label_encoder = LabelEncoder()
for column in df.columns:
if df[column].dtype == 'object':
df[column] = label_encoder.fit_transform(df[column])
# 打印转换后的数据
print("Label Encoded Data:")
print(df)
label_encoder = LabelEncoder()
for column in df.columns:
if df[column].dtype == 'object':
df[column] = label_encoder.fit_transform(df[column])
# 打印转换后的数据
print("Label Encoded Data:")
print(df)