Data Science · मराठी आवृत्ती
25.2 rank — peers मधलं स्थान
या 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
हे का शिकायचं?
मोठा GMV म्हणजे rank 1 (ascending=False). Ties कसे मोडायचे ते ठरवा.
हे काय आहे?
Series.rank(ascending=False, method="dense").
कसं करायचं?
Step 1. Metric column.
Step 2. rank काढा.
Step 3. Tie method निवडा.
Step 4. Top 5 पाहा.
उदाहरणं: copy करा आणि चालवा
| method | Tie behaviour (high amounts first) |
|---|---|
average (default) |
Both get 1.5 if they share #1 |
min |
Both get 1; next gets 3 |
dense |
Both get 1; next gets 2 (no gap) |
first |
Order of appearance breaks the tie |
उदाहरण A — Dense rank on baskets.
import pandas as pd
df = pd.DataFrame({
"order_id": ["BLK-1", "BLK-2", "BLK-3", "AMN-4", "BLK-5"],
"city": ["Pune", "Pune", "Nashik", "Kolhapur", "Pune"],
"amount_inr": [210, 210, 95, 180, 150],
"customer": ["Ruhi Bagale", "Amir", "Zoya", "Ravina", "Salman"],
})
df["rank_dense"] = df["amount_inr"].rank(ascending=False, method="dense")
df["rank_min"] = df["amount_inr"].rank(ascending=False, method="min")
df["rank_avg"] = df["amount_inr"].rank(ascending=False, method="average")
print(df.sort_values("rank_dense")[
["order_id", "amount_inr", "rank_dense", "rank_min", "rank_avg"]
])
What you should see. Both ₹210 rows share dense rank 1; next amount gets 2. min leaves a gap (next is 3). average shows 1.5.
उदाहरण B — Rank low delivery minutes (faster is better).
df = pd.DataFrame({
"order_id": ["BLK-10", "BLK-11", "AMN-12"],
"city": ["Solapur", "Nagpur", "Pune"],
"delivery_mins": [11, 18, 11],
})
df["fast_rank"] = df["delivery_mins"].rank(ascending=True, method="dense")
print(df.sort_values("fast_rank"))
उदाहरण C — Interview one-liner.
“I use rank(ascending=False, method='dense') on GMV so ties share a place and the next city is still #2.”