我的代碼中有以下陳述句:
mcap_summary['cap'].cat.set_categories(['Large','Mid','Small','None'],inplace=True)
現在生成一個警告: D:\Python\Python39\lib\site-packages\pandas\core\arrays\categorical.py:2630: FutureWarning: The inplaceparameter in pandas.Categorical.set_categories is deprecated and will be removed in a未來版本。洗掉未使用的類別將始終回傳一個新的 Categorical 物件。res = 方法(*args, **kwargs)
我該怎么寫才能避免這個警告和未來的錯誤?
提前致謝
uj5u.com熱心網友回復:
pandas v1.3.0 洗掉了“就地”選項。
所以你可以像下面這樣編碼:
mcap_summary['cap'] = mcap_summary['cap'].cat.set_categories(['Large', 'Mid', 'Small', 'None'])
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/381296.html
上一篇:型別錯誤:預期的str、bytes或os.PathLike物件,而不是Series
下一篇:將列轉換為資料框列geaders
