'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?
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | greco |