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
55 practiced

You have two DataFrames df_a and df_b, both indexed by the same MultiIndex ['region','store_id'], with some overlapping columns. Explain how to perform a left join of df_a to df_b while preserving that MultiIndex, and what can go wrong if the index level names or dtypes differ between the two frames.

HardTechnical
61 practiced

Design a robust solution to align and resample irregular event time-series from multiple users across different timezones. Requirements: align to hourly UTC buckets, handle DST transitions correctly, forward-fill missing values per user up to a 6-hour limit, and produce a consistent index for downstream ML features. Outline steps and show pandas code for timezone-aware resampling and per-user forward-fill.

HardTechnical
67 practiced

You must join customer records from two sources where the same person's name and address are spelled slightly differently between systems (typos, abbreviations, formatting differences), so an exact-key join misses real matches. Propose an approach to link these records that scales beyond a handful of rows, and discuss how you would guard against false matches and validate the results before trusting them downstream.

MediumTechnical
51 practiced

Explain and demonstrate with pandas code when to use groupby.transform vs groupby.apply or agg for feature engineering. Specifically compute for each user in an events DataFrame: (1) time since last event, (2) rolling count of events in the last 7 days, and (3) normalized 'value' by user mean using appropriate pandas methods that return aligned results suitable for assignment to new columns.

MediumTechnical
62 practiced

A DataFrame loaded from a CSV is consuming far more memory than the raw data would suggest. Walk through how you would find out where the memory is actually going, and bring it down without losing information you still need. Give code for the highest-impact fix you would try first.

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.