【发布时间】:2021-10-26 13:16:56
【问题描述】:
我有一个数据框
timestamp
2020-08-26
2020-08-27
2020-08-28
我希望它看起来像这样
timestamp
2020-08-26 00:00:00
2020-08-27 00:00:00
2020-08-28 00:00:00
我试过了
df['timestamp'] = df['timestamp'].apply(lambda x: dt.datetime.strftime(x, '%Y-%m-%d %H:%M:%S'))
但它给出了一个问题 TypeError: descriptor 'strftime' for 'datetime.date' objects does not apply to a 'str' object
感谢您的帮助
【问题讨论】:
-
df['timestamp'] = pd.to_datetime(df['timestamp'], format='%Y-%m-%d %H:%M:%S')
标签: python python-3.x pandas dataframe datetime