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

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

23.6 Debugging checklist

By Ravindra Bagale

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

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

अडकल्यावर यादीने चाला — अंदाजाने random changes नाही.

हे काय आहे?

Checklist: shape, dtypes, head, NaNs, key uniqueness, merge validate, timezone, filter counts.

कसं करायचं?

Step 1. shape आणि dtypes.

Step 2. isna().sum().

Step 3. Key duplicates.

Step 4. Last merge/filter.

Step 5. Expected vs actual एका वाक्यात.

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

उदाहरण A — Helper function.

def peek(df, key="order_id", label="df"):
    print(f"== {label} ==")
    print("shape", df.shape)
    print("dtypes\n", df.dtypes)
    print("na\n", df.isna().sum())
    if key in df.columns:
        print("dup keys", df[key].duplicated().sum())
    if "amount" in df.columns and pd.api.types.is_numeric_dtype(df["amount"]):
        print("amount sum", df["amount"].sum())

peek(df, label="orders")

उदाहरण B — Merge audit.

left = pd.DataFrame({"store_id": ["PUN-01", "NAS-01"], "amount": [10, 20]})
right = pd.DataFrame({"store_id": ["PUN-01"], "city": ["Pune"]})
m = left.merge(right, on="store_id", how="left", indicator=True)
print(m["_merge"].value_counts())
print(m.loc[m["_merge"] != "both"])

उदाहरण C — Story from Rani (Nagpur).

Rani’s cancel rate hit 40% after a “quick filter”. Checklist showed status had mixed case (cancelled vs Cancelled) after a bad export round-trip. str.title() fixed it — not a new chart theme.