简体   繁体   中英

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. There are like 19 numerical columns. 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. 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:

在此处输入图像描述

I'm trying to find outliers for my numerical columns in a dataframe. I need to display boxplots for those columns using subplots. There are like 19 numerical columns. 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. 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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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