How can I tell pandas to return datetime64
rather than Timestamp
? For example, in the following code df['dates'][0]
returns a pandas Timestamp
object rather than the numpy datetime64
object that I put in.
Yes, I can convert it after getting it, but is it possible to tell pandas to give me back exactly what I put in?
>>> import numpy as np
>>> import pandas as pd
>>> np.__version__
'1.10.4'
>>> pd.__version__
u'0.19.2'
>>> df = pd.DataFrame()
>>> df['dates'] = [np.datetime64('2019-02-15'), np.datetime64('2019-08-15')]
>>> df.dtypes
dates datetime64[ns]
dtype: object
>>> type(df['dates'][0])
<class 'pandas.tslib.Timestamp'>