Skip to content

pandas TypeError: Series.name must be a hashable type #13162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
algotr8der opened this issue May 12, 2016 · 3 comments
Closed

pandas TypeError: Series.name must be a hashable type #13162

algotr8der opened this issue May 12, 2016 · 3 comments

Comments

@algotr8der
Copy link

algotr8der commented May 12, 2016

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

@shoyer
Copy link
Member

shoyer commented May 12, 2016

Please provide a minimal complete verifiable example: http://stackoverflow.com/help/mcve

@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented May 12, 2016

It is pandas that now requires that the Series name is hashable. You probably updated your pandas version as well together with numba.

See #12610 and #12612. The series name not being hashable caused a bug that was fixed in pandas 0.18.1

@jorisvandenbossche jorisvandenbossche added this to the No action milestone May 12, 2016
@jorisvandenbossche
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants