How to plot the boxplot of the columns in one loop?

Solution 1:

You can directly plot the data frame instead of going through the loop

Example code:

import numpy as np; 
import pandas as pd
import matplotlib.pyplot as plt
data = np.random.random(size=(4,4))
df = pd.DataFrame(data, columns = ['A','B','C','D'])

df.boxplot()
plt.show()

Output:

enter image description here