Stack Exchange
How to plot seaborn barplots as subplot?
I want to create subplot for a list of columns from a data frame. However, when I run the code below, I am getting indexing error associated with axes

TypeError: 'AxesSubplot' object does not support indexing

%matplotlib inline
import seaborn as sns
import matplotlib.pyplot as plt
nr_rows = 1
nr_cols = 3

cols_review = ['home_ownership', 'verification_status', 'loan_status']
li_col_reviews = list(cols_review)

fig, axs = plt.subplots(nr_rows, nr_cols, figsize=(nr_cols*4,nr_rows*3))

for r in range(0,nr_rows):
    for c in range(0, nr_cols):  
        col = r*nr_cols+c
        if col < len(li_col_reviews):
            col_count = pdf[li_col_reviews[col]].value_counts()
            sns.set(style="darkgrid")
            sns.barplot(col_count.index, col_count.values, alpha=0.9,ax = axs[r][c])
            plt.ylabel('Number of Occurrences', fontsize=12)
            plt.xlabel(col, fontsize=12)
            plt.tight_layout()    
            plt.show() 


You will need to add squeeze=Falseto the line plt.subplots
Here I have modified your code and used some dummy data. Also you must keep plt.show() outside the loop.
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

nr_rows = 1
nr_cols = 3

cols_review = ['home_ownership', 'verification_status', 'loan_status']

fig, axs = plt.subplots(nr_rows, nr_cols, figsize=(nr_cols*4,nr_rows*3), squeeze=False)

for r in range(0,nr_rows):
    for c in range(0, nr_cols):  
        col = r*nr_cols+c
        if col < len(cols_review):
            x=np.random.rand(5) * 10
            y=np.random.rand(5)
            sns.set(style="darkgrid")
            sns.barplot(x, y, alpha=0.9,ax = axs[r][c])
            plt.ylabel('Number of Occurrences', fontsize=12)
            plt.xlabel(col, fontsize=12)
plt.tight_layout()    
plt.show()

Squeeze is set as True by default, which means that:
 extra dimensions are squeezed out from the returned array axs. And hence cannot be indexed with [r][c]. By not squeezing (squeeze=False) you ensure that axs is returned as a 2D array which can then be indexed using [r][c]
You might want to read on the squeeze argument here.

side note: li_col_reviews = list(cols_review) is useless as cols_review is already a list
