只保留日期时间中的月、日、年,使用Pandas。

9 浏览
0 Comments

只保留日期时间中的月、日、年,使用Pandas。

如果我有一个包含日期的日期列,如下所示:\n

df['date_utc'] = pd.to_datetime(df['date_utc'])
df['date_utc']
0       2020-12-01 22:08:07
1       2020-11-11 14:30:09
2       2020-11-10 18:30:09
3       2020-11-08 15:00:12
4       2020-11-05 17:30:29

\n如何只返回日期类型的数据?\n

df['date']
2020-12-01
2020-11-11
2020-11-10

0