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

Write pandas code to remove groups with fewer than 3 transactions per customer in DataFrame df_orders where each group is defined by customer_id. Use groupby.filter and explain how groupby.filter differs from groupby.transform in terms of return shape and alignment.

EasyTechnical
51 practiced

Explain how to inspect the schema and quality of a newly loaded DataFrame. Provide pandas code to show column dtypes, basic descriptive statistics for numeric and categorical columns, percent missing per column, and a sample of unique values for a chosen categorical column.

MediumTechnical
70 practiced

Using Python and pandas, transform a wide DataFrame 'df' with columns ['month', 'segment_A', 'segment_B', 'segment_C'] into tidy (long) format and compute month-over-month growth per segment. Provide the code outline and note edge cases you must handle (missing months, NaNs, zero denominators).

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.

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.

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.