How to eliminate suppression warnings by python
This article mainly introduces python how to eliminate suppression warnings, the article is very detailed, has a certain reference value, interested friends must read it!
1. Use loc to act on a subset of slices.
Df2 = df.loc [:, ['A']] df2 ['A'] / = 2 # Does not raise
2. Change pd.options.mode.chained_assignment. Can be set to None, "warn" or "raise".
"warn" is the default.
None completely suppresses the warning and "raise" throws a SettingWithCopyError to prevent the operation from passing.
Pd.options.mode.chained_assignment = None df2 ['A'] / = 2
3. Make a deepcopy.
Df2 = df [['A']] .copy (deep=True) df2 ['A'] / = 2 is all the content of the article "how to eliminate suppression warnings in python". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!