私信  •  关注

Nico Coallier

Nico Coallier 最近创建的主题
Nico Coallier 最近回复了
6 年前
回复了 Nico Coallier 创建的主题 » 如何在pandas python中为字符串创建汇总列[duplicate]

如果要在数据数据帧中重新映射多个列,则添加此问题:

def remap(data,dict_labels):
    """
    This function take in a dictionnary of labels : dict_labels 
    and replace the values (previously labelencode) into the string.

    ex: dict_labels = {{'col1':{1:'A',2:'B'}}

    """
    for field,values in dict_labels.items():
        print("I am remapping %s"%field)
        data.replace({field:values},inplace=True)
    print("DONE")

    return data

希望它对某人有用。

干杯