I have a DataFrame with 7 columns of categorical information that I would like to loop through for each columns unique labels and count of rows per label, that would then be added as a bar chart subplot to my figure. I am able to create a figure with the correct amount of subplots for the figure and also the individual DataFrames with column name and counts, but I'm not sure how I can return a new subplot to the figure from each cycle in the loop. Any help of the proper process? Provided is my attempt below and error message at the loop:
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
Libraries
# Import Libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
%matplotlib inline
Categorical DataFrame (df_cat)
df_cat = example data from .head() method

Figure and amount of subplots
plt_nrows = round(len(df_cat.columns) / 2)
plt_ncols = len(df_cat.columns) - sub_plt_rows
fig, axs = plt.subplots(plt_nrows, plt_ncols, figsize=(20,15))
Loop of DataFrames with individual columns and label counts:
for i in df_cat.columns:
df_cat_counts = df_cat[i].value_counts().rename_axis([i]).reset_index(name='counts')
x = df_cat_counts[i]
y = df_cat_counts['counts']
axs[i,0].plot(x, y)
