Skip to content
Advertisement

How to convert a whole column from string type to date type in mongodb with pymongo

My data consist of 1million rows. A sample look like this:

JavaScript

The thing is that date2 and date4 are in the form that i want but they are string and i want to convert them to date. The code i have used look like this:

JavaScript

Do i need to convert them before inserting or after? Does anyone know how i can do that?

Advertisement

Answer

If it were me, I’d want to combine date2/time3 into one column, and date4/time5, as in:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement