pandas for analysis · core
Types, dates and missing values
Wrong types and missing values cause silent errors. Check dtypes, parse dates with an explicit format, and understand why values are missing before you fill them.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- fillna(0) adds fake instant deliveries and lowers the average. Filling with the mean keeps the average but shrinks the spread and hides the problem. mean() skips NaN, which is fine only if the missing rows are like the rest.
- Look for a pattern in missing values: df["x"].isna().groupby(df["city"]).mean(), and by platform, app version and status. Cancelled orders are left out, not filled.
- Show coverage next to a number (based on 81% of orders) and ask engineering to fix the tracking. Use dropna(subset=...) rather than dropping every row with a NaN in any column.
- Amounts such as 1,20,000 load as text. Use pd.read_csv(..., thousands=","). Summing text joins the strings.
- to_datetime guesses the format from the first value. 03-11-2026 can be read month-first. Use format="%d-%m-%Y" or dayfirst=True. If every day is 12 or less there is no error and every date is silently swapped.
- errors="coerce" turns bad dates into NaT silently. Use it only with a count of the NaT rows it creates.
- pandas 3 parses to datetime64[us] (microseconds) by default, so code that turns dates into integers with astype("int64") gets numbers 1,000 times smaller than before.
- Check after loading: df.dtypes, the min and max dates, the row count and the total against the vendor's footer.
- Copy-on-write is always on in pandas 3, so chained assignment such as df[df.a > 0]["b"] = 1 no longer changes the frame.
The red pen
Common traps: mistake → fix
Mistake: fillna with the mean is a safe fix
Fix: it hides a pattern in why values are missing.
Mistake: errors="coerce" and move on is fine
Fix: it turns bad dates into NaT with no warning.
Mistake: Chained assignment still updates the frame
Fix: not in pandas 3; use df.loc[mask, "b"] = 1.
Easy to hard
Questions interviewers ask, easy to hard
- 20% of delivery times are missing. What do you do?
- A payout file has dates like 03-11-2026 and amounts like 1,20,000. What goes wrong with a plain read_csv?
- Why is errors="coerce" risky?
- What changed about dates in pandas 3?
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.