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
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')