Interview Q&A · questions with model answers

pandas Interview Questions

Part of the study plan for: Machine Learning Engineer · Data Engineer

Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.

  1. What is the difference between loc and iloc in pandas, and what is the SettingWithCopyWarning?

    loc selects by labels (index values and column names); iloc selects by integer positions. The SettingWithCopyWarning appears when you assign into something that might be a copy of a slice, so the…

  2. How do you handle missing data in pandas?

    Find it (isna().sum()), understand why it's missing, then drop, fill or flag it depending on the cause: dropna for rows that are unusable, fillna with a constant, statistic or forward fill for time…

  3. Explain groupby in pandas: split-apply-combine, agg, transform and filter.

    groupby splits rows into groups by keys, applies a function to each group, and combines the results. agg returns one row per group (sums, means), transform returns a value per original row (for…

  4. A pandas script runs out of memory or takes too long on a large file. How do you fix it?

    Load less and store it more compactly: read only needed columns (usecols), set efficient dtypes (categories for repeated strings, smaller numeric types), process in chunks or with filters, use…

  5. Write pandas code that finds each customer's latest order and their 30-day rolling spend.

    Sort by customer and date, use groupby().tail(1) (or idxmax) for the latest order, and a time-based rolling window per customer for the 30-day spend. Time-based windows ("30D") need a datetime index…

  6. When would you use merge, join or concat in pandas?

    merge joins two DataFrames on columns like SQL (inner, left, right, outer); join is a convenience for joining on the index; concat stacks DataFrames vertically (more rows) or side by side (more…

Was this page helpful?

Report a mistake