我可以轻松地将时间戳转换为日期时间:
>>> time = pd.Timestamp('2016-02-05 00:02:00')
Timestamp('2016-02-05 00:02:00')
>>> time.to_datetime()
datetime.datetime(2016, 2, 5, 0, 2)
但出于某种原因,当我尝试将其应用于整个系列时,值不会改变类型:
>>> time = pd.Series([pd.Timestamp('2016-02-05 00:02:00'), pd.Timestamp('2016-02-05 00:03:00'), pd.Timestamp('2016-02-05 00:04:00')])
0 2016-02-05 00:02:00
1 2016-02-05 00:03:00
2 2016-02-05 00:04:00
dtype: datetime64[ns]
>>> time.apply(lambda x: x.to_datetime())
0 2016-02-05 00:02:00
1 2016-02-05 00:03:00
2 2016-02-05 00:04:00
dtype: datetime64[ns]
如何将整个系列转换为日期时间?