Top 50 Python & Pandas Interview Questions
Ace Python and Pandas technical interviews with real-world scenarios on data cleaning, multi-index slicing, groupby aggregations, merges, and time-series.
Calculate Frequency of Items in Python (Dictionary & Counter)
Count the occurrence frequency of items in a raw list using basic dictionaries and collections.Counter.
Clean and Filter Data with List Comprehensions in Python
Transform and filter raw text data in a single pythonic, memory-efficient expression.
Memory-Efficient Data Streaming with Generators in Python
Stream massive 50GB datasets line-by-line using Python yield generators to preserve RAM.
loc vs iloc in Pandas: Label-Based vs Integer-Based Indexing
Contrast label-based indexing (.loc) with integer positional indexing (.iloc) and boundary inclusion rules.
Filter DataFrames with Multiple Conditions in Pandas
Apply compound boolean conditions using bitwise operators (&, |) and parentheses.
Optimize DataFrame Memory by Downcasting and Category Dtypes in Pandas
Reduce DataFrame memory consumption by 70%+ by downcasting int64/float64 and converting low-cardinality strings to category.
Vectorization vs apply() vs iterrows(): Performance Benchmarks in Pandas
Understand why numpy vectorization is 100x-1000x faster than iterrows() and apply().
Detect and Quantify Missing Values with isna().sum() in Pandas
Audit null and missing data percentages across all DataFrame columns.
Impute Missing Values with Group Median in Pandas
Impute missing numeric values using the median of their specific subgroup to avoid outlier bias.
Deduplicate DataFrames by Subset Columns in Pandas
Remove duplicate records based on specific composite key subsets and specify which occurrence to keep.
Convert Formatted Currency Strings to Floats in Pandas
Strip currency symbols, commas, and whitespace from price strings and cast to numeric floats.
Multiple Named Aggregations with groupby().agg() in Pandas
Compute mean, sum, count, and unique customers in a single groupby pass with clean column names.
Build Matrix Dashboards with pivot_table in Pandas
Pivot transactional data into cross-tabulated revenue matrices with row and column totals using margins=True.
Reshape Data from Wide to Long Format with melt() in Pandas
Unpivot wide spreadsheet tables where month columns exist into tidy long format.
Feature Normalization and Percentage of Group Total with transform()
Compute each item's percentage contribution to its category total using groupby().transform().
Reshape Hierarchical Series with unstack() in Pandas
Pivot inner index levels of a MultiIndex Series into columns with unstack().
Compute Group-Wise Running Totals with cumsum() in Pandas
Calculate running cumulative sums partitioned by customer ID and sorted by transaction date.
Select Top N Records Per Group with nlargest() in Pandas
Extract the top N rows per partition using groupby().apply(nlargest) or rank.
Table Joins with pd.merge() and Indicator Auditing in Pandas
Perform inner, left, and outer joins with pd.merge() and audit matching origins using indicator=True.
Fuzzy Time Series Matching with merge_asof() in Pandas
Match transactional records to the closest prior timestamp in an asynchronous market price stream.
Calculate Rolling 30-Day Moving Averages in Pandas
Compute rolling 30-day moving average and standard deviation on daily sales data.
Calculate Month-over-Month Growth with pct_change() in Pandas
Compute percentage changes between consecutive periods using .pct_change().
Detect Outliers Using Interquartile Range (IQR) in Pandas
Filter statistical anomalies outside [Q1 - 1.5*IQR, Q3 + 1.5*IQR] using quantile calculations.
Ranking Methods in Pandas: min, max, first, dense
Contrast the ranking behaviors of `method='dense'`, `'min'`, `'max'`, and `'first'` in Pandas.
Implement SQL LAG and LEAD with .shift() in Pandas
Shift column values forward or backward by N rows to calculate sequential differences.