This repository contains my complete coursework for the Statistics module of the TOPS program, built entirely using Python (primarily pandas, numpy, scipy.stats, matplotlib, and seaborn). It covers the full journey from the fundamentals of statistics (data types, central tendency, dispersion) through probability theory, sampling, and inferential statistics (hypothesis testing, t-tests, chi-square, ANOVA, correlation, and regression) — and ends with two applied case studies and one full-scale exploratory analysis of a real-world e-commerce dataset.
All notebooks were solved using Python instead of Excel/Google Sheets, even where the original questions were framed around spreadsheet tools like PivotTables or the CORREL function, to demonstrate the same analysis programmatically.
TOPS_Assignment_Statistics/
│
├── Session_1_Intro_To_Statistics.ipynb
├── Session_2_Types_Of_Data.ipynb
├── Session_3_Measures_Central_Tendency.ipynb
├── Session_4_measures_Of_Dispersion.ipynb
├── Session_5_Percentiles_Quartiles_BoxPlot.ipynb
├── Session_6_Probability_Basics.ipynb
├── Session_7_Conditional_Probability.ipynb
├── Session_8_Probability_Distribution_Discrete.ipynb
├── Session_9_Probability_Distribution_Continuous.ipynb
├── Session_10_Sampling_Techniques.ipynb
├── Session_11_Central_Limit_Theorem.ipynb
├── Session_12_Hypothesis_Testing.ipynb
├── Session_13_t_test.ipynb
├── Session_14_Chi_Square_Test.ipynb
├── Session_15_ANOVA.ipynb
├── Session_16_Correlation_Analysis.ipynb
├── Session_17_Simple_Linear_Regression.ipynb
│
├── Case_Study_1.ipynb
├── Case_Study_2.ipynb
├── purchase_data.csv
├── songs.csv
├── Telco_Customer_Churn.csv
│
└── Online Retail Full Analysis/
├── Online_Retail_Analysis.ipynb
└── Online_Retail_Customer_Insights_Report.pdf
Each Session_* notebook contains a set of practice questions (usually 4–5) framed around everyday, relatable scenarios — food-delivery apps like Zomato/Swiggy, e-commerce platforms like Flipkart, and streaming apps like Spotify — to make abstract statistical concepts concrete.
| # | Notebook | Topics Covered |
|---|---|---|
| 1 | Session_1_Intro_To_Statistics |
Population vs. sample, generating and summarizing sample data (mean, median, mode) using simulated Zomato order amounts |
| 2 | Session_2_Types_Of_Data |
Classifying data types (nominal, ordinal, discrete, continuous), real-life examples, working with a Spotify time-series dataset, auto-detecting measurement scales |
| 3 | Session_3_Measures_Central_Tendency |
Mean, median, and mode applied to step counts, delivery times, YouTube genres, and UPI transactions |
| 4 | Session_4_measures_Of_Dispersion |
Range, variance, standard deviation and other spread measures |
| 5 | Session_5_Percentiles_Quartiles_BoxPlot |
Percentiles, quartiles, IQR, and box-plot visualization for outlier detection |
| 6 | Session_6_Probability_Basics |
Sample spaces, classical probability, complement rule, addition rule — using dice/coin tosses, Spotify playlists, and Zomato orders |
| 7 | Session_7_Conditional_Probability |
Conditional probability, Bayes' Theorem — applied to e-commerce purchase behavior, churn prediction, and fraud detection scenarios |
| 8 | Session_8_Probability_Distribution_Discrete |
Bernoulli, Binomial, and Poisson distributions — modeling login success, UPI payment success rates, and playlist-creation rates |
| 9 | Session_9_Probability_Distribution_Continuous |
Normal distribution, Z-scores, and probability calculations for delivery times and fitness-app step counts |
| 10 | Session_10_Sampling_Techniques |
Simple random sampling, stratified sampling, systematic sampling, and the effect of sample size on estimate accuracy |
| 11 | Session_11_Central_Limit_Theorem |
Simulating the CLT with repeated sampling from skewed data, comparing sampling-distribution shapes for different sample sizes |
| 12 | Session_12_Hypothesis_Testing |
Null/alternative hypotheses, Type I/II errors, p-values, and confidence levels in an A/B-testing context |
| 13 | Session_13_t_test |
One-sample, independent two-sample, and paired t-tests using scipy.stats |
| 14 | Session_14_Chi_Square_Test |
Contingency tables, chi-square test of independence, and chi-square goodness-of-fit test |
| 15 | Session_15_ANOVA |
One-way ANOVA comparing purchase values across customer age groups (using purchase_data.csv), plus between-group/within-group variance |
| 16 | Session_16_Correlation_Analysis |
Pearson and Spearman correlation, correlation matrices, heatmaps (using songs.csv), and common pitfalls in interpreting correlation |
| 17 | Session_17_Simple_Linear_Regression |
Identifying dependent/independent variables, fitting a linear regression model with scikit-learn, interpreting slope, intercept, and R² |
An early, smaller-scale version of the retail analysis performed on a filtered/sampled subset of the online retail transactions data. It walks through:
- Filtering UK transactions and counting unique customers
- Building a country-wise sales pivot to find the top 3 countries by revenue
- Calculating average order value and flagging high-value invoices (> ₹10,000)
- Running an independent two-sample t-test to compare average order values between France and Germany (result: not statistically significant at α = 0.05)
An analysis of customer churn for a telecom provider:
- Counting churned vs. retained customers (1,869 "Yes" vs. 5,174 "No")
- Churn counts broken down by contract type
- Comparing average
MonthlyChargesfor churned vs. non-churned customers (churned customers pay noticeably more on average — ₹74.4 vs ₹61.3) - A bar chart comparing churn counts across
InternetServicetypes (DSL, Fiber optic, No internet) - Correlation between tenure and churn (converted to numeric), showing a moderate negative correlation — customers with longer tenure churn less
This is the flagship analysis of the assignment — a full end-to-end exploration of the Online Retail dataset (UK-based online retailer transactions from Dec 2010–Dec 2011), containing ~540K transaction rows. Because the raw CSV is too large (~45 MB) to include in this repository, it can be downloaded from Kaggle here:
Folder contents:
Online_Retail_Analysis.ipynb— the full notebookOnline_Retail_Customer_Insights_Report.pdf— a written summary report of the findings
Part A — Core assignment tasks:
- Data cleaning — removed cancelled orders (InvoiceNo starting with "C"), which reduced the dataset from 541,909 to 530,104 valid purchase rows
- UK customer count — identified 3,920 unique customers who purchased from the United Kingdom
- Sales by country — built a
Sales = Quantity × UnitPricecolumn and grouped by country; the top 3 countries by total sales are:- United Kingdom — ₹9,025,222.08
- Netherlands — ₹285,446.34
- Eire (Ireland) — ₹283,453.96
- Average order value — computed total sales per invoice (confirming each invoice maps to a single customer) and found the average order value ≈ ₹534.40, then flagged all invoices exceeding ₹10,000
- France vs. Germany t-test — ran an independent two-sample t-test (Welch's, unequal variance) comparing average order value between France and Germany:
- t-statistic ≈ 0.76, p-value ≈ 0.45
- Conclusion: the difference is not statistically significant at the 0.05 level
Part B — Additional customer purchasing-pattern analysis (self-driven, beyond the core questions):
- Monthly sales trend — revealed clear seasonality, with a strong spike heading into the holiday season (Sept–Nov 2011)
- Average items (quantity) per order — ≈ 280 units per order
- Top 10 best-selling products by revenue — e.g., "DOTCOM POSTAGE," "REGENCY CAKESTAND 3 TIER," "PAPER CRAFT, LITTLE BIRDIE"
- Repeat vs. one-time customers — out of 4,338 total customers, 65.6% were repeat customers (2+ orders) vs. 34.4% one-time buyers
- Day-of-week purchasing pattern — sales are highest on Thursdays and Tuesdays, and the store does not trade on Saturdays; Sunday sales are notably lower than weekday sales
- Top 10 customers by total spend — identifies the highest-value customers (e.g., top customer spent over ₹280,000 across 73 orders)
The accompanying PDF report (Online_Retail_Customer_Insights_Report.pdf) summarizes these findings in a business-facing write-up.
- pandas — data loading, cleaning, grouping/aggregation, pivot-style analysis
- numpy — numerical operations and random sampling/simulations
- scipy.stats — t-tests, chi-square tests, ANOVA, Poisson/Binomial/Normal distributions
- scikit-learn — simple linear regression
- matplotlib / seaborn — visualizations (histograms, box plots, bar charts, heatmaps, trend lines)
| Dataset | Used In | Notes |
|---|---|---|
| Online Retail transactions | Case Study 1 & Online Retail Full Analysis | Too large to host here — see Online Retail Data Set |
Telco_Customer_Churn.csv |
Case Study 2 | Included in repo |
purchase_data.csv |
Session 15 (ANOVA) | Included in repo |
songs.csv |
Session 16 (Correlation) | Included in repo |
Shivam Thakur
Aspiring Data Analyst | Python Learner | Exploring Data Analytics & AI
- 💼 LinkedIn: https://www.linkedin.com/in/shivam-thakur-55b167406/
- 📧 Email: dataanalyst.shivamthakur@gmail.com
This repository demonstrates a progression from foundational statistical concepts to applied, real-world data analysis: starting with descriptive statistics and probability, moving through inferential statistics and hypothesis testing, and culminating in a full exploratory data analysis project on a real e-commerce transactions dataset — complete with data cleaning, business-relevant KPIs, statistical significance testing, and a written insights report.
⭐ Thank you for visiting my repository! Feel free to explore