I am trying to do a catplot using seaborn library for all the categorical variables in my dataframe but I ma getting error for ambiguous truth value. It generally happens with "&" value but I am unable to get the root cause here. My target is continuous variable.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
target = df[target_col]
features = df[df.columns.difference([target_col])]
cat_cols = features.select_dtypes(include=['object']).columns.to_list()
fig, axes = plt.subplots(round(len(cat_cols) / 3), 3, figsize=(15, 15))
for i, ax in enumerate(fig.axes):
if i < len(cat_cols):
sns.catplot(x=cat_cols[i], y=target, kind='bar',data=df, ax = ax)
But I am getting the below error. Which part is causing this value error?
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().