首页 > 解决方案 > 如何避免 Pandas 中的警告?

问题描述

我有一个关于熊猫的问题。

我写了以下代码:

df_all.loc[df_all['_merge'] == 'right_only', ['count', 'Discount', 'RefPrice']] = df_all.loc[df_all['_merge'] == 'right_only', ['old_count', 'old_Discount', 'old_RefPrice']].values

但是,Python 返回一个警告:

Warning (from warnings module):
    File "C:\python-3.6.6.amd64\lib\site-packages\pandas\core\indexing.py", line 1472
        return self._getitem_tuple(key)
FutureWarning: 
Passing list-likes to .loc or [] with any missing label will raise
KeyError in the future, you can use .reindex() as an alternative.
    
See the documentation here:
https://pandas.pydata.org/pandas-docs/stable/indexing.html#deprecate-loc-reindex-listlike

我能做些什么来避免这个警告?

非常感谢。

标签: pythonpandas

解决方案


推荐阅读