[英]How to Convert Multiple Unix TimeStamp to Pandas Datetime?
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. 尝试将多个unix时间戳转换为大熊猫中的日期时间时出现以下错误,我尝试设置值,但似乎不正确。
ValueError: to assemble mappings requires at least that [year, month, day] be specified: [day,month,year] is missing
ValueError:组装映射至少需要指定[年,月,日]:[天,月,年]丢失
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 数据集有助于简化测试解决方案,但是无论如何对于unix时间戳,解决方案都是
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 如@MaxU建议,如果您需要将所有以'_at'结尾的列转换为时间戳,则可以使用
ksdata.filter(regex='_at$')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.