我正在尝试通过运行以下代码将数据框中的所有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