[英]timedelta to integers while ignoring NaT values in a python pandas DataFrame
I created a timedelta column and got a couple of NaT values, they are actually important for me to conserve.我创建了一个 timedelta 列并获得了几个 NaT 值,它们实际上对我来说很重要,可以保存。 Now I want to transform my timedelta which is now like this: 234 days and NaT values.
现在我想改变我的时间增量,现在是这样的:234 天和 NaT 值。 I want to get integers.
我想得到整数。 These is the code so far:
这些是到目前为止的代码:
reports['delinquency_free_time'] = reports['delinquency_free_time'].dt.total_seconds().astype(int)
ValueError: Cannot convert non-finite values (NA or inf) to integer
ValueError:无法将非有限值(NA 或 inf)转换为 integer
Please note that the days instead of total_seconds also didn't work请注意,days 而不是 total_seconds 也不起作用
ok, I understood something: I might not convert to int but I can convert to float.好的,我明白了一些事情:我可能不会转换为 int,但我可以转换为 float。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.