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.

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

Explain how a pandas MultiIndex works. Given a DataFrame df with a MultiIndex on ['country','city'] and columns ['year','population'], show how you would select every row for a single country, reorder and sort the index levels, and turn the MultiIndex back into plain columns. Discuss when a MultiIndex actually helps versus when a flat single index is easier to work with.

HardTechnical
63 practiced

A left merge between orders and customers unexpectedly resulted in fewer rows than the original orders DataFrame. Walk through how you would diagnose why rows were lost, and what you would check first.

HardTechnical
67 practiced

You must join customer records from two sources where the same person's name and address are spelled slightly differently between systems (typos, abbreviations, formatting differences), so an exact-key join misses real matches. Propose an approach to link these records that scales beyond a handful of rows, and discuss how you would guard against false matches and validate the results before trusting them downstream.

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.

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.