Aan de slagGa gratis aan de slag

Creating a point plot

Creating helpful visualizations sometimes requires a lot of testing. You have been asked to create a visualization that shows the number of reviews, "Nr. reviews", which is the number of reviews a reviewer has previously written, across a hotel's star rating, "Hotel stars". Since the number of reviews is numerical, you have decided to use a point plot to show the mean of the data across the categories.

Deze oefening maakt deel uit van de cursus

Working with Categorical Data in Python

Cursus bekijken

Oefeninstructies

  • Using the catplot() function, create a point plot.
  • Split the data across the x-axis using "Hotel stars".
  • Specify the numerical variable to visualize to "Nr. reviews".
  • Update the arguments so that any lines that appear do not overlap.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Create a point plot with catplot using "Hotel stars" and "Nr. reviews"
sns.catplot(
  # Split the data across Hotel stars and summarize Nr. reviews
  ____,
  ____,
  data=reviews,
  # Specify a point plot
  ____,
  hue="Pool",
  # Make sure the lines and points don't overlap
  ____
)
plt.show()
Code bewerken en uitvoeren