Yash
Yash

Reputation: 1

SettingWithCopyWarning Python3

I am finding the max of df2 by row, and setting the max value to new col on df1.

df1['max'] = df2[df2.keys().tolist()].max(axis=1)

This line is throwing a SettingWithCopyWarning. Not sure how to re-write it to make the warning go away. How to re-write it?

Upvotes: 0

Views: 101

Answers (1)

greco
greco

Reputation: 325

The warning typically is a result of chained assignments and you can read more about it in this answer and this blog post also goes into great detail.

If you wish to turn it off, you can use:

pd.options.mode.chained_assignment = None

Upvotes: 0

Related Questions