I am trying to get all the numerical columns plotted within a tight layout with a mean line in each of the subplots for the average of each column. I have tried several options and get the following error:
the truth value of a series is ambiguous. use a.empty, a.bool(), a.item(), a.any() or a.all()
FYI: the code works without the plt.axvline
This is the code I have tried:
from scipy.stats import norm
all_col = data.select_dtypes(include=np.number).columns.tolist()
plt.figure(figsize=(17,75))
for i in range(len(all_col)):
plt.subplot(18,3,i+1)
sns.distplot(data[all_col[i]])
plt.tight_layout()
plt.title(all_col[i],fontsize=25)
plt.axvline(data.mean(), color='k', linestyle='dashed', linewidth=1)#displaying the mean on the chart
plt.show()