{}const=>[]async()letfn</>var
Development

Data Science in a nutshell: learn to analyze data using simple examples

Let's analyze Data Science using simple and illustrative examples — how to calculate the average check, look for bottlenecks in the funnel and test hypotheses without complex formulas. Everything is human, with logic, not the magic of statistics.

К

Kodik

Author

3 min read

Why Data Science at all?

Data Science is not "AI magic", but rather careful questions to data:

  • What's going on? — descriptive analytics

  • Why is this happening? - diagnostic

  • What will happen next? - forecast

  • What should I do? - recommendations

Basic cycle: collect → clear → look (EDA) → test the hypothesis → model → explain the result and make a decision.

Rule #1: The result must lead to action. A number for the sake of a number is garbage.

🔥 100,000+ students already with us

Tired of reading theory?
Time to code!

Kodik — an app where you learn to code through practice. AI mentor, interactive lessons, real projects.

🤖 AI 24/7
🎓 Certificates
💰 Free
🚀 Start learning
Joined today

Mini-cheat sheet: what to count and how to measure

Question

What we consider

Tool

Metric type

What it means

How much do customers spend?

Average check (mean), median

Pandas/SQL

Descriptive

Basic revenue benchmark

How "live" is the demand?

Conversion, frequency of purchases

Cohorts

Descriptive/diagnostic

Understanding the funnel

Does the banner work?

Δ conversions, t-test/bootstrapping

SciPy/bootstrapping

Inf. statistics

Probability that the effect is not an accident

What influences the response?

Correlations/feature importance

corr(), simple regression

Diagnostic

What factors are really significant

How much will we sell tomorrow?

Forecast (linear/trees)

scikit-learn

Forecast

Optimize purchases/advertising

Example 1. Coffee shop and average check

Scenario: the owner wants to understand why the revenue is "jumping".

Data: table orders (id, date, amount, payment method).

What we do:

  1. We calculate average check and median.

  2. We are building distribution of receipts.

  3. We are looking day of the week — where are the peak days?

df['weekday'] = df['date'].dt.day_name()
avg_check = df['amount'].mean()
median_check = df['amount'].median()
by_weekday = df.groupby('weekday')['amount'].mean().sort_values(ascending=False)

Conclusions: if the average check >> the median, you have a long "tail" of expensive orders. Peaks on Fridays? So, it's better to launch the promo on Thursday night.

Example 2. Conversion from viewing to purchase

Scenario: online store: lots of views, few purchases.

Data: events view_product and purchase with user_id.

views = events.query('event=="view_product"').user_id.nunique()
carts = events.query('event=="add_to_cart"').user_id.nunique()
buys  = events.query('event=="purchase"').user_id.nunique()
conv_view_to_cart = carts / views
conv_cart_to_buy  = buys / carts

Conclusion: if the drawdown is at the "basket → purchase" stage, check the UX, form errors or shipping cost.

Example 3. Quick A/B test of a banner

from statsmodels.stats.proportion import proportions_ztest
count = np.array([buys_B, buys_A])
nobs  = np.array([visits_B, visits_A])
stat, p = proportions_ztest(count, nobs)

Conclusion: even with a +0.8 p.p. difference, the confidence interval and the cost of traffic should be taken into account.

Example 4. Sales forecast "for tomorrow"

X = pd.get_dummies(df[['day_index','weekday']], drop_first=True)
y = df['sales']
model.fit(X_train, y_train)
pred = model.predict(X_test)
mae = np.mean(np.abs(pred - y_test))

Conclusion: forecast is needed to reduce uncertainty, not for "accurate guessing".

Example 5. What really affects the response?

Scenario: email newsletter. Why do some people open emails and others don't?

Idea: check correlations and logistic regression to assess the impact of features.

Data cleaning is half the battle

Problem

How to notice

What to do

Passes

df.isna().mean()

Delete or replace with median

Emissions

Boxplot, z-score

Restrict by business rules

Duplicates

df.duplicated().sum()

Clear keys

Different date formats

Parsing errors

Use to_datetime

Incomplete categories

Share < 1%

Merge into "Other"

In Codice We provide short modules on Python and analytics with "real-life" tasks — CSV loading, cleaning, funnels, mini A/B test and the first model. No water and with clear results.

And we also have an active Telegram channel, where we discuss cool ideas, share experiences and analyze tasks together — learning becomes not only useful, but also fun.

🎯Stop procrastinating

Liked the article?
Time to practice!

In Kodik, you don't just read — you write code immediately. Theory + practice = real skills.

Instant practice
🧠AI explains code
🏆Certificate

No registration • No card