I've tried to convert a series of date where the format is yyyymmdd
to executable pandas datetime
format.
20180331
to 2018-03-31
Timestamp method is giving error.
You can use pandas to_datetime to convert
pd.to_datetime('20180331 ')
Out:
Timestamp('2018-03-31 00:00:00')
and you can make use of strip time to extract your required information of days, month ,year etc
%m - month of timestamp
%y - year with last 2 digts
%Y - year of timestamp
%d - date of timestamp
%H - hours of timestmap
%M - minutes of timestamp
pd.to_datetime('20180331 ').strftime('%Y:%m:%d')
Out:
'2018:03:31'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.