You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Full details and workaround are available in this SO question
Code Sample, a copy-pastable example if possible
importnumpyasnpimportpandasaspdfromnumpyimportarounddf=pd.DataFrame({'x':np.array([1.12,2.76])})
# this throws TypeError: 'Series' objects are mutable, thus they cannot be hasheddf['y'] =df.eval('@around(x,1)')
Problem description
The evaluated expression should work because around is imported into the local namespace. There are two solutions:
remove numexpr from the environment.
set the engine for parsing the expression to be python:
df['y'] =df.eval('@around(x,1)', engine='python')
Expected Output
x y
0 1.133320 1.1
1 2.733336 2.7
Output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.7.0.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en
LOCALE: None.None
@jreback Eval does support in line function evaluation.
I edited my first post to show that there actually is a better solution - specify the parsing engine to be python, no need to remove numexpr from the environment. Running df['y'] = df.eval('@around(x,1)', engine = 'python') produces the expected output.
I'm not sure this is a bug anymore, the workaround to the original issue is trivial.
@jreback : I'm not entirely sure which issue this duplicates, so labeling for now. Given that the code works with engine='python', is that just coincidental?
Full details and workaround are available in this SO question
Code Sample, a copy-pastable example if possible
Problem description
The evaluated expression should work because
around
is imported into the local namespace. There are two solutions:numexpr
from the environment.Expected Output
Output of
pd.show_versions()
pandas: 0.23.4
pytest: None
pip: 10.0.1
setuptools: 40.2.0
Cython: None
numpy: 1.15.1
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 6.5.0
sphinx: 1.7.8
patsy: None
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: None
tables: None
numexpr: 2.6.8
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 1.0.1
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: