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.

MediumTechnical
61 practiced

A script builds up a result DataFrame by concatenating onto it inside a loop, once per iteration, and it gets dramatically slower as the loop runs longer. Explain why this pattern degrades the way it does, and rewrite it so it scales linearly instead.

HardTechnical
102 practiced

Timezones can be a source of subtle bugs. Given user events with local timestamps and a user timezone column, design a pandas-based approach to normalize events into UTC, handle ambiguous times during DST transitions, and store both original local time and normalized UTC. Provide code examples and discuss edge cases.

HardTechnical
55 practiced

You are asked to reduce memory usage of a DataFrame with numeric columns currently float64 and many repeated integer-like values. Provide a robust step-by-step pandas recipe (and code) to downcast numeric dtypes safely, detect when precision loss is acceptable, and validate results after downcasting.

HardTechnical
59 practiced

Explain what Copy-on-Write changed about when a pandas operation returns a view versus a copy, and why it is no longer something you can opt into or out of. Discuss what this means for code that used to rely on chained assignment sometimes working, and general strategies to avoid unnecessary copies and large temporary DataFrames when working with large datasets.

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.

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.