BaşlayınÜcretsiz Başlayın

Distribution of inflation rates in China, India, and the US

As you saw in the video, the boxplot() function displays key quantiles of a distribution with respect to categories, where y represents a quantitative variable, and x a categorical variable. In statistics, this kind of distribution is known as a box-and-whisker plot.

A complement to a box plot is a swarmplot(), which draws a categorical scatterplot that displays all categorical observations without overlapping; it takes similar arguments to boxplot():

seaborn.boxplot(x=None, y=None, data=None, ...)
seaborn.swarmplot(x=None, y=None, data=None, ...)

In this final exercise, you will compare the historical distributions of inflation rates by country - specifically China, India, and the US - instead of by time series trends. pandas as pd, matplotlib.pyplot as plt, and seaborn as sns have been imported for you. The FRED inflation data is in your workspace as inflation.

Bu egzersiz

Importing and Managing Financial Data in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Create and show a boxplot of the inflation data with 'Country' for x and 'Inflation' for y.
  • Create and show sns.swarmplot() with the same arguments.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Create boxplot
sns.____(x=____, y=____, data=____)

# Show the plot
plt.show()

# Close the plot
plt.close()

# Create swarmplot
sns.swarmplot(x=____, y=____, data=____)

# Show the plot
plt.show()
Kodu Düzenle ve Çalıştır