Python practice: Statistical Charts with Seaborn

Chapter 30 · 8 questions · included in full access

  1. Question 1 · easy

    Why Seaborn for statistical analytics?

    Why do data scientists and analysts frequently use Seaborn alongside Matplotlib?

    Solve it in your browser
  2. Question 2 · easy

    Statistical bar plot with sum estimator

    Load "sales.csv". Create a Seaborn bar plot summing Revenue by Region: fig, ax = plt.subplots(), sns.barplot(data=sales, x="Region", y="Revenue", estimator="sum", errorbar=None, ax=ax). Print the number of bars rendered (len(ax.patches)):

    Solve it in your browser
  3. Question 3 · medium

    Segment metrics with the hue parameter

    Load "sales.csv". Create a segmented bar plot with fig, ax = plt.subplots() and sns.barplot(data=sales, x="Region", y="Revenue", hue="Category", estimator="sum", errorbar=None, ax=ax). Print the count of rendered bar patches (len(ax.patches)):

    Solve it in your browser
  4. Question 4 · medium

    Detect distribution spread with boxplots

    Load "sales.csv". Create a boxplot of Revenue across Category using fig, ax = plt.subplots() and sns.boxplot(data=sales, x="Category", y="Revenue", ax=ax). Print the number of boxplot artists generated (len(ax.lines)):

    Solve it in your browser
  5. Question 5 · medium

    Bivariate relationship with scatterplot

    Load "sales.csv". Plot Units vs Revenue segmented by Category: fig, ax = plt.subplots(), sns.scatterplot(data=sales, x="Units", y="Revenue", hue="Category", ax=ax). Print len(ax.collections):

    Solve it in your browser
  6. Question 6 · medium

    Feature correlation matrix heatmap

    Load "sales.csv". Compute correlation corr = sales[["Units", "Price", "Revenue"]].corr(). Plot with fig, ax = plt.subplots() and sns.heatmap(corr, annot=True, ax=ax). Print the correlation between Units and Revenue rounded to 2 decimals (round(corr.loc["Units", "Revenue"], 2)):

    Solve it in your browser
  7. Question 7 · easy

    Apply executive business theme and palette

    Set Seaborn's global theme to "whitegrid" using sns.set_theme(style="whitegrid"). Create a simple bar plot of ["A", "B"] and [1, 2]. Print the grid status of the axes (ax.xaxis.get_gridlines()[0].get_visible()):

    Solve it in your browser
  8. Question 8 · hard

    Executive dashboard distribution comparison

    Load "sales.csv". Create a figure with fig, ax = plt.subplots(). Plot a horizontal boxplot with sns.boxplot(data=sales, x="Revenue", y="Region", ax=ax). Set title "Regional Revenue Spread". Print ax.get_title():

    Solve it in your browser

These questions are part of full access.

The first chapters of every track are free. Full access is a one-time payment.

See pricing