Data Science · मराठी आवृत्ती
21.2 Mean, median आणि mode — ₹ orders सोबत
या course चे सर्व chapters (py + ch)
- How to Use This Free Data Science Course
- How to Install Python, Jupyter Notebook and VS Code for Data Science (Windows and Mac)
- Python Variables and Data Types Explained for Beginners (int, float, str, bool)
- Python Strings Tutorial: Slicing, f-strings and String Methods with Examples
- Python Lists, Tuples, Dictionaries and Sets Explained with Examples
- Python if, elif and else Statements with Real Examples for Beginners
- Python for Loops and while Loops Explained with Examples (range, break, continue)
- Python Functions Tutorial: def, return, Arguments and lambda with Examples
- Python Errors and Exceptions: How to Use try, except, else and finally
- How to Read and Write CSV, JSON and Text Files in Python (with open and with)
- Python Modules, pip and Virtual Environments (venv) Explained for Beginners
- Python Classes and Objects for Beginners: OOP Basics with Simple Examples
- NumPy Tutorial for Beginners: Arrays, Maths and Filtering in Python
- Python Mini Projects for Beginners: 5 Practice Projects Before Learning pandas
- Data Science vs Data Analytics Tutorial
- Python Jupyter Setup for Data Science
- Python Basics for Data Science Tutorial
- NumPy Essentials for Data Science Tutorial
- pandas DataFrames and Series Tutorial
- Filter and Sort Data in pandas Tutorial
- pandas GroupBy and Aggregations Tutorial
- Merge and Concat Data in pandas Tutorial
- Data Cleaning in pandas A–Z Tutorial
- Dates and Text in pandas – Free Tutorial
- Reshape Data: melt and pivot_table
- Exploratory Data Analysis in Python
- matplotlib Visualization Tutorial – Free
- seaborn Visualization Tutorial – Free
- Chart Choice and Data Storytelling
- Data Science Project: Blinkit Maharashtra
- Data Science Practice Exercises
- Data Science Interview Questions
- pandas matplotlib seaborn Cheat Sheet
- Data Science Glossary – Free Tutorial
- Stats for Data Work Mean Median IQR
- Export CSV Excel PNG from pandas Tutorial
- Common pandas Mistakes and Fixes Tutorial
- Load SQL Query Results into pandas DataFrame – Free Tutorial
- How to Rank and Running Totals in pandas
- How to Read APIs, JSON and Zipped CSVs into pandas
- How to Use Git with Jupyter Notebooks for Data Projects
- How to Merge and Join Tables in pandas for Blinkit Data
- What Is Machine Learning Simple Explanation
- Machine Learning Workflow Step by Step
- Train Test Split in Machine Learning sklearn
- Features and Labels in Machine Learning
- Linear Regression in Python with sklearn
- Classification with Logistic Regression in Python
- Decision Trees and Random Forests in Python
- K-Means Clustering in Python for Beginners
- How to Check If Your ML Model Is Good
- Overfitting and Underfitting in Machine Learning
- End-to-End ML Project India Dataset
- Data Preprocessing for ML: Impute Scale Encode
- What Is a Neural Network Simple Explanation
- Activation Loss Gradient Descent Plain English
- Backpropagation Intuition No Heavy Maths
- Install PyTorch and First Tensors
- Your First Neural Network in PyTorch
- Deep Learning vs Classical ML When to Use Which
- Convolutional Neural Networks CNNs for Images
- Small CNN Image Project in PyTorch
- What Transformers Are Text and Sequences
- Tiny Text Classifier Transformer Intro PyTorch
- What Is Natural Language Processing NLP
- Text Cleaning and TF-IDF in Python sklearn
- Sentiment Analysis Project in Python TF-IDF
- NLP vs ChatGPT Classical NLP and Generative AI
हे का शिकायचं?
Average एकच कल्पना नाही. Mean टोकांकडे ओढलं जातं. Median मध्ये बसतं. Mode सर्वात common value आहे.
हे काय आहे?
Mean = जोडून count ने भागा. Median = sort केल्यावर मधली value. Mode = सर्वाधिक वारंवार value.
कसं करायचं?
Step 1. amount column घ्या.
Step 2. mean() चालवा.
Step 3. median() चालवा.
Step 4. mode() पाहा.
Step 5. Category साठी value_counts().idxmax() वापरा.
Step 6. Stat शेजारी count print करा.
उदाहरणं: copy करा आणि चालवा
| Stat | Plain English | Good for |
|---|---|---|
| Mean | Add all ₹, divide by count | Stable, no huge outliers |
| Median | Middle value after sorting | Skewed ₹ baskets, salaries |
| Mode | Most frequent value | City name, payment method |
उदाहरण A — Six Maharashtra cities (fictional delivered orders).
import pandas as pd
orders = pd.DataFrame({
"order_id": [
"BLK-261020-001", "BLK-261020-002", "BLK-261020-003",
"BLK-261020-004", "AMN-261020-005", "BLK-261020-006",
"BLK-261020-007", "AMN-261020-008", "BLK-261020-009",
"BLK-261020-010", "BLK-261020-011", "AMN-261020-012",
],
"city": [
"Pune", "Pune", "Solapur", "Nashik", "Kolhapur", "Nagpur",
"Pune", "Sambhaji Nagar", "Nashik", "Pune", "Solapur", "Nagpur",
],
"customer": [
"Ruhi Bagale", "Amir", "Zoya", "Salman", "Ravina", "Raja",
"Shraddha Bagale", "Rani", "Shahrukh", "Ravindra Bagale", "Amir", "Zoya",
],
"amount": [64, 189, 120, 95, 210, 150, 72, 340, 88, 1250, 110, 160],
"status": ["Delivered"] * 12,
})
print("mean ", round(orders["amount"].mean(), 1))
print("median", orders["amount"].median())
print("mode ₹", orders["amount"].mode().tolist())
print("mode city", orders["city"].mode().tolist())
print(orders.groupby("city")["amount"].agg(["count", "mean", "median"]).round(1))
What you should see. Overall mean is pulled up by Ravindra Bagale’s ₹1,250 festival hamper in Pune. Median stays near everyday kirana baskets. Mode for city is Pune (most rows). Mode for ₹ may be empty or weak — amounts rarely repeat exactly.
उदाहरण B — Same city, two stories.
pune = orders.loc[orders["city"] == "Pune", "amount"]
print("Pune mean", round(pune.mean(), 1), "median", pune.median())
print("Pune without max", round(pune[pune < pune.max()].mean(), 1))
When you drop the single ₹1,250 row, Pune’s mean falls hard; median barely moves. That is your teaching slide for “why median for ₹”.
उदाहरण C — Mode for ops, not for ₹.
print(orders["city"].value_counts())
# Payment-method style category (fictional)
pay = pd.Series(["UPI", "UPI", "Cash", "UPI", "Card", "UPI", "Cash"])
print("most common pay", pay.mode().iloc[0])
Raja in Nagpur asks “which pay method should the dark store promote?” Mode answers. Mean of UPI strings does not exist — right tool for the question.