I want to convert this Timestamp object to datetime this object was obtained after using asfreq on a dataframe this is the last index
Timestamp('2018-12-01 00:00:00', freq='MS')
<class 'pandas._libs.tslibs.timestamps.Timestamp'>
wanted output
2018-12-01
do you want this?
from pandas._libs.tslibs.timestamps import Timestamp
ts = Timestamp('2018-12-01 00:00:00', freq='MS')
date_time = ts.to_pydatetime()
And if you just want a string then you can do this:
print(str(ts).split()[0])
out:
'2018-12-01'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With