📜  标签编码列 pandas - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:21.958000             🧑  作者: Mango

代码示例2
import seaborn as sns 
df = sns.load_dataset('iris')
def encode(x):
    for i,j in enumerate(df['species'].unique()):
        if x == j:
            return i

df['species'] = df['species'].apply(lambda x:encode(x))