user14946125
user14946125

Reputation:

Seaborn: Plot a Barplot showing the Mean of an Attribute on the Y Axis?

I am new to Seaborn, and I am trying to plot a barplot that shows the average (mean) of an attribute on the Y axis, but I am unsure what is going wrong with my code.

This is my code:

fig, ax = plt.subplots(figsize=(15,10))
sns.barplot(data=df, x='Day', y=df['Spending'].mean())
ax.set(xlabel="Day of the Week", ylabel = "Average Spending each Day")

When I try to execute my code, I just get this error:

AttributeError: 'bool' object has no attribute 'all'

Any help on how to get the average to show on my Y axis would be greatly appreciated, including what I am doing wrong.

Thank you!

Upvotes: 0

Views: 1023

Answers (1)

Quang Hoang
Quang Hoang

Reputation: 150805

By default,

sns.barplot(data=df, x='Day', y='Spending')

shows the mean of Spending on the y axis.

Upvotes: 1

Related Questions