I'm getting SettingWithCopyWarning on the following code although I use .loc.
import pandas as pd
df = pd.DataFrame([10,10,11,11,12,12],columns=['num'])
mask = (df['num'] % 2) == 0
df = df.drop_duplicates(keep='last')
df.loc[mask, 'num'] = 7
I think it might be because I create the mask and after drop the duplications, but I can't change the order in my case.
Any other idea to solve it?