My dataset has a date column that I need to do some calculations with. One typical cell would look like "3/21/2020" and I checked with dtypes, they are all objects. I want to know the difference between two dates, what should I do with the dates? What should I convert them to? And how can I do the calculation? I am not so familiar with datetime package. I hope this description is clear. Thanks in advance!
Asked
Active
Viewed 26 times
0
-
1You should probably convert them to date. `df['object_column'] = pd.to_datetime(df['object_column], errors='coerce')` You can also add a default value if the cells contain wonky data. DT fields can be rough. – eddyizm Jul 16 '20 at 23:13
-
1Does this answer your question? [Convert Pandas Column to DateTime](https://stackoverflow.com/questions/26763344/convert-pandas-column-to-datetime) – Trenton McKinney Jul 16 '20 at 23:30
-
That worked thank you! – Jingqi Wang Jul 16 '20 at 23:41