pandas.errors.SettingWithCopyWarning#

exception pandas.errors.SettingWithCopyWarning[源代码]#

尝试在 DataFrame 的副本切片上设置值时引发的警告。

此时 mode.chained_assignment 需要设置为 ‘warn’。’Warn’ 是默认选项。当发生链式索引时,这可能无意中发生。

有关求值顺序的更多信息,请参阅 the user guide

For more information on view vs. copy, see the user guide.

Examples

>>> df = pd.DataFrame({'A': [1, 1, 1, 2, 2]}, columns=['A'])
>>> df.loc[0:3]['A'] = 'a' 
... # SettingWithCopyWarning: A value is trying to be set on a copy of a...