我不确定您为什么首先要这样做,但是如果您确实需要…
df = pd.Dataframe({'my_timestamp': pd.date_range('2016-1-1 15:00', periods=5)})>>> df my_timestamp0 2016-01-01 15:00:001 2016-01-02 15:00:002 2016-01-03 15:00:003 2016-01-04 15:00:004 2016-01-05 15:00:00df['new_date'] = [d.date() for d in df['my_timestamp']]df['new_time'] = [d.time() for d in df['my_timestamp']]>>> df my_timestamp new_date new_time0 2016-01-01 15:00:00 2016-01-01 15:00:001 2016-01-02 15:00:00 2016-01-02 15:00:002 2016-01-03 15:00:00 2016-01-03 15:00:003 2016-01-04 15:00:00 2016-01-04 15:00:004 2016-01-05 15:00:00 2016-01-05 15:00:00转换为CST比较棘手。我假设当前时间戳是“不知道的”,即它们没有附加时区?如果没有,您将如何转换它们?
更多细节:
https://docs.python.org/2/library/datetime.html
如何在python中识别未知的日期时间时区
编辑
另一种方法仅在时间戳上循环一次,而不是两次:
new_dates, new_times = zip(*[(d.date(), d.time()) for d in df['my_timestamp']])df = df.assign(new_date=new_dates, new_time=new_times)



