Code Sample, a copy-pastable example if possible
This is the following SO issue: http://stackoverflow.com/questions/37195658/pandas-typeerror-series-name-must-be-a-hashable-type
Call to Func_df(df):
pattern_tmp1 = grouped[['sprd1','cost1']].apply(Func_df)[0]
Input df to Func_df(df):
sprd1 cost1
date
2016-01-31 -19.02 -436.31
def Func_df(df): cases_list = [monthly_pattern_check(x,y) for x,y in zip(df[[0]].values,df[[1]].values)] print collections.Counter(cases_list) return dict(collections.Counter(cases_list))
def monthly_pattern_check(r,c): if r > c > 0: return 'A' elif c > r > 0 : return 'B' elif r > 0 > c: return 'C' elif r == 0 and c > 0: return 'D' elif r < c < 0: return '-A' elif c < r < 0: return '-B' elif r < 0 < c: return '-C' elif r == 0 and c < 0: return '-D'
Expected Output
pattern_tmp1 should be assigned to the the [0] index value of Counter({'-B': 1})
output of pd.show_versions()
INSTALLED VERSIONS
commit: None python: 2.7.11.final.0 python-bits: 64 OS: Darwin OS-release: 13.4.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_US.UTF-8
pandas: 0.18.1 nose: 1.3.7 pip: 8.1.1 setuptools: 20.7.0 Cython: 0.22.1 numpy: 1.10.4 scipy: 0.16.0 statsmodels: None xarray: None IPython: 4.0.0 sphinx: 1.3.1 patsy: 0.3.0 dateutil: 2.4.2 pytz: 2015.4 blosc: None bottleneck: 1.0.0 tables: 3.2.0 numexpr: 2.4.4 matplotlib: 1.4.3 openpyxl: 1.8.5 xlrd: 0.9.3 xlwt: 1.0.0 xlsxwriter: 0.7.3 lxml: 3.4.4 bs4: 4.3.2 html5lib: None httplib2: None apiclient: None sqlalchemy: 1.0.5 pymysql: None psycopg2: None jinja2: 2.8 boto: 2.38.0 pandas_datareader: None
Comment From: shoyer
Please provide a minimal complete verifiable example: http://stackoverflow.com/help/mcve
Comment From: jorisvandenbossche
It is pandas that now requires that the Series name is hashable. You probably updated your pandas version as well together with numba.
See https://github.com/pydata/pandas/issues/12610 and https://github.com/pydata/pandas/pull/12612. The series name not being hashable caused a bug that was fixed in pandas 0.18.1
Comment From: jorisvandenbossche
@algotr8der You should investigate how it comes that you end up with a series name that is a dict, and then try to see how you can achieve what you want using a regular column name.