dataFrame 类别属性转成数值属性

    major_unique = data['major'].unique()
    major_unique_list = major_unique.tolist()
    major_unique_list.sort()
    major_mapping = {}
    index = 0
    for major in major_unique_list:
        major_mapping[major] = index
        index = index + 1
    data['major'] = data['major'].map(major_mapping)

你可能感兴趣的:(程序调试)