Interview questions

Pandas Interview Questions

17 pandas interview questions on indexing, groupby, merges, missing data, performance and pandas 3.0 Copy-on-Write, with model-answer guidance.

Pandas Interview Questions

What's here

17 Pandas interview questions, grouped into 4 areas: selecting and filtering data, grouping, merging and reshaping, missing data and data types and performance and real tasks. Each one comes with why it is worth asking and what a strong answer contains, so the same question can be scored the same way by different interviewers.

  • Give a small DataFrame and a task (top customer per month, share of group total) and watch how the candidate approaches it
  • Ask candidates to predict the output of a loc slice on a non-default index
  • Include a merge with duplicate keys and ask what will happen to the row count
For hiring teams

Cohesyve finds, contacts and tests Pandas candidates on the real work, then ranks them for these interviews. 14-day free trial for 10 candidates, not charged until it ends.

Preparing for this interview yourself? Practise it free →

pandas is the standard Python library for working with tabular data, used daily by data analysts, data scientists and data engineers. These pandas interview questions cover selecting data with loc and iloc, groupby, merging, missing values, performance and the changes in pandas 3.0. Each question comes with what a strong answer contains, so interviewers can score consistently and candidates can check that they understand why pandas behaves as it does.

Selecting and Filtering Data

Indexing is where most pandas confusion starts.

  1. 1

    What is the difference between loc and iloc?

    Why ask it

    The most common pandas question, with a detail many people miss.

    What to look for

    loc selects by label and iloc by integer position. With loc, slices include both the start and the stop label; with iloc, the end position is excluded, like normal Python slicing. Strong answers give an example where the index labels are not 0, 1, 2 to show the difference.
  2. 2

    Why does df[df['A'] > 2 & df['B'] < 3] fail or give the wrong result?

    Why ask it

    Tests understanding of boolean indexing.

    What to look for

    Operator precedence: & binds more tightly than the comparisons, so each condition needs parentheses: df[(df['A'] > 2) & (df['B'] < 3)]. Candidates should also know to use &, | and ~ rather than and, or and not on Series.
  3. 3

    How do you select rows where a column matches any value in a list?

    Why ask it

    A common practical task.

    What to look for

    Using isin, for example df[df['country'].isin(['UK', 'IE'])], and ~ to negate. Mention of query() as an alternative for readability is a plus.
  4. 4

    What changed about chained assignment in pandas 3.0, and how should you write updates now?

    Why ask it

    Tests whether knowledge is current.

    What to look for

    Copy-on-Write is the default and only mode in pandas 3.0, so chained assignment such as df['foo'][df['bar'] > 5] = 100 never updates df and raises a ChainedAssignmentError warning. The fix is a single loc call: df.loc[df['bar'] > 5, 'foo'] = 100.
For hiring teams

Before the Pandas interviews, see who can do the work

Cohesyve finds and contacts Pandas candidates from your job description and tests each one on an AI job simulation of the role, so these questions go to a ranked shortlist. 14-day free trial for 10 candidates, not charged until it ends.

Grouping, Merging and Reshaping

Combining and summarising data is the core of most pandas work.

  1. 5

    Explain how groupby works.

    Why ask it

    Groupby underpins most analysis.

    What to look for

    Split-apply-combine: split the data into groups, apply a function to each group, combine the results. Strong answers name the three kinds of apply step: aggregation (one value per group), transformation (same index as the input) and filtration (keeps or drops rows or whole groups).
  2. 6

    When would you use transform instead of agg after a groupby?

    Why ask it

    Separates intermediate from basic users.

    What to look for

    transform returns a result aligned to the original rows, which is useful for adding a group statistic back as a column (for example each row's share of its group total). agg reduces each group to one row. A worked example strengthens the answer.
  3. 7

    What are the options for the how argument in merge?

    Why ask it

    Joins are a daily task and a frequent source of errors.

    What to look for

    inner (the default, keys in both), left, right, outer (union of keys) and cross (Cartesian product). Candidates should know that unmatched keys produce NaN and that duplicate keys on both sides multiply rows.
  4. 8

    How do you check that a merge did not silently duplicate or drop rows?

    Why ask it

    Tests data quality habits.

    What to look for

    Using validate (for example 'one_to_one' or 'many_to_one'), which raises an error if keys are not unique as expected; using indicator=True to add a _merge column showing left_only, right_only or both; and comparing row counts before and after.
  5. 9

    What is the difference between concat and merge?

    Why ask it

    Basic but often confused.

    What to look for

    concat stacks objects along an axis (rows below rows, or columns side by side by index); merge joins on key columns or indexes like a SQL join.

Missing Data and Data Types

Messy data and wrong dtypes cause subtle bugs.

  1. 10

    Why does df['col'] == np.nan never find missing values, and what should you use instead?

    Why ask it

    A classic trap.

    What to look for

    NaN does not equal anything, including itself, so the comparison is always False. Use isna() and notna(). Strong answers also mention that sums skip missing values by default unless skipna=False is passed.
  2. 11

    How do you decide whether to drop or fill missing values?

    Why ask it

    Tests judgement, not just API knowledge.

    What to look for

    It depends on why data is missing and how much: dropping rows can bias results; filling with a constant, mean, median or forward fill each make assumptions. Good candidates investigate the cause first and document the choice.
  3. 12

    When would you convert a column to the categorical dtype?

    Why ask it

    Shows awareness of memory and ordering.

    What to look for

    When a string column has few distinct values, converting saves memory; when values have a logical order (low, medium, high), an ordered categorical sorts and compares correctly. The benefit shrinks as the number of categories approaches the number of rows.
  4. 13

    What changed for text columns in pandas 3.0?

    Why ask it

    Checks current knowledge.

    What to look for

    pandas 3.0 uses a new default string data type for text (shown as str), using pyarrow when installed and falling back otherwise, instead of the old object dtype by default. Candidates should know this can affect code that checks for object dtype.

Performance and Real Tasks

How the candidate handles larger data and practical problems.

  1. 14

    Why is using apply with a Python function often slow, and what do you do instead?

    Why ask it

    Performance awareness is expected beyond junior level.

    What to look for

    apply calls a Python function row by row; vectorised column operations, built-in methods (str, dt accessors), np.where or merges usually run much faster. Use apply when there is no vectorised option, and measure before optimising.
  2. 15

    A CSV file is too large to load into memory. How do you work with it?

    Why ask it

    A common real-world constraint.

    What to look for

    Reading only needed columns with usecols, setting efficient dtypes, reading in chunks with chunksize and aggregating as you go, converting to a columnar format such as Parquet, or moving to a tool built for larger-than-memory data when pandas is the wrong fit.
  3. 16

    How would you calculate a monthly total from daily transaction data?

    Why ask it

    A practical time-series task.

    What to look for

    Parsing dates to datetime, then either resample with a month-based frequency on a datetime index, or groupby on a period or Grouper, then sum. Strong answers mention time zones and missing days.
  4. 17

    How do you find and remove duplicate rows, and how do you decide which copy to keep?

    Why ask it

    Data cleaning is a large share of real work.

    What to look for

    duplicated() and drop_duplicates() with subset and keep arguments, sorting first so the right row is kept (for example the latest record), and investigating why duplicates exist before removing them.

Running the interview well

  • 1Give a small DataFrame and a task (top customer per month, share of group total) and watch how the candidate approaches it
  • 2Ask candidates to predict the output of a loc slice on a non-default index
  • 3Include a merge with duplicate keys and ask what will happen to the row count
  • 4Ask which pandas version they use and whether they know about Copy-on-Write in pandas 3.0
  • 5Probe judgement on missing data; the reasoning matters more than the method
  • 6Score readable, vectorised code above clever one-liners nobody can maintain

Common questions

What pandas topics are most common in interviews?

loc versus iloc, boolean filtering, groupby with agg and transform, merge and concat, pivot tables, missing data, dtypes including categoricals and datetimes, apply versus vectorised operations, and handling large files.

How should I prepare for a pandas interview?

Practise on a real dataset: clean it, join it to another table, group and summarise it, and plot the result. Time yourself on common tasks such as top N per group and month-over-month change, and review what changed in pandas 3.0.

What is the difference between loc and iloc in pandas?

loc selects by label and includes both ends of a slice. iloc selects by integer position and excludes the end of a slice, like standard Python slicing.

What is Copy-on-Write in pandas?

Copy-on-Write means any DataFrame or Series derived from another behaves as a copy, so changing it never changes the original. It is the default and only mode in pandas 3.0, which is why chained assignment no longer works and updates should use a single loc call.

Do pandas interviews include SQL questions?

Often, especially for analyst and data engineering roles. Many interviewers ask you to solve the same problem in SQL and pandas, so knowing how joins and group-bys map between them helps.

For hiring teams

Save these questions for the Pandas candidates who can do the work

Cohesyve takes your Pandas job description, finds candidates, reaches out to them and runs an AI job simulation of the real work, then returns a ranked shortlist.

1,500+

assessments completed

50%

faster time-to-hire

5 min

from JD to assessment

14-day free trial · 10 candidates · Not charged until the trial ends

For job seekers

Preparing for a Pandas interview yourself? Practise on an AI job simulation of the role. 3-day free trial, cancel anytime.

Practise a Pandas interview free →

See Cohesyve in action

Free 30-min walkthrough

See it on your role