Data Analyst Interview
Menu
Browse in your language. All mock interviews, preparation sessions and feedback are in English only.
Python · Learning guide

Seaborn: compare distributions without overstating them

Use statistical plots to explore a question, then inspect sample sizes and plotting assumptions before interpreting a pattern.

Start the worked examples ↓

Show the observations alongside a boxplot

This standalone Python example uses eight fictional amounts. Install pandas, Seaborn and Matplotlib in your chosen environment before running it.

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
orders = pd.DataFrame({
    'group': ['A'] * 4 + ['B'] * 4,
    'amount_usd': [20, 30, 40, 50, 25, 35, 45, 95]
})
fig, ax = plt.subplots(figsize=(6, 4), layout='constrained')
sns.boxplot(data=orders, x='group', y='amount_usd',
            color='#DCF94E', ax=ax)
sns.stripplot(data=orders, x='group', y='amount_usd',
              color='#0C1122', jitter=False, ax=ax)
ax.set(title='Order amounts: eight fictional observations',
       xlabel='Group', ylabel='Amount (USD)')
plt.show()

Expected: four observations in each group. A ranges from $20 to $50; B from $25 to $95. The group medians are $35 and $40. A small visual difference does not establish a reliable treatment effect.

Know what the box means

The box spans the middle half of observations and marks the median. Default whiskers extend to observed points within 1.5 interquartile ranges of the quartiles; points beyond are shown separately. They are not automatically errors, and the whiskers are not generally the minimum and maximum.

A violin plot adds a smoothed density estimate. Its shape depends on the bandwidth and available data; with few observations, show the points rather than presenting a smooth shape as precise evidence.

Check defaults before interpreting a plot

  • lineplot can aggregate repeated x values and display uncertainty. Decide whether you want raw trajectories or an estimated summary.
  • hue can encode a category or a numeric variable. Choose a readable mapping and describe it.
  • A correlation heatmap summarises the chosen correlation measure, not causality. Missing-value patterns and outliers can affect it.
  • A pairplot becomes crowded as the number of variables grows. Select relevant features or use a sample with its limitations stated.

Practical chart checks

Count observations per group, inspect missing values and label the units. Use a consistent category order. Avoid interpreting a colour or a smoothed curve without checking what the plotting function calculated.

Should I delete the $95 point?

Not from the chart alone. Check whether it is valid, whether it belongs in the population and how results change with an explicitly justified sensitivity analysis.

What would I need for an A/B-test conclusion?

A defined outcome, randomisation or another defensible design, appropriate uncertainty estimates and checks on the assignment and analysis. A boxplot by itself does not establish an effect.

Continue learning

Reference: Seaborn boxplot · Seaborn lineplot. Check behaviour for your installed version.

These are educational exercises with fictional data, not a verified employer question bank. Amounts in examples are USD unless otherwise stated.

Practise your explanation

Use the self-practice guide to review your approach. Mock-interview booking and payment are currently inactive. All planned preparation sessions and feedback are in English.

View preparation options
✉ WhatsApp