在这种情况下,SettingWithCopyWarning是什么?如何避免呢?

时间:2018-08-23 10:05:47

标签: python pandas numpy warnings

我正在尝试通过运行以下代码将数据框中的所有NaN值替换为零,但它似乎不起作用,并且得到警告:

# X is some DataFrame

for row in range(X.shape[0]):
    for col in range(X.shape[1]):
        if np.isnan(X.iloc[row, col]) == True:
            X.iloc[row, col] = 0.

SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame

0 个答案:

没有答案