So I'm trying to be a good person and re-write this:
df1["Cum Correct"] = df1.groupby(level=0)["Correct"].cumsum()
which triggers the over-zealous SettingWithCopyWarning with this:
tmp={'Cum Correct': df1.groupby(level=0)["Correct"].cumsum()}
df1= df1.assign(tmp)
as based on what I read using assign is the correct approach. However this gives me the error:
TypeError: assign() takes 1 positional argument but 2 were given
try to unpack the tmp dict:
df1= df1.assign(**tmp)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With