我想遍历列表g以使用
进行子绘图ax = sns.countplot(x='salary', hue="left", data=df)
g = ['salary', 'Gender ','Marrital Status', 'EducationLevel', 'Overtime',
'Stock Level', 'Experience ', 'Role', 'Business Travel']
g
是数据框中的类别列表,显示员工流失。我将属性left
作为标签,并想针对标签
g
中的类别
我的尝试:
g = ['salary', 'Gender ', 'Marrital Status', 'EducationLevel', 'Overtime', 'Stock Level', 'Experience ', 'Role', 'Business Travel']
for i in g:
ax = sns.countplot(x=i, hue="left", data=df)
答案 0 :(得分:0)
尝试
g = ['salary', 'Gender ', 'Marrital Status', 'EducationLevel', 'Overtime', 'Stock Level', 'Experience ', 'Role', 'Business Travel']
ax = [sns.countplot(x=i, hue="left", data=df) for i in g]