Any way to get mappings of a label encoder in Python pandas?

前端 未结 8 1667
清酒与你
清酒与你 2021-02-01 15:11

I am converting strings to categorical values in my dataset using the following piece of code.

data[\'weekday\'] = pd.Categorical.from_array(data.weekday).labels         


        
8条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-01 15:38

    train['cat'] = train['cat'].map(list(train['cat'].value_counts().to_frame().reset_index().reset_index().set_index('index').to_dict().values())[0])
    

提交回复
热议问题