functions
def plot_hist(df, col):
fig = plt.figure()
ax=sns.displot(x=col, data=df)
plt.show()
plt.close(fig)
def plot_count(df, col):
fig = plt.figure()
ax=sns.countplot(x=col, data=df)
plt.show()
plt.close(fig)
def plot_column(df, col):
if (df[col].dtype =='float64') or (df[col].dtype =='int64'):
plot_hist(df, col)
elif (df[col].dtype =='O') :
plot_count(df, col)
else:
print (col+ ' not plotted')
and loop through each column:
for i in df.columns:
plot_column(df, i)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…