22

How I can supress a PerformanceWarning in pandas?

I've already tried warnings.simplefilter(action='ignore', category=PerformanceWarning), but it gives me a NameError: name 'PerformanceWarning' is not defined

Vaiaro
  • 908
  • 1
  • 9
  • 20
  • Can you try putting `warnings.simplefilter(action='ignore', category=PerformanceWarning)` before `import pandas`? – the-lay Jul 25 '18 at 14:41

1 Answers1

49

PerformanceWarning is not a built-in warning class so you can't call it directly in category argument. You can try the following code:

import pandas as pd
import warnings

warnings.simplefilter(action='ignore', category=pd.errors.PerformanceWarning)

I have no idea how to reproduce the PerformanceWarning but i tested a similar approach to the "SettingWithCopyWarning" pandas warning and it worked. Let me know if it works.

Safvan CK
  • 1,140
  • 9
  • 18
FiloCara
  • 666
  • 7
  • 7