LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Working with Categorical Data in Python

Kurs anzeigen

Anleitung zur Übung

  • 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.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# 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 bearbeiten und ausführen