[英]How to return individual dates from a date-time series in Python?
I have a datetime column in a data frame.我在数据框中有一个日期时间列。 From that column i want to return every single day.从那一栏我想每天都回来。 In that df, I have 14 days and each day has so many values with even miliseconds.在那个df中,我有14天,每一天都有很多甚至毫秒的值。
So I want a output like [2022-07-18, 2022-07-19,………………]所以我想要一个 output 像 [2022-07-18, 2022-07-19,………………]
You can standardize the format with .dt.date
.您可以使用.dt.date
标准化格式。 If it has not yet been converted into datetime, then use:如果尚未转换为日期时间,则使用:
df['Dates'] = pd.to_datetime(df['Dates'],infer_datetime_format=True).dt.date
Did you read the official documentation of pandas about this topic?您是否阅读过有关此主题的 pandas 官方文档? https://pandas.pydata.org/docs/reference/api/pandas.to_datetime.html https://pandas.pydata.org/docs/reference/api/pandas.to_datetime.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.