InterviewStack.io LogoInterviewStack.io

Python Data Manipulation with Pandas Questions

Skills and concepts for extracting, transforming, and preparing tabular and array data in Python using libraries such as pandas and NumPy. Candidates should be comfortable reading data from common formats, working with pandas DataFrame and Series objects, selecting and filtering rows and columns, boolean indexing and query methods, groupby aggregations, sorting, merging and joining dataframes, reshaping data with pivot and melt, handling missing values, and converting and validating data types. Understand NumPy arrays and vectorized operations for efficient numeric computation, when to prefer vectorized approaches over Python loops, and how to write readable, reusable data processing functions. At higher levels, expect questions on memory efficiency, profiling and optimizing slow pandas operations, processing data that does not fit in memory, and designing robust pipelines that handle edge cases and mixed data types.

HardTechnical
74 practiced
You need a fast group-wise custom aggregation that currently uses df.groupby(...).apply(custom_python_fn) and is too slow because of Python overhead. Describe techniques to optimize: rewrite in vectorized form, use numba to JIT compiled functions, use cython, or express logic with C-accelerated libraries. Provide a small example converting a Python loop over groups into a numba-accelerated function with minimal pandas interaction.
HardTechnical
111 practiced
You have many partitioned parquet files on S3 and need to perform deduplication across the entire dataset by a key without loading all data into memory. Design an approach using pandas + pyarrow that minimizes memory, leverages partition pruning, and avoids excessive network IO. Describe the algorithm and provide code sketches.
MediumTechnical
71 practiced
You need to merge a small dimension table (10k rows) into a very large fact table (200M rows). Describe pandas strategies to make this join efficient and memory-safe. Consider using categorical dtypes, setting indexes, using map/replace for one-to-many, and chunked processing. Provide example code for a chunked merge approach.
EasyTechnical
57 practiced
You have two DataFrames: users (user_id, name, signup_date) and events (event_id, user_id, event_type, ts). Demonstrate with pandas how to perform: inner join, left join, and an anti-join (rows in users with no events). Show how to handle overlapping column names and how to use the 'indicator' and 'validate' parameters during merge.
MediumTechnical
84 practiced
Implement a pandas function that deduplicates records keeping the latest row per key based on a 'updated_at' timestamp. The function should accept a DataFrame and a list of key columns and return the deduplicated DataFrame. Show an approach that works efficiently even when called on chunks of data as part of a streaming ETL.

Unlock Full Question Bank

Get access to hundreds of Python Data Manipulation with Pandas interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.