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.

EasyTechnical
110 practiced

Explain what NaN represents in NumPy/pandas, why comparisons like (np.nan == np.nan) return False, and list safe ways to test for missing values in a DataFrame that also work for non-numeric dtypes.

EasyTechnical
56 practiced

You are given a CSV file data.csv (comma-separated, header in the first row). 1) Load it into a DataFrame, parsing a column named event_time as datetime. 2) Print the first 5 rows and a concise summary (info) including non-null counts and dtypes. 3) Select only the columns ['user_id', 'event_time', 'value'] and filter rows where value > 0 and event_time falls in calendar year 2021. 4) Show how you would handle rows with malformed dates during parsing.

MediumTechnical
52 practiced

Given a sample DataFrame df with columns ['id', 'name', 'age', 'signup_date', 'score'] demonstrate with code and explanations the differences between df.loc, df.iloc and chained indexing. Show examples selecting rows 10-20, selecting by boolean condition (age > 30), selecting columns by label and by integer positions. Explain why chained indexing can be dangerous and how to avoid it.

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.