I am writing a single entry from a column of a data frame
2011100101 is interpreted as 1 AM of 1st October 2011.
I want it to change in the format as YYYY-Mmm-dd HH
train['date1']=datetime.strptime(train['ID'], '%Y%m%d%H')
but getting an error TypeError: strptime() argument 1 must be string, not Series
How to change in the required format for the entire entries in a single column?
you can use the apply() method
train['date1'] = train['ID'].apply(lambda x: datetime.strptime(x, '%Y%m%d%H'))
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