The 60 Pandas questions interviewers actually ask, with direct answers, practice Python snippets, diagrams, videos, and data-cleaning tips.
60 questions with answersKey Takeaways
Pandas is a Python library for cleaning, transforming, analyzing, and reshaping tabular data. Its core objects are Series for one-dimensional labeled data and DataFrame for two-dimensional labeled tables. In interviews, Pandas questions test whether you can filter rows, select columns, group and aggregate, merge datasets, handle missing values, work with dates, and avoid slow row-by-row code. A strong answer shows the code and explains the data shape before and after the operation.
Watch: Data Analysis in Python with pandas
Video: Data Analysis in Python with pandas (Wes McKinney, YouTube)
Test yourself and earn a certificate
6 quick questions. Score 70%+ to download your Pandas certificate.
Start here. These are the definitions and first-principle checks that open most rounds.
Pandas is a Python library for labeled tabular data analysis.
Use it for local data cleaning, exploration, joining, reshaping, and aggregation.
Pandas changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Watch a deeper explanation
Video: Data Analysis in Python with pandas (Wes McKinney, YouTube)
A Series is a one-dimensional labeled array in Pandas.
Think of it as one column with an index.
Series changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
import pandas as pd
s = pd.Series([10, 20, 30], name="score")
print(s.mean())A DataFrame is a two-dimensional labeled table with rows and columns.
Most Pandas interview tasks use DataFrames.
DataFrame changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
An index labels rows and can support alignment, selection, joins, and time-series operations.
Index alignment can surprise candidates during arithmetic.
Index changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
| Answer part | What to say | Evidence to mention |
|---|---|---|
| Definition | Index in one direct sentence. | Official docs or course material |
| Use case | The work where it changes a decision. | Dataset, model, query, dashboard, or pipeline |
| Risk | What breaks when it is misunderstood. | Metric, log, test result, or review note |
A dtype is the data type of a Series or column.
Wrong dtypes cause bad sorting, math errors, and failed date operations.
dtype changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Watch a deeper explanation
Video: Pandas for Data Analysis (SciPy, YouTube)
loc selects rows and columns by label or boolean mask.
Use loc when you mean labels.
loc changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
active = df.loc[df["status"] == "active", ["user_id", "revenue"]]iloc selects rows and columns by integer position.
Use iloc when you mean position.
iloc changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
A boolean mask is a True/False Series used to filter rows.
Use parentheses around each condition.
boolean mask changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
groupby splits data into groups, applies an aggregation, and combines the result.
It is one of the most asked Pandas operations.
groupby changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
revenue_by_plan = df.groupby("plan")["revenue"].sum().reset_index()Key point: The direct answer is the grouping key, aggregation, and output shape.
Aggregation reduces many rows to a summary value such as sum, mean, count, min, or max.
Use named aggregations for readable output.
aggregation changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
merge joins two DataFrames using one or more keys.
Always check join keys and row counts before and after.
merge changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
concat stacks or combines DataFrames along rows or columns.
Use it when tables already share compatible structure.
concat changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
A pivot table summarizes data by reshaping rows into a matrix of values.
It is useful for cross-tab summaries.
pivot table changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Watch a deeper explanation
Video: So You Wanna Be a Pandas Expert? (PyData, YouTube)
melt converts wide data into long format.
Long format is often easier for grouping, plotting, and modeling.
melt changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
apply runs a function across rows or columns.
It is flexible but often slower than vectorized operations.
apply changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Vectorization applies operations to whole arrays or columns without explicit Python loops.
It is usually faster and cleaner than iterating rows.
vectorization changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Missing values are absent or null entries represented by NA-like markers.
Use isna, fillna, dropna, or explicit flags depending on meaning.
missing values changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Duplicate rows repeat the same record or key.
Before dropping duplicates, define what makes a row duplicate.
duplicate rows changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
SettingWithCopyWarning warns that Pandas may be modifying a view rather than the intended DataFrame.
Use loc assignment to be explicit.
SettingWithCopyWarning changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Pandas time series features handle dates, times, resampling, rolling windows, and time-based indexing.
Date parsing and timezone assumptions are common interview follow-ups.
time series changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
These questions test whether you can apply the topic to real data, real code, and messy constraints.
Use read_csv, inspect shape and dtypes, and parse dates where needed.
Do not assume imported columns have correct types.
reading a CSV changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
df = pd.read_csv("orders.csv", parse_dates=["created_at"])
print(df.shape)
print(df.dtypes)Use boolean masks with loc for readable filters.
Wrap each condition in parentheses.
filtering rows changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
big_orders = df.loc[(df["status"] == "paid") & (df["amount"] > 100)]Use a list of column names to keep only the fields you need.
Column selection reduces noise and memory.
selecting columns changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
cols = ["user_id", "created_at", "amount"]
orders = df[cols]Use assign or direct column assignment with vectorized expressions.
Avoid row loops for simple derived columns.
creating a column changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
df = df.assign(net_amount=df["amount"] - df["discount"])Measure nulls first, then fill, drop, or flag based on meaning.
Missing can be data quality noise or a real signal.
handling missing values changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
null_rate = df.isna().mean()
df["age_missing"] = df["age"].isna().astype(int)
df["age"] = df["age"].fillna(df["age"].median())Watch a deeper explanation
Video: Effective Pandas (PyData, YouTube)
Use drop_duplicates with the key columns that define uniqueness.
Never drop duplicates before defining the business key.
dropping duplicates changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
users = df.drop_duplicates(subset=["user_id"], keep="last")Use groupby with named aggregations for readable summaries.
Reset index if you need a flat table.
grouping data changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
summary = df.groupby("plan").agg(
users=("user_id", "nunique"),
revenue=("amount", "sum"),
avg_order=("amount", "mean"),
).reset_index()Use merge and validate join type, keys, and row counts.
Join mistakes are common interview traps.
joining DataFrames changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
joined = orders.merge(users, on="user_id", how="left", validate="many_to_one")Key point: Mention `validate`. It instantly shows you know how joins fail in real data.
Use concat when stacking tables with the same columns.
Set ignore_index when old indexes should not be preserved.
concatenating DataFrames changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
all_orders = pd.concat([jan_orders, feb_orders], ignore_index=True)Use pivot_table to summarize values across two dimensions.
Specify aggfunc when duplicate combinations exist.
pivoting data changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
pivot = df.pivot_table(index="region", columns="plan", values="amount", aggfunc="sum", fill_value=0)Use melt to convert wide columns into variable-value rows.
Long data is easier for plotting and grouping.
melting data changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
long = df.melt(id_vars="user_id", var_name="metric", value_name="value")Use sort_values with explicit ascending rules.
Sort after aggregation when ranking groups.
sorting data changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
top = summary.sort_values("revenue", ascending=False).head(10)Use to_datetime and check invalid parses.
Dates imported as strings break time filters.
parsing dates changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
df["created_at"] = pd.to_datetime(df["created_at"], errors="coerce")Set a datetime index, then use resample for daily, weekly, or monthly summaries.
Know the time zone and missing-period behavior.
resampling time series changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
daily = df.set_index("created_at").resample("D")["amount"].sum()Use rolling for moving averages, sums, or counts over ordered data.
Sort by time before rolling.
rolling windows changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
df = df.sort_values("created_at")
df["ma7"] = df["amount"].rolling(7).mean()Use the str accessor for vectorized text cleaning.
It is cleaner than looping over rows.
string operations changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
df["email_domain"] = df["email"].str.lower().str.split("@").str[-1]Use category dtype for repeated labels when memory and valid values matter.
It can save memory and prevent invalid categories.
categorical data changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Use loc for assignment on the DataFrame you intend to modify.
The goal is explicit assignment.
avoiding SettingWithCopyWarning changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
df.loc[df["status"] == "trial", "segment"] = "trial_user"Use vectorized operations, efficient dtypes, selected columns, and chunking for large files.
If data is too large for memory, move to SQL, Polars, Dask, or Spark.
speeding up Pandas changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Pandas performance order
Check row counts, nulls, totals, duplicate keys, and sample rows after each major transform.
This is how you catch silent data errors.
validating output changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Advanced rounds test trade-offs, failure modes, and whether the decision can hold up under production pressure.
Check key uniqueness on both sides and use validate in merge.
Unexpected row growth usually means duplicate keys.
merge creates too many rows changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Merge debug flow
Read selected columns, set dtypes, use chunks, push filters to SQL, or move to a larger-data tool.
Do not load everything and hope.
CSV is too large for memory changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Check group keys, index, as_index, reset_index, and whether the aggregation is named correctly.
Shape awareness is a major Pandas interview signal.
groupby result has wrong shape changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Watch a deeper explanation
Video: pandas in 10 minutes (Wes McKinney and PyData, YouTube)
Convert strings to datetime before sorting or filtering.
String dates sort lexicographically, not by actual time.
dates sort incorrectly changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Check unmatched keys, join direction, key formatting, and whether missing means no match or missing attribute.
Missing after joins often reveals data coverage issues.
missing values after left join changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Replace it with vectorized operations, map, merge, or NumPy where possible.
apply is not always bad, but it should not be your first move.
slow apply function changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Define user grain, deduplicate by key and time rule, then verify counts.
Duplicate users can inflate metrics.
duplicate users in analysis changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Use SQL for extraction and heavy filtering in the database; use Pandas for local inspection and custom transforms.
Moving less data is usually better.
Pandas vs SQL choice changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Use melt to convert repeated question columns into long format.
Long format makes grouping and plotting much easier.
wide data from survey changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Normalize time zones and document whether timestamps are local, UTC, or user-local.
Time zones can silently move events across dates.
time zone issue changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Explain that Pandas may be assigning to a copy, then rewrite with loc.
The fix is explicit assignment.
SettingWithCopyWarning in interview changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Use to_numeric with error handling, inspect failed values, and decide how to clean them.
Bad dtypes often come from commas, currency symbols, or blanks.
wrong dtype for numeric column changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Group rare categories or keep top values and map the rest to Other.
This helps summaries and models.
category with rare values changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Define cohort, first activity date, return window, and unique user count.
Retention is a definition-heavy Pandas task.
calculating retention changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Sort within group or use groupby with idxmax, then validate ties.
Tie behavior should be explicit.
finding top item per group changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Move repeated transforms into functions, tests, scheduled jobs, and checks.
Pandas can support production steps, but notebooks need structure.
data pipeline uses notebook logic changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Check missing values because classic integer dtypes cannot represent NaN.
Use nullable integer dtype if needed.
integer column becomes float changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Use reset_index, stack, unstack, or explicit index names to make shape clear.
Multi-index is useful but easy to make unreadable.
multi-index confusion changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Explain input grain, transform steps, row-count checks, null handling, join validation, and output shape.
That is the practical path the question needs.
senior Pandas review changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Write the clear version first, validate it, then optimize only if needed.
Readable correct code beats clever broken code.
Pandas answer under time pressure changes Pandas decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Pandas overlaps with NumPy and SQL, but each tool has a different center of gravity. Good candidates know where Pandas fits instead of using it for everything.
| Tool | Best at | Data shape | Interview takeaway |
|---|---|---|---|
| Pandas | Cleaning, joining, grouping, and reshaping tabular data | Labeled rows and columns | Best for local analysis and data wrangling |
| NumPy | Fast numeric arrays and vectorized math | Homogeneous arrays | Pandas uses NumPy ideas underneath |
| SQL | Querying data from databases | Tables in a database | Use SQL to get data, Pandas to inspect and transform |
| PySpark | Distributed processing | Large datasets across a cluster | Use when data no longer fits local memory |
Pandas interview skill weight
Most Pandas rounds are practical coding rounds.
Scale: Hyring editorial score for interview preparation, not an external benchmark.
Prepare by writing code. Pandas interviews usually ask you to transform a small dataset under time pressure while explaining shape, index, and null behavior.
The typical Pandas interview flow
Most rounds reward clear reasoning more than memorized phrasing.
A strong Pandas answer is concrete: The starting DataFrame shape, write the operation, then state the expected output shape and validation check. Interviewers are not only checking syntax. They want to know if you understand grain, index behavior, nulls, join cardinality, and why vectorized code usually beats row-by-row loops.
Before filtering, grouping, or joining, say what one row represents. Is it one user, one event, one order, or one user-day? This avoids silent mistakes where a join multiplies rows or a groupby aggregates the wrong unit. Shape thinking also helps you catch output that is too large or too small.
Use loc when selecting by labels and iloc when selecting by position. Say why you chose one. This is more than syntax: it shows you know that an index can carry meaning and that chained selection can create confusing view-copy behavior.
The index can be useful for alignment, time series, and fast selection, but it can also surprise candidates who forget it exists. Say when you would reset_index, set_index, or keep the default index. This matters after groupby, pivot, merge, and concat operations.
For joins, The key columns, expected cardinality, and row-count check. In real work, merge mistakes create fake totals and fake model signal. Mention merge(..., validate=...) when possible because it turns an assumption into a runtime check instead of a comment.
When multiple derived columns are needed, assign can make the pipeline easier to read and test. The intermediate columns for intent, not for cleverness. In an interview, readable Pandas code is usually better than a one-line chain that hides each calculation.
Do not fill every null by habit. Ask why the value is missing, whether missingness means something, and whether the rule must be learned only from training data. For interviews, a clean answer separates display cleanup from modeling cleanup.
Date columns create many Pandas interview traps: timezone, date parsing, monthly grouping, rolling windows, and inclusive or exclusive boundaries. A clear answer converts to datetime, names the time grain, and states the expected time window before aggregating.
Vectorized code is usually the right first choice, but it should still be readable. If the operation becomes unreadable, split it into assign steps with names that explain the intent. Interviewers prefer clear, checkable transformations over one dense expression that nobody can debug.
Groupby can return a reduced table, a transformed Series aligned to the original rows, or a filtered subset. Say whether you need aggregation, transform, or filter. This one distinction catches many mistakes in revenue, churn, and cohort questions.
Pandas can be fast enough for local work, but memory can fail before CPU does. A practical answer mentions selecting only needed columns, reading chunks when appropriate, setting dtypes, using categoricals for repeated strings, and moving very large work out of Pandas.
Many Pandas prompts are SQL prompts in disguise. If the task is a join, filter, aggregation, or window calculation, say the SQL equivalent briefly. This helps interviewers see that you understand the data operation, not only the Pandas method name.
Pandas is excellent for local tabular work. It is not always right for huge distributed data, concurrent production services, or database-side filtering. The practical point is when to push work to SQL, PySpark, DuckDB, or a pipeline job instead of forcing every task into memory.
After a transformation, say what the first few output rows should look like. Include the columns that remain, the index behavior, and one row that proves the calculation. This is a simple way to catch mistakes before the interviewer has to point them out.
Dropping rows, filling values, trimming strings, and changing dtypes should follow a rule, not a habit. The rule is explicit so the interviewer can judge whether the transformation preserves the meaning of the data.
After code, say how you would verify it: sample rows, compare totals before and after, check null counts, inspect duplicate keys, and confirm expected categories. This final check turns a coding answer into an analysis answer and prevents the most common Pandas interview mistakes.
6 questions, about 4 minutes. Score 70% or higher to earn a shareable certificate.
Hyring's AI Coding Interviewer can score live Python tasks, including data-cleaning and analysis problems. Use these Pandas questions with the Python and SQL banks before a data role screen.
See Hyring AI Coding Interviewer