PD Course 1, Week 1, Exercise 4 - Barplot

Hi There,

Please help me understand what I’m doing wrong.

Thanks!
Jennifer

Here’s my input:

Create seaborn barplot

barplot = sns.barplot(
### BEGIN SOLUTION - DO NOT delete this comment for grading purposes
data=df_count_by_category_desc, # Replace None
y=‘product_category’, # Replace None
x=‘count_reviews’, # Replace None
### END SOLUTION - DO NOT delete this comment for grading purposes
color=“b”,
saturation=1
)

Set the size of the figure

sns.set(rc={‘figure.figsize’:(15.0, 10.0)})

Set title

plt.title(“Number of reviews per product category”)
plt.xlabel(“Number of reviews”)
plt.ylabel(“Product category”)

plt.tight_layout()

Do not change the figure name - it is used for grading purposes!

plt.savefig(‘num_reviews_per_category.png’, dpi=300)

Show the barplot

plt.show(barplot)

Here’s the error message:

NameError Traceback (most recent call last)
in
1 # Create seaborn barplot
----> 2 barplot = sns.barplot(
3 ### BEGIN SOLUTION - DO NOT delete this comment for grading purposes
4 data=df_count_by_category_desc, # Replace None
5 y=‘product_category’, # Replace None

NameError: name ‘sns’ is not defined

Hi @corderojm!

Thanks for your question. Have you tried to import seaborn library again? :slight_smile: (import seaborn as sns)

It is in the first cell of section 3.1. Preparation for data visualization > Imports

Let us know if it works out.

Thanks very much for your help, Raul! I tried your suggestion, but it did not work. I decided to start the assignment from scratch again, and I didn’t encounter that error message this time. Who knows why it didn’t work yesterday! In any event, thanks again!

1 Like