I'm trying to plot a graph for only rows with an if condition. And to the best of my knowledge, this is what I've done.
b = pd.read_csv('Zlatan_ClubComp.csv')
print(b.head())
if (b['Competition_Type'] == 'League'):
pp = sns.pairplot(b, y_vars=['Appearances'], x_vars=['Goals_PerGame', 'Minutes_PerGoal'], hue="Club")
plt.show()
Zlatan_ClubComp is the csv file from which I get my data. I've run the code and this is the error I get,
Traceback (most recent call last):
File "C:/Users/Siddhardh/Desktop/Python/Projects/Zlatan_Analysis/PairPlots.py", line 13, in <module>
if (b['Competition_Type'] == "League"):
File "C:\Users\Siddhardh\Desktop\OiDS Project\Zlatan_Analysis\lib\site-packages\pandas\core\generic.py", line 1555, in __nonzero__
self.__class__.__name__
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
From the Googling I've done, I know that pandas take truth values of conditional statements as ambiguous. But, I can't seem to fix this.