有some similar questions,但那里的回复对我不起作用。
我正在尝试这样做,如warnings documentation:
中所述def disable_pandas_warnings():
import warnings
warnings.resetwarnings() # Maybe somebody else is messing with the warnings system?
warnings.filterwarnings('ignore') # Ignore everything
# ignore everything does not work: ignore specific messages, using regex
warnings.filterwarnings('ignore', '.*A value is trying to be set on a copy of a slice from a DataFrame.*')
warnings.filterwarnings('ignore', '.*indexing past lexsort depth may impact performance*')
我在测试/程序开始时调用它:
disable_pandas_warnings()
正如您在评论中所看到的,我有:
似乎没有效果:消息仍然显示。如何禁用所有警告?