-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Pandas breaks warnings module when printing DataFrame #31978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
warnings
module when printing DataFrame
Can you show the result of |
BTW, I can't reproduce this with pandas master on Python 3.7, and also not with pandas 1.0.0 on Python 3.8 |
@jorisvandenbossche, here is the same output for >>> import warnings
>>> import pandas as pd
>>> warnings.warn('asd')
<input>:1: UserWarning: asd
>>> warnings.warn('asd')
>>> warnings.warn('asd')
>>> df = pd.DataFrame([1])
>>> warnings.warn('asd')
>>> warnings.warn('asd')
>>> warnings.warn('asd')
>>> df
0
0 1
>>> warnings.warn('asd')
>>> warnings.warn('asd')
>>> warnings.warn('asd') Output of INSTALLED VERSIONScommit : None pandas : 0.25.3 |
A little update. First of all, all the tests were being done using PyCharm's Python Console. When I wrote a script file and then run it, the behavior is a bit different. Here is the script: import sys
import warnings
from time import sleep
import pandas as pd
def do_warn():
sleep(1)
warnings.warn('asd')
sys.stdout.flush()
print('Printing warning 3 times', flush=True)
do_warn()
do_warn()
do_warn()
print('Creating DataFrame and then printing warning 3 times', flush=True)
df = pd.DataFrame([1])
do_warn()
do_warn()
do_warn()
print('Printing DataFrame and then printing warning 3 times', flush=True)
print(df)
do_warn()
do_warn()
do_warn()
print('Printing DataFrame AGAIN and then printing warning 3 times', flush=True)
print(df)
do_warn()
do_warn()
do_warn()
print('Printing DataFrame AGAIN and then printing warning 3 times', flush=True)
print(df)
do_warn()
do_warn()
do_warn() I use
It seems like printing |
Seems like this may be a PyCharm issue potentially since it's not reproducible with other set ups so closing. Can reopen if it appears again |
Problem description
As you can see from the interactive Python listed above, when
DataFrame
is printed, suddenly all calls towarnings.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
The text was updated successfully, but these errors were encountered: