I am having an issue with SettingWithCopyWarning and values not being replaced. I searched on this site pretty extensively, and all I'm seeing in terms of dealing with SettingWithCopyWarning is to use copy(). However, trying to replace any missing values in col1 with the values in col2 even with the following code is not working for me-
import numpy as np
import pandas as pd
import copy
test = pd.DataFrame({'a':[1,np.nan,3], 'b':[5,6,7]})
test2 = test.copy()
test3 = test.copy()
test2.loc[np.isnan(test2['a']) & (np.isnan(test2['b']) == False)]['a'] =
test3.loc[np.isnan(test3['a']) & (np.isnan(test3['b']) == False)]['b']
print(test2)
The NaN in the first column is still there, and I am still getting the SettingWithCopyWarning. What am I missing?