Interviewers assess a candidate's ability to efficiently manipulate, clean, and analyze tabular data using pandas, focusing on practical problem-solving, understanding core data structures, and applying common operations like filtering, grouping, and merging.
16 questions (5 easy · 6 medium · 5 hard), each with what a strong answer covers and where people lose the point. Free to read, no account.
1.Explain the fundamental differences between a pandas Series and a DataFrame. When would you choose one over the other?
Warm-up
What a strong answer covers
Define a Series as a one-dimensional labeled array capable of holding any data type, similar to a single column of data.
Define a DataFrame as a two-dimensional labeled data structure with columns of potentially different types, resembling a spreadsheet or SQL table.
Highlight that a DataFrame can be thought of as a collection of Series objects that share a common index.
Explain that Series are suitable for single-column data or when working with time-series data, while DataFrames are ideal for tabular, multi-column datasets.
Where people lose the point
×Confusing the dimensionality, stating a Series is 2D or a DataFrame is 1D.
×Failing to mention the 'labeled' aspect of both structures, which is key to pandas.
×Not providing clear use cases for when to prefer one over the other.
2.How would you create a pandas DataFrame from a Python dictionary where keys are column names and values are lists of data? Provide a simple example.
Warm-up
What a strong answer covers
Explain that `pd.DataFrame()` is the constructor used to create a DataFrame.
Demonstrate creating a dictionary where each key represents a column name and its corresponding value is a list (or NumPy array) of data for that column.
Show the syntax: `df = pd.DataFrame(data_dict)`.
Provide a concrete Python code example with a dictionary and the resulting DataFrame.
Where people lose the point
×Incorrectly structuring the dictionary (e.g., values are not lists of equal length).
×Forgetting to import pandas as `pd`.
×Attempting to create a DataFrame from a dictionary of Series without explicitly calling `pd.DataFrame()`.
5.Describe how to add a new column to an existing pandas DataFrame. Provide an example where you add a 'Full Name' column by combining 'First Name' and 'Last Name'.
Warm-up
What a strong answer covers
Explain that new columns can be added by direct assignment, similar to adding a new key-value pair to a dictionary.
Demonstrate the syntax: `df['new_column_name'] = value_or_series`.
Show how to create the 'Full Name' column by concatenating existing 'First Name' and 'Last Name' columns, ensuring a space in between.
Provide a complete code example with a sample DataFrame and the column addition.
Where people lose the point
×Forgetting to include a space or separator when concatenating strings for a new column.
×Attempting to use `df.add_column()` (which doesn't exist) instead of direct assignment.
×Not ensuring the length of the assigned Series/list matches the DataFrame's number of rows.
6.Explain the difference between `.loc` and `.iloc` for data selection in pandas DataFrames. Provide examples for both.
Core
What a strong answer covers
Explain that `.loc` is primarily label-based, used for selecting data by row and column labels (names).
Explain that `.iloc` is primarily integer-position-based, used for selecting data by the integer position of rows and columns.
Provide clear examples demonstrating selection of single elements, rows, columns, and slices for both methods (e.g., `df.loc['A':'C', 'col1']` vs `df.iloc[0:3, 0]`).
Highlight that `.loc` slicing is inclusive of the end label, while `.iloc` slicing is exclusive of the end integer position.
Where people lose the point
×Confusing label-based (`.loc`) with integer-position-based (`.iloc`) indexing.
×Incorrectly assuming `.loc` slicing is exclusive of the end label.
×Attempting to use a non-integer index with `.iloc` or a non-label with `.loc`.
7.Describe the 'split-apply-combine' strategy in pandas and demonstrate how to use `groupby()` to calculate the mean of a numerical column for each category in another column.
Core
What a strong answer covers
Explain the 'split-apply-combine' paradigm: splitting data into groups, applying a function to each group, and combining the results.
Demonstrate using `df.groupby('category_column')` to split the DataFrame.
Show how to select a numerical column and apply an aggregation function, e.g., `['numerical_column'].mean()`.
Provide a complete code example with a sample DataFrame, grouping, and mean calculation.
Where people lose the point
×Forgetting to select a column after `groupby()` before applying an aggregation, leading to aggregation across all columns.
×Misunderstanding the output of `groupby()` before an aggregation (it returns a GroupBy object, not a DataFrame).
×Attempting to use `groupby()` on a non-categorical column without a clear purpose.
8.Explain the different types of merges available in `pd.merge()` (inner, outer, left, right) and illustrate with a scenario where each would be appropriate.
Core
What a strong answer covers
Define `pd.merge()` as a function for combining DataFrames based on common columns or indices, similar to SQL joins.
Explain `inner` merge: returns only rows with matching keys in *both* DataFrames. Scenario: finding common customers in two sales lists.
Explain `left` merge: returns all rows from the left DataFrame, and matching rows from the right. `NaN` for unmatched right keys. Scenario: adding customer details to all orders, even if some customers are missing.
Explain `right` merge: returns all rows from the right DataFrame, and matching rows from the left. `NaN` for unmatched left keys. Scenario: adding order details to all customers, even if some customers have no orders.
Explain `outer` merge: returns all rows when there is a match in *either* DataFrame, filling `NaN` for unmatched values. Scenario: combining all unique records from two datasets.
Where people lose the point
×Misunderstanding which rows are preserved or dropped for different merge types.
×Incorrectly specifying the `on` or `left_on`/`right_on` parameters, leading to unintended joins.
×Not considering potential duplicate keys and their impact on merge results.
9.Compare and contrast `df.fillna()` and `df.dropna()` for handling missing values in a DataFrame. When would you choose one over the other?
Core
What a strong answer covers
Explain `df.dropna()`: removes rows or columns containing missing values. Discuss `axis` and `how` parameters.
Explain `df.fillna()`: replaces missing values with a specified value (e.g., constant, mean, median, mode) or using imputation methods like `ffill`/`bfill`.
Contrast their primary actions: `dropna` removes data, `fillna` modifies/imputes data.
Discuss scenarios for `dropna` (e.g., small number of missing values, missing data is truly irrelevant) and `fillna` (e.g., preserving data, using statistical imputation, time-series data).
Where people lose the point
×Not mentioning the `axis` parameter for both functions, which controls row vs. column operation.
×Failing to discuss the `inplace` parameter and its implications.
×Suggesting `dropna()` as a universal solution, ignoring potential data loss.
10.How can you apply a custom function to a pandas Series or DataFrame? Provide an example using `apply()` to categorize ages into 'Young', 'Adult', 'Senior'.
Core
What a strong answer covers
Explain that the `apply()` method is used to apply a function along an axis of a DataFrame or Series.
Demonstrate applying a function to a Series (e.g., `df['Age'].apply(my_function)`).
Show how to define a custom function (e.g., `categorize_age`) that takes an age and returns a category string.
Provide a complete code example with a sample DataFrame, the custom function, and its application to create a new 'Age Group' column.
Where people lose the point
×Confusing `apply()` with vectorized operations, using it when a direct pandas method exists (e.g., `df['col'].str.lower()` vs `df['col'].apply(lambda x: x.lower())`).
×Incorrectly defining the custom function to accept a Series when it should accept a single value (for Series.apply).
×Forgetting to specify `axis=1` when applying a function row-wise to a DataFrame that needs access to multiple columns.
11.What is the purpose of `df.reset_index()`? Provide a scenario where it would be useful and explain the `drop` parameter.
Core
What a strong answer covers
Explain that `reset_index()` converts the DataFrame's index into a regular column and resets the index to the default integer index (0, 1, 2...).
Describe a scenario where it's useful, such as after a `groupby()` operation where the grouping keys become the new index, and you want them back as regular columns.
Explain the `drop=True` parameter: if `True`, the old index is discarded; if `False` (default), the old index is added as a new column.
Provide a simple code example demonstrating `reset_index()` with and without `drop=True`.
Where people lose the point
×Not understanding that `groupby()` often changes the index, making `reset_index()` necessary.
×Confusing `reset_index()` with simply reassigning the index.
×Forgetting the `inplace=True` parameter if modifying the DataFrame directly is desired.
12.Explain the concepts of 'pivoting' and 'melting' (unpivoting) in pandas. When would you use `pivot_table` versus `melt`?
Hard
What a strong answer covers
Explain `pivot_table`: transforms data from a 'long' format to a 'wide' format, aggregating values. Define `index`, `columns`, and `values` parameters.
Explain `melt`: transforms data from a 'wide' format to a 'long' format, unpivoting columns into rows. Define `id_vars` and `value_vars` parameters.
Provide a scenario for `pivot_table`: summarizing sales data by region and product type, with product types as new columns.
Provide a scenario for `melt`: converting survey responses where each question is a column into a format suitable for statistical analysis (question and answer in separate columns).
Emphasize that they are inverse operations, used for different data representation needs.
Where people lose the point
×Confusing the direction of transformation (wide to long vs. long to wide).
×Incorrectly identifying the `index`, `columns`, `values` for `pivot_table` or `id_vars`, `value_vars` for `melt`.
×Not understanding the aggregation aspect of `pivot_table` (it often requires an `aggfunc`).
14.Discuss key performance considerations when working with large pandas DataFrames. What are some best practices to optimize code for speed?
Hard
What a strong answer covers
Explain the importance of vectorization: using built-in pandas/NumPy operations over explicit Python loops for significant speed gains.
Discuss `apply()`: faster than pure Python loops but generally slower than vectorized operations. Use it when custom logic is unavoidable.
Mention `astype()` for optimizing data types (e.g., using `category` for low-cardinality strings, smaller integer types) to reduce memory usage and improve performance.
Suggest avoiding `inplace=True` where possible, as it can sometimes lead to less readable code and unexpected behavior, and often doesn't offer significant performance benefits.
Briefly touch upon using `chunksize` when reading very large files to avoid memory issues.
Where people lose the point
×Relying heavily on explicit `for` loops for row-wise or element-wise operations instead of vectorized pandas functions.
×Misusing `apply()` when a direct vectorized method exists (e.g., `df['col'].str.lower()` instead of `df['col'].apply(lambda x: x.lower())`).
×Not considering the impact of data types on both memory and computational speed.
15.Demonstrate how to use method chaining in pandas to perform a sequence of operations on a DataFrame in a single, readable statement. Provide an example.
Hard
What a strong answer covers
Explain method chaining as calling multiple pandas methods sequentially, where each method returns a DataFrame or Series, allowing the next method to be called directly.
Highlight the benefits: improved readability, reduced need for intermediate variables, and often better performance due to optimized internal operations.
Provide an example that combines several operations, such as filtering, grouping, aggregating, and sorting, into a single chain.
Emphasize using parentheses and line breaks for clarity in long chains.
Where people lose the point
×Breaking the chain unnecessarily by assigning to intermediate variables.
×Not using parentheses to make the chained operations readable across multiple lines.
×Attempting to chain methods that do not return a DataFrame or Series (e.g., `inplace=True` operations).
16.How do you convert a column to datetime objects and perform common datetime operations like extracting components (year, month) or calculating time differences?
Hard
What a strong answer covers
Explain how to convert a column to datetime objects using `pd.to_datetime()`, mentioning the `errors='coerce'` parameter for handling invalid dates.
Demonstrate extracting components like year, month, day, or hour using the `.dt` accessor (e.g., `df['date_col'].dt.year`).
Show how to calculate the difference between two datetime columns, resulting in a `Timedelta` Series (e.g., `df['end_date'] - df['start_date']`).
Explain how to extract specific units from a `Timedelta` (e.g., `.dt.days` for days difference).
Where people lose the point
×Forgetting to convert the column to datetime objects before attempting to use the `.dt` accessor.
×Not handling potential errors during conversion, leading to `ValueError` for malformed date strings.
×Attempting to perform arithmetic operations on datetime columns without ensuring they are of the correct `datetime64` type.
A question a pandas panel actually asks, answered out loud, scored on what you said and how you said it. Under two minutes, and nothing to sign up for.
“Explain the fundamental differences between a pandas Series and a DataFrame. When would you choose one over the other?”
We never store the audio. Your answer is deleted within 24 hours unless you save the result.
How pandas answers get judged
The weights a pandas interviewer is holding, whether or not they say so out loud. Round Zero scores your practice answers against exactly these, and quotes your own words back as the evidence for each.
Code Correctness
40%
The solution's code is syntactically correct, executes without errors, and produces the expected output for the given problem.
Conceptual Understanding
30%
Demonstrates a clear and accurate understanding of underlying pandas concepts, data structures, and method functionalities.
Efficiency and Best Practices
20%
Utilizes efficient pandas operations (e.g., vectorization over loops), appropriate data types, and follows idiomatic pandas best practices.
Clarity of Explanation
10%
The explanation of the solution, including reasoning and trade-offs, is clear, concise, and easy to understand.
You have read what strong pandas answers contain. The next thing that moves the needle is producing one under time, out loud, and finding out where it falls apart.
What pandas interview questions should I practice?
Start with the core areas pandas interviewers probe: Explain the fundamental differences between a pandas Series and a DataFrame. When would you choose one over the other; How would you create a pandas DataFrame from a Python dictionary where keys are column names and values are lists of data? Provide a simple example.; Given a DataFrame `df`, how do you select a single column named 'Age'? Show two different ways.. This page outlines strong answers and common mistakes, and the scored path drills each one with follow-ups.
Is the pandas practice free?
Yes. The pandas path runs free inside Round Zero: lessons, practice questions and flashcards. Drills are unlimited on every plan, free included. So is the full scorecard. Free also covers 3 complete scored interviews, no card.
How is this different from a pandas question list?
A static list gives you questions with no feedback. Round Zero runs a live scored practice that probes your actual answers, rotates difficulty, and tells you exactly what to fix, grounded in a pandas rubric.
How should I prepare for a pandas interview?
Learn the concepts, drill the questions until answers come fast, then prove it in a scored mock. Round Zero sequences all three so you know you are ready, not just that you read about pandas.
How is a pandas answer scored?
pandas answers are scored on code correctness, conceptual understanding, efficiency and best practices, clarity of explanation, with evidence quoted from what you actually said, so feedback is specific instead of generic praise.
More free tools
Try everything. Sign up only when you want the full version.