assign() takes 1 positional argument but 2 were given (SettingWithCopyWarning)

Viewed 2284

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
1 Answers
Related