Python “TypeError: unhashable type: 'slice'” for encoding categorical data

后端 未结 7 894
长情又很酷
长情又很酷 2020-12-04 16:03

I am getting

TypeError: unhashable type: \'slice\'

when executing the below code for encoding categorical data in Python. Can a

相关标签:
7条回答
  • 2020-12-04 17:06

    if you use .Values while creating the matrix X and Y vectors it will fix the problem.

    y=dataset.iloc[:, 4].values
    
    X=dataset.iloc[:, 0:4].values
    

    when you use .Values it creates a Object representation of the created matrix will be returned with the axes removed. Check the below link for more information

    https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.values.html

    0 讨论(0)
提交回复
热议问题