Issue
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
Solution
try to unpack the tmp
dict:
df1= df1.assign(**tmp)
Answered By - MaxU - stand with Ukraine
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.