我有一个日期时间值列表,我想要添加到熊猫中的列。但是,每当我将其添加为列时,值都会更改为键入时间戳。如何获取它以便我可以将该列及其值保留为datetime类型?
Code:
#partialDates is a datetime list
#partialddf is a panda dataframe
print 'Type as an independent list:'
print type(partialDates[0])
partialddf['A'] = partialDates
print 'Type once inside panda as a colum:'
print type(partialddf['A'].tolist()[0])
Output:
Type as an independent list:
<type 'datetime.datetime'>
Type once inside panda as a colum:
<class 'pandas._libs.tslib.Timestamp'>