I get the following error when trying to convert multiple the unix timestamps to a datetime in pandas, I've tried setting values but seem to not be getting it right.
ValueError: to assemble mappings requires at least that [year, month, day] be specified: [day,month,year] is missing
Here's the code:
pd.to_datetime(ksdata[['state_changed_at','created_at','launched_at']])
It's got to be something simple but I just can't see it.
Sample of file
The dataset helps as its easier to test the solution but anyway for unix timestamp, solution would be
ksdata[['state_changed_at','created_at','launched_at']] = ksdata[['state_changed_at','created_at','launched_at']].\
apply(pd.to_datetime, unit = 's')
As @MaxU suggested, if you need to convert all the columns ending with '_at' to timestamp, you can filter them using
ksdata.filter(regex='_at$')
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.