我使用了2个处理程序,我不想在StremHandler
中像这样编写所有的库警告
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
return super().rename(
/home/anaconda3/envs/test_pr/lib/python3.8/site-packages/pandas/core/frame.py:4441: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame
我尝试使用logging.disable(logging.WARNING)
,但它不工作。
我的StreamHandler
是
logger = logging.getLogger()
logger.setLevel(logging.INFO)
# create console handler
ch = logging.StreamHandler(sys.stdout)
ch.setLevel(logging.INFO)
logger.addHandler(ch)
为你的处理器添加一个过滤器,过滤掉你不想输出的内容:
def filter(record):
"""Filter out warnings - this is just an example"""
return record.levelno != logging.WARNING
ch = logging.StreamHandler(sys.stdout)
ch.addFilter(filter)