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

后端 未结 7 899
长情又很酷
长情又很酷 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 16:41

    use Values either while creating variable X or while encoding as mentioned above

    # Importing the libraries
    import numpy as np
    import matplotlib.pyplot as plt
    import pandas as pd
    
    # Importing the dataset
    # dataset = pd.read_csv('50_Startups.csv')
    
    dataset = pd.DataFrame(np.random.rand(10, 10))
    y=dataset.iloc[:, 4].values
    X=dataset.iloc[:, 0:4].values
    

提交回复
热议问题