簡體   English   中英

astype 熊貓上的錯誤?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM