Ravindra Bagale · Data Scienceसर्व coursesया course चे lessonsशोधाEnglish

Data Science · मराठी आवृत्ती

25.1 Rank आणि running totals का

By Ravindra Bagale

या course चे सर्व chapters (py + ch)

हे का शिकायचं?

Leaderboard आणि cumulative progress व्यवसायात रोज लागतात. Chart आधी rank/cumsum काढा.

हे काय आहे?

rank = क्रम. cumsum = चालू जोड. GroupBy सोबत city/store निहाय.

कसं करायचं?

Step 1. एक metric निवडा.

Step 2. Sort किंवा rank.

Step 3. cumsum पाहा.

Step 4. Business प्रश्न एका वाक्यात.

उदाहरणं: copy करा आणि चालवा

Question Tool
Top basket in Pune today rank (within city)
GMV so far this week cumsum after date sort
3-day moving average orders rolling(3).mean()

उदाहरण A — Sort vs rank.

import pandas as pd

df = pd.DataFrame({
    "order_id": ["BLK-1", "BLK-2", "BLK-3", "AMN-4"],
    "city": ["Pune", "Pune", "Nashik", "Pune"],
    "amount_inr": [210, 210, 95, 180],
    "customer": ["Ruhi Bagale", "Amir", "Zoya", "Ravina"],
})
print(df.sort_values("amount_inr", ascending=False))

Sorting shows order. Ranking labels ties clearly (next section).

उदाहरण B — Running total need (fictional evening).

Raja in Nagpur sends hourly delivered GMV. The city manager wants one column: cumulative GMV from midnight IST — that is cumsum, not a new groupby.

उदाहरण C — Decision card.

Question Tool
Top basket in Pune today rank (within city)
GMV so far this week cumsum after date sort
3-day moving average orders rolling(3).mean()