简体   繁体   English

使用 seaborn 绘制多个数值列的箱线图

[英]Plotting boxplot for multiple numerical columns using seaborn

I'm trying to find outliers for my numerical columns in a dataframe. I need to display boxplots for those columns using subplots.我正在尝试为 dataframe 中的数字列查找异常值。我需要使用子图显示这些列的箱线图。 There are like 19 numerical columns.大约有 19 个数字列。 I cant spend time writing down boxplot code for each of the numerical variable using subplot of matplotlib. I need to use some sort of for loop so that python displays boxplot for each column by subplotting them.我不能花时间使用 matplotlib 的子图为每个数值变量写下箱线图代码。我需要使用某种 for 循环,以便 python 通过子图显示每一列的箱线图。 I dont want to keep writing this below code我不想继续写下面的代码

plt.subplot()
sns.boxplot(data=df['<column name>']) for every column.

It would be very cumbersome.会很麻烦。

I need the boxplots displayed in rows and columns.我需要以行和列显示的箱线图。 Any idea?任何的想法?

Is it:是吗:

sns.catplot(y='value', col='variable', col_wrap=5,
            data=df.melt(), kind='box')

Output: Output:

在此处输入图像描述

I'm trying to find outliers for my numerical columns in a dataframe.我正在尝试在 dataframe 中查找我的数值列的异常值。 I need to display boxplots for those columns using subplots.我需要使用子图显示这些列的箱线图。 There are like 19 numerical columns.大约有 19 个数字列。 I cant spend time writing down boxplot code for each of the numerical variable using subplot of matplotlib.我不能花时间使用 matplotlib 的子图为每个数值变量写下箱线图代码。 I need to use some sort of for loop so that python displays boxplot for each column by subplotting them.我需要使用某种 for 循环,以便 python 通过子图显示每列的箱线图。 I dont want to keep writing this below code我不想继续写下面的代码

plt.subplot()
sns.boxplot(data=df['<column name>']) for every column.

It would be very cumbersome.这会很麻烦。

I need the boxplots displayed in rows and columns.我需要以行和列显示的箱线图。 Any idea?任何想法?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM