Reputation: 305
I have a column in a Pandas data frame that has a date column but has datetime and date mixed in together as follows:
2020-05-20 00:00:00
2020-05-21 00:00:00
2020-05-22
2020-05-23
Is there any way to convert everything to a date format as follows:
2020-05-20
2020-05-21
2020-05-22
2020-05-23
Upvotes: 0
Views: 474
Reputation: 862791
Convert values to strings and then to datetimes, last to dates:
pd.to_datetime(df['date'].astype(str)).dt.date
Upvotes: 2