emie
emie

Reputation: 289

Python hide / disable warnings

How do you go about hiding the following warnings?

I did write the following but it doesn't work:

warnings.filterwarnings("ignore", category=DeprecationWarning) 

I also run the code using

%run -i "Admin_Vision_POC_Version_0_E.py" -W ignore

Here is the list of warnings that I'm getting:

Admin_Vision_POC_Version_0_E.py:218: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  output = interactive_w2v_mode('w2v_model_bigdata',arg)
Admin_Vision_POC_Version_0_E.py:219: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

    See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
      maximumKey = max(output.items(), key=operator.itemgetter(1))[0]
    c:\Anaconda3\lib\site-packages\pandas\core\frame.py:4133: SettingWithCopyWarning: 
    A value is trying to be set on a copy of a slice from a DataFrame

    See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
      errors=errors,

Upvotes: 1

Views: 1015

Answers (1)

emie
emie

Reputation: 289

I ended up using the following code to suppress warnings:

pd.options.mode.chained_assignment = None

Upvotes: 2

Related Questions