下面是我的数据框
from pandas import Timestamp
df = pd.DataFrame({'Year': [Timestamp('2023-03-14 00:00:00'),Timestamp('2063-03-15 00:00:00'),Timestamp('2043-03-21 00:00:00'),Timestamp('2053-10-09 00:00:00')],
'offset' : [1, 9, 8, 1]
})
当我将“年份”列转换为 list() 时,它们被保存为时间戳
>>> df['Year'].to_list()
[Timestamp('2023-03-14 00:00:00'),
Timestamp('2063-03-15 00:00:00'),
Timestamp('2043-03-21 00:00:00'),
Timestamp('2053-10-09 00:00:00')]
但是,当我转换为值时,它们会保存为 datetime64
>>> df['Year'].values
array(['2023-03-14T00:00:00.000000000', '2063-03-15T00:00:00.000000000',
'2043-03-21T00:00:00.000000000', '2053-10-09T00:00:00.000000000'],
dtype='datetime64[ns]')
如何获取我的数组Timestamp
本身(而不是datetime64
格式)?