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

Examine the code:

subset = df[df['A'] > 0]
subset['B'] = subset['C'] * 2

Using the pandas version you have installed, explain exactly what happens when this runs: does it silently do nothing, raise an error, or modify df, and why. Show the correct way to either modify df in place or work on a genuinely independent copy, and how you would tell which one you have before writing to it.

HardTechnical
55 practiced

You discover a subtle bug where a pandas transformation yields different results on developer laptop and production machine. Outline a debugging plan: check pandas and dependency versions, inspect dtypes, examine float precision and sorting order, and verify deterministic ordering. Provide concrete checks and code to assert environment parity and data invariants.

MediumTechnical
54 practiced

Given time-series data per user, you need the mean, standard deviation, min, and max over the trailing 7 days, computed separately for each user. Show an efficient pandas approach that avoids materializing unnecessary intermediate DataFrames, and explain what indexing requirements your approach depends on.

EasyTechnical
64 practiced

Describe when to use pivot vs melt in pandas. Given a DataFrame sales with columns ['date','store_id','product','units_sold'], show code to create a pivoted table with store_id as rows, product as columns and sum of units_sold, then show how to revert that wide table back to the original long format using melt.

EasyTechnical
73 practiced

Explain the difference between DataFrame.loc and DataFrame.iloc in pandas. Provide Python examples showing selection by label vs integer position, slicing semantics (inclusive/exclusive), behavior with boolean arrays and callable indexing, and discuss pitfalls when the index contains integer labels or duplicate labels.

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.