-
-
Notifications
You must be signed in to change notification settings - Fork 19.5k
Description
Code Sample
After some hypothesis testing on our codebase we noticed that pd.eval can cause a max recursion limit when run on an empty dataframe or an all NaN dataframe:
import pandas as pd
df = pd.DataFrame(index=list(range(0,1)), columns=list('abc'))
df.eval('a*b') # Max recursion limitAnd:
import pandas as pd
df = pd.DataFrame(columns=list('abc'))
df.eval('a*b') # Max recursion limitInterestingly enough using numpy.nan works correctly so the error is caused if the data is native python nan:
import pandas as pd
import numpy as np
df = pd.DataFrame(index=list(range(0,1)), columns=list('abc'), data=np.nan)
df.eval('a*b')This seems to happen on 0.19.2 so I don't think this is a regression.
A similar issue was raised in 2013 #5198
INSTALLED VERSIONS
Details
commit : None
python : 3.6.5.final.0
python-bits : 64
OS : Windows
OS-release : 7
machine : AMD64
processor : Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 0.25.0
numpy : 1.16.4
pytz : 2018.4
dateutil : 2.7.3
pip : 10.0.1
setuptools : 39.1.0
Cython : None
pytest : 3.5.1
hypothesis : None
sphinx : 1.8.2
blosc : None
feather : None
xlsxwriter : 1.0.4
lxml.etree : 4.1.1
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10
IPython : 6.4.0
pandas_datareader: None
bs4 : 4.7.1
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.1.1
matplotlib : 2.2.2
numexpr : 2.6.5
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.1.0
sqlalchemy : 1.2.8
tables : 3.5.2
xarray : None
xlrd : 1.1.0
xlwt : None
xlsxwriter : 1.0.4