I'm trying to use df.eval to evaluate an expression that contains a call to a function - in my example it's numpy.around which I have imported in the local namespace. According to the documentation, using @ before the function name should do the trick, but it throws this error
TypeError: 'Series' objects are mutable, thus they cannot be hashed
What am I doing wrong? Doesn't work after fresh run, in IDE (Spyder / Jupyter notebook) or from console.
import numpy as np
import pandas as pd
from numpy import around
df = pd.DataFrame({'x':np.array([1.12,2.76])})
# this throws TypeError: 'Series' objects are mutable, thus they cannot be hashed
df['y'] = df.eval('@around(x,1)')
# this works
df['z'] = around(df['x'],1)
print(pd.__version__)
# 0.23.4
print(np.__version__)
# 1.15.1
import sys
print(sys.version)
# 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:27:44) [MSC v.1900 64 bit (AMD64)]
numpy1.14.5,pandas0.20.3{'x': {0: 1.12, 1: 2.76}, 'y': {0: 1.1, 1: 2.8}}which looks correct...