Skip to content

Pandas breaks warnings module when printing DataFrame #31978

Closed
@fisheye36

Description

@fisheye36
>>> import warnings
>>> warnings.warn('asd')
<input>:1: UserWarning: asd
>>> warnings.warn('asd')
>>> warnings.warn('asd')
>>> import pandas as pd
>>> df = pd.DataFrame([1])
>>> warnings.warn('asd')
<input>:1: UserWarning: asd
>>> warnings.warn('asd')
>>> df
   0
0  1
>>> warnings.warn('asd')
<input>:1: UserWarning: asd
>>> warnings.warn('asd')
<input>:1: UserWarning: asd
>>> warnings.warn('asd')
<input>:1: UserWarning: asd
>>> warnings.warn('asd')
<input>:1: UserWarning: asd

Problem description

As you can see from the interactive Python listed above, when DataFrame is printed, suddenly all calls to warnings.warn() are being reported, instead of being suppressed when identical warning is issued.

The problem does not occur on Pandas version 0.25.3.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.8.1.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1250
pandas : 1.0.1
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 45.1.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.2.7
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.1.3
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : 1.2.7
numba : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugRegressionFunctionality that used to work in a prior pandas versionWarningsWarnings that appear or should be added to pandas

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions