I have seen this a million times, I am somehow chaining indexes and am getting a setting with copy warning. The code I am using is below:
toEmail['median'] = np.nanmedian(toEmail.filter(like = 'foo_'), axis = 1)
I am guessing that it has to do with filter is creating some slice but I am not sure. I have tried the following, neither of which worked.
toEmail['median'] = np.nanmedian(toEmail.filter(like = 'foo_').copy(deep=True), axis = 1)
toEmail['median'] = list(np.nanmedian(toEmail.filter(like = 'foo_'), axis = 1))
--- EDIT ---
Per the comments I got this dataframe from this:
toEmail = fullDf[['foo_1', 'foo_2', 'bar_1', 'bar_2']]
and adding the copy here fixes the issues
toEmail = fullDf[['foo_1', 'foo_2', 'bar_1', 'bar_2']].copy()