![](/img/trans.png)
[英]Working Around the Windows-numpy astype(int) Bug in Pandas
[英]Bug on astype pandas?
我正在使用 timedeltas,似乎这段代码
copy_for_U.Time.astype('timedelta64[m]',copy=False);
不会更改数据框 - 如果我从文档中正确理解,它应该如此,它说:
Signature: full_df.Time.astype(dtype, copy=True, raise_on_error=True, **kwargs) Docstring: Cast object to input numpy.dtype Return a copy when copy = True (be really careful with this!)
为了将更改应用于数据帧,需要将数据帧分配给所需的变量(或传递inplace=True
-这可能是一个很好的阅读线程)。
此外,这样做时,您不需要传递copy=False
,正如@jezrael 建议的那样。
鉴于此,这应该可以解决您的问题
copy_for_U.Time = copy_for_U.Time.astype('timedelta64[m]')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.