Python and Pandas for Data Analysis Questions

Programmatic data manipulation and analysis in Python and R. Covers pandas transformations, joins and reshaping, aggregation, working with PySpark for larger data, and using R for statistical analysis. Emphasizes clean, reproducible analytical code.

HardTechnical
56 practiced

A churn dataset has missing values in income, last_login, and plan_type, and the missingness seems to come from different sources rather than one system bug. How would you decide whether to impute, drop, or flag each field before modeling, and what would you check to make sure the choice is not biasing the model or hiding an important signal?

MediumTechnical
61 practiced

Your team stores a product tier column as plain strings (Bronze, Silver, Gold, Platinum), but a report needs to sort and compare tiers in business order rather than alphabetically. Walk through how you'd fix the dtype so sorting, comparisons, and groupby all respect that order, and what that buys you over leaving it as a plain string column.

MediumTechnical
63 practiced

You have two DataFrames: prices (timestamp, symbol, price) and trades (timestamp, symbol, quantity). For each trade, you need the most recent price for that symbol at or before the trade's own timestamp. Write pandas code to produce this, explain what ordering your approach depends on, and how you would restrict matches to the same symbol.

MediumTechnical
70 practiced

Using Python and pandas, transform a wide DataFrame 'df' with columns ['month', 'segment_A', 'segment_B', 'segment_C'] into tidy (long) format and compute month-over-month growth per segment. Provide the code outline and note edge cases you must handle (missing months, NaNs, zero denominators).

MediumTechnical
56 practiced

Write Python (pandas) code to compute weekly active users (WAU) from an event log events(user_id, event_time timestamp). Your code should: 1) compute WAU per ISO week, 2) compute week-over-week percentage change, and 3) handle missing days and timezone-aware timestamps. Explain any assumptions.

Unlock Full Question Bank

Get access to all Python and Pandas for Data Analysis interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.