Code Sample, a copy-pastable example if possible
import pandas as pd
df = pd.DataFrame({'x': [1, 2, 3], 'y': [2, 3, 4]})
df.eval('(x - y)').std() # evaluates
df.eval('(x - y).std()') # exception: AttributeError: 'BinOp' object has no attribute 'value'
Problem description
I expected this type of eval()
expression to work correctly. I'm not sure how to justify the behavior other than it being more intuitive and practical.
I searched and was able to find similar errors, but the cause seems to be with UnaryOp
instead of BinOp
:
* https://github.com/pandas-dev/pandas/issues/16363
Expected Output
>>> import pandas as pd
>>> df = pd.DataFrame({'x': [1, 2, 3], 'y': [2, 3, 4]})
>>> df.eval('(x - y)').std() # evaluates
0.0
>>> df.eval('(x - y).std()') # should also evaluate
0.0
Output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.3.final.0
python-bits: 64
OS: Linux
OS-release: 4.13.0-32-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.22.0
pytest: None
pip: 9.0.1
setuptools: 32.3.1
Cython: None
numpy: 1.14.0
scipy: None
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.2.0
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.999999999
sqlalchemy: 1.2.2
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
Comment From: jreback
closing as duplicate of #16363
function calls are simply not implemented. would take a PR fixing this.