I have a DataFrame df
of multiple columns and I would like to create a boxplot
for each column using matplotlib
.
df.info()
output of my DataFrame below for reference
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 9568 entries, 0 to 9567
Data columns (total 5 columns):
Ambient Tempreature 9568 non-null float64
Exhaust Vacuum 9568 non-null float64
Ambient Pressure 9568 non-null float64
Relative Humidity 9568 non-null float64
PE 9568 non-null float64
dtypes: float64(5)
memory usage: 373.8 KB
If you want to create a separate plot per column, then you can iterate over each column and use plt.figure()
to initiate a new figure for each plot.
import matplotlib.pyplot as plt
for column in df:
plt.figure()
df.boxplot([column])
If you want to just put all columns into the same boxplot graph then you can just use df.plot(kind='box')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With