Python Pandas – How to supress PerformanceWarning?

痞子三分冷 提交于 2020-12-11 02:17:09

问题


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


回答1:


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
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.



来源:https://stackoverflow.com/questions/51521526/python-pandas-how-to-supress-performancewarning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!