【问题标题】:How can I fix for unhashable type series problemHow can I fix for unhashable type series problem
【发布时间】:2022-12-27 20:48:28
【问题描述】:
The following code has generated this error message:
(dd
[['cfs']]
.loc['2018/3':'2019/5']
.query('cfs.isna()')
)
--->TypeError: unhashable type: 'Series'
Can somebody help me in figuring out the problem?
【问题讨论】:
标签:
python
pandas
numpy
time-series
data-science
【解决方案1】:
This has been around for a while so thought I would provide one possible solution.
Based on this github issue filed to Matt Harrisons project for the book Effective Pandas, you should add engine='python' to the query arguments.
.query('cfs.isna()', engine='python')
This worked for me.
The reason appears to be that the 'numexpr' engine, which is used by default by pandas.eval if it's installed (which appears to be the case with Anaconda Python), cannot handle pd.Series