在数据帧Pandas上应用apply时使用copywarning获取SettingWithCopyWarning

2024-09-29 23:21:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直收到这个警告,但我真的不知道我应该在这里改变什么:

C:\Users\3626416\Software\Anaconda\lib\site-packages\pandas\core\indexing.py:543:
    SettingWithCopyWarning:
        A value is trying to be set on a copy of a slice from a DataFrame.
        Try using .loc[row_indexer,col_indexer] = value instead

请参见文档中的注意事项:
http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy

^{pr2}$

这是我的代码:

df_pcl.loc[:,['Weight','Pieces','Cons','DeadWeight']] = df_pcl.loc[:,['Weight','Pieces','Cons','DeadWeight']] * pcl2docRtio

Tags: 警告pandasdfvaluesoftwareuserslocpcl

热门问题