InterviewStack.io LogoInterviewStack.io

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

You currently compute a 'segment' column with df.apply(func, axis=1), where func is a small if/elif chain over a couple of numeric columns, and it is slow on a large DataFrame. Rewrite this so it no longer calls a Python function per row, and explain why your rewrite is faster.

HardTechnical
62 practiced

You have a DataFrame with nested JSON in a column 'payload' (strings of JSON), where some fields inside the payload are themselves lists. Show how to expand this column into separate flat columns, and how to turn the list-valued fields into one row per list item where needed. Discuss the performance implications of doing this at scale.

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.