BUG: .fillna(-1)
does not work in pd.eval
· Issue #46471 · pandas-dev/pandas (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Description
Pandas version checks
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of pandas.
- I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd def test_unary(val): df = pd.DataFrame({'x': np.array([0.11, 0], dtype=np.float32)}) res = df.eval(f'x=x.fillna({val})') test_unary(1) # works test_unary(-1) # fails
Issue Description
.eval
seems to be having some problems with negative values. A very similar issue has been reported, summarized and closed here: #16363
However, it clearly still persists in other instances.
Expected Behavior
test_unary(-1) # works
Installed Versions
INSTALLED VERSIONS
commit : 66e3805
python : 3.9.10.final.0
python-bits : 64
OS : Linux
OS-release : 5.13.0-35-generic
Version : #40~20.04.1-Ubuntu SMP Mon Mar 7 09🔞32 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.3.5
numpy : 1.21.2
pytz : 2021.3
dateutil : 2.8.2
pip : 21.3.1
setuptools : 58.2.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.2
IPython : 7.28.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : 2021.11.1
fastparquet : None
gcsfs : None
matplotlib : 3.4.3
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 5.0.0
pyxlsb : None
s3fs : 2021.11.1
scipy : 1.7.1
sqlalchemy : 1.4.25
tables : None
tabulate : 0.8.9
xarray : None
xlrd : None
xlwt : None
numba : 0.55.0