Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: strptime() argument 1 must be string, not Series

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?

like image 900
Ashish Choudhary Avatar asked Oct 13 '17 20:10

Ashish Choudhary


1 Answers

you can use the apply() method

train['date1'] = train['ID'].apply(lambda x: datetime.strptime(x, '%Y%m%d%H'))
like image 198
bouletta Avatar answered Sep 28 '22 19:09

bouletta