Interview Insights · Data Analytics
What Happens When a Candidate Cannot Explain Their Notebook
Quick summary — Notebook explanation
When you cannot explain your notebook, the interviewer stops treating it as evidence. A notebook is the most detailed proof of your work you can bring to an interview, and that is exactly why interviewers dig into it. When a candidate cannot explain why a column was dropped, why missing values became zero, or why a cell runs out of order, I stop learning about their project and start testing whether they know pandas at all. The round becomes harder, colder and shorter. The good news is that every one of those questions is predictable.
In this guide you will learn:
- What I actually do when a notebook cell has no explanation
- The cells interviewers probe most: missing values, drops, joins and filters
- How hidden state and out-of-order cells give the game away
- How to rewrite a cell so its reason is visible in the notebook itself
- A self-audit you can run on any notebook before an interview
SECTION 01The moment the notebook stops counting as your work
Here is the honest sequence from my side of the table. I open the notebook you linked, scroll past the imports and stop at the first cleaning cell. I ask a simple question: 'Why did you fill missing values with zero here?' If you give a reason, even an imperfect one, we have a conversation about your choices. If you say 'that removed the error' or 'I am not sure, I followed a tutorial', I make a quiet note and move to a second cell.
One unexplained cell is forgivable. Everyone copies a line now and then. Two in a row form a pattern, and at that point I stop using the notebook as evidence. The rest of the round turns into basic questions, such as the difference between loc and iloc or how merge works, because I can no longer assume you know them. That shift is what candidates feel as the interview 'going cold'.
| What you say | What I note | My next move | Effect on the round |
|---|---|---|---|
| It removed the NaN error | Fixing symptoms, not data | Ask what the missing values mean | Doubt starts |
| The tutorial did it | Work may not be yours | Pick another cell to confirm | Trust drops |
| I am not sure now, let me reason | Honest, can think | Let you reason aloud | Often recovers |
| Missing means no purchase, so zero is correct | Understands the data | Probe a harder decision | Round deepens |
df = pd.read_csv('orders.csv')
df = df.drop(['col7', 'Unnamed: 0', 'discount'], axis=1)
df = df.fillna(0)
df = df[df['amount'] < 50000]
df['month'] = pd.to_datetime(df['date']).dt.month
# Interview questions this invites:
# Why drop 'discount'? Why fill every column with 0?
# Where does 50000 come from? Month without year?df = pd.read_csv('orders.csv', index_col=0) # first column is the old index
# 'discount' is blank for most rows and only filled from
# a later system version, so I keep it out of the trend analysis.
df = df.drop(columns=['discount'])
# Missing 'returns' means no return was logged -> 0 is correct.
# Missing 'city' is unknown, so I label it instead of zero.
df['returns'] = df['returns'].fillna(0)
df['city'] = df['city'].fillna('Unknown')
# Orders above the 99.9th percentile were bulk B2B orders,
# confirmed by their customer type, so I analyse them separately.
cap = df['amount'].quantile(0.999)
bulk = df[df['amount'] > cap]
df = df[df['amount'] <= cap]
df['order_month'] = pd.to_datetime(df['date']).dt.to_period('M')
The second version is longer, but every line now answers its own interview question. Notice also the fix at the end: taking only .dt.month merges January of two different years, while to_period('M') keeps year and month together. Bugs like that are what I find when I probe a cell, and finding them yourself first is much better.
SECTION 02The cells interviewers probe first, and why
Interviewers do not pick cells at random for long. With experience, you learn where weak notebooks hide their problems. The imports and the final chart are rarely interesting. The interesting parts are the decisions in the middle: how missing values were handled, which rows were removed, how tables were joined, and how a metric was defined.
These are the places where a copied notebook shows its seams, because the person who wrote the tutorial made those decisions for their own data, not yours. If your notebook drops the same columns or uses the same thresholds as a popular tutorial on a different dataset, the cell cannot be explained, because there is no reason behind it in your context. Prepare each of the cell types below before you share any notebook.
| Cell type | Typical probe | What a good answer includes | Red flag |
|---|---|---|---|
| Missing values | Why this fill method? | What a blank means in the source | Same fill for every column |
| Row filters | Where does this threshold come from? | A check you ran, such as a percentile | A round number with no reason |
| Joins and merges | Did row count change after this? | Expected key relationship, count check | Never checked the shape |
| Metric definition | How is this KPI calculated? | Formula, numerator and denominator | Cannot say what is divided by what |
orders = pd.read_csv('orders.csv')
customers = pd.read_csv('customers.csv')
print('orders before:', len(orders))
# Each order has one customer; each customer appears once.
# validate raises an error if that assumption is false.
merged = orders.merge(
customers,
on='customer_id',
how='left',
validate='many_to_one',
indicator=True,
)
print('after merge:', len(merged))
print(merged['_merge'].value_counts())
# 'left_only' rows are orders with no matching customer.Interviewer: Your row count is the same before and
after the merge. How do you know that is right?
Candidate: I expected it to stay the same, because it is
a left join from orders to a customer table where each
customer should appear once. I used validate='many_to_one',
so pandas would have raised an error if a customer ID
was duplicated.
The indicator column showed a few orders with no
matching customer. I kept them and labelled them
as unknown customers rather than dropping sales.
The validate and indicator arguments of merge are small, but they let you answer the join question with evidence rather than hope. Very few freshers use them, so they also make your notebook stand out when someone reads it.
SECTION 03Hidden state: when the notebook itself contradicts you
Notebooks have a trap that scripts do not. Cells can run in any order, and variables stay in memory after you delete the cell that created them. A notebook that worked on your machine may fail when someone else runs it top to bottom, or the outputs saved in it may come from code that no longer exists.
Interviewers notice this quickly. The execution counters next to each cell, like [12], [3], [27], show the order things ran in. If they jump around, or a cell uses a variable that is never defined above it, the notebook looks assembled rather than built. Worse, if I ask you to rerun a section during a screen share and it breaks, you now have to explain an error under pressure. Clearing hidden state before an interview is basic hygiene.
| Symptom | What it suggests | How I spot it | Fix before the interview |
|---|---|---|---|
| Execution numbers out of order | Cells were run in a random sequence | Counters such as [14] above [3] | Restart kernel and run all |
| Variable used but never defined | Defining cell was deleted | NameError on a fresh run | Search for each variable's first use |
| Outputs do not match the code | Code edited after it ran | Chart title differs from the code | Rerun and resave outputs |
| Hard-coded local file paths | Only runs on one machine | Paths with personal folder names | Use relative paths in a data folder |
# From a terminal, in the project folder:
# executes every cell top to bottom in a fresh kernel
# and saves a new copy, so the original stays untouched.
jupyter nbconvert --to notebook --execute analysis.ipynb \
--output analysis_clean_run.ipynb
# If any cell fails, the command stops and shows the error.
# Fix it in the original notebook, then run again until it passes.# Fragile: works only on one laptop
df = pd.read_csv('C:/Users/me/Desktop/final/orders.csv')
# Robust: data lives in a folder next to the notebook
from pathlib import Path
DATA = Path('data')
df = pd.read_csv(DATA / 'orders.csv')
# Add a short README line: 'Put orders.csv in ./data'.
Running the notebook end to end in a fresh kernel takes a few minutes and removes a whole category of awkward moments. If it reveals a cell you cannot fix or explain, that is a strong sign the cell should be removed or rewritten before anyone else sees it.
SECTION 04A notebook self-audit before you share the link
Run these three checks on every notebook listed on your resume or portfolio. Each one targets a type of question that causes candidates to freeze.
For EVERY cell that changes data, answer:
[ ] What does this cell change? (rows, columns, values)
[ ] Why is that change correct for THIS dataset?
[ ] What would happen if I skipped it?
[ ] Is the reason written in a comment or markdown cell?
Mark cells you cannot answer with # TODO-EXPLAIN
Fix or delete every TODO-EXPLAIN before the interview.Find every hard-coded number in the notebook.
Number | Cell | Where it came from | Written down?
-------+------+--------------------+--------------
50000 | [7] | __________________ | Y / N
0.3 | [15] | __________________ | Y / N
30 | [21] | __________________ | Y / N
Any number with no source is a question
you will be asked and cannot answer.Ask a friend to open your notebook and pick
any three cells without telling you which.
For each cell you must, within 30 seconds:
1. Say what it does in one sentence.
2. Say why it is needed.
3. Name one alternative you considered.
Score: 3/3 cells clear = ready.
Anything less = rewrite those cells and repeat.
SECTION 05Habits that make any notebook easy to explain
These habits make explanation part of the notebook, so the interview becomes a reading of reasons you already wrote down.
- Write the why above the code — Use a short markdown cell or comment before each decision, describing what the data meant and why the step follows from it.
- Print shapes after changes — After filters and merges, print the row count. It gives you evidence to point at when asked whether a step lost data.
- Name variables for meaning — Use names such as
orders_cleanorbulk_ordersinstead ofdf2andtemp, so the interviewer can follow without your help. - Delete what you cannot defend — If a cell came from a tutorial and you cannot explain it for your data, remove it or redo it. A shorter notebook is safer.
- Keep a decisions log — End the notebook with a short list of the main decisions and alternatives. It doubles as your interview revision sheet.
SECTION 06Interview Q&A — Notebook explanation
Q1Why did you fill missing values with zero in this column?
Answer with what a blank means in the source. For example: 'In the returns column, a blank means no return was recorded, so zero is the correct value. For city, a blank means unknown, so I used an Unknown label instead, because zero would be meaningless there.'
Q2How do you know this merge did not duplicate rows?
I compared row counts before and after, and I used pandas merge with validate='many_to_one', which raises an error if the right table has duplicate keys. I also used indicator=True to count orders that had no matching customer.
Q3Where does this threshold in your filter come from?
Give the check behind it. For example: 'I looked at the distribution and the 99.9th percentile, and the orders above it were bulk business orders according to customer type. I analysed them separately so they would not distort the retail averages.'
Q4If I restart the kernel and run all cells, will this notebook work?
Yes, I checked that by executing it end to end in a fresh kernel with nbconvert before sharing it. The data is read from a relative data folder, so it runs on any machine that has the files.
Q5Which part of this notebook would you redo today?
Pick something real, such as: 'I would move the cleaning steps into a function so I could apply them to next month's file, and I would add checks that fail loudly if a column is missing.' This shows growth, not weakness.
SECTION 07Test yourself — Notebook explanation quiz
Five questions. No sign-up.
0 / 5Pick an answer to see why it is right or wrong.
SECTION 08Frequently asked questions
What do interviewers look for in a Jupyter notebook?
They look for clear reasoning in the data cleaning and analysis steps, correct handling of joins and missing values, a notebook that runs top to bottom, and findings that answer a stated question. Clean code helps, but explained decisions matter more.
What if I used a tutorial to build my notebook?
That is common and acceptable if you have adapted it. Make sure every decision fits your dataset, rewrite cells whose reasons you cannot explain, and be honest that you started from a tutorial if asked.
How do I prepare to explain my data analysis notebook in an interview?
Restart the kernel and run all cells, add a reason above every cell that changes data, list every hard-coded number with its source, and practise explaining three random cells to a friend within thirty seconds each.
Should I share my notebook on GitHub before an interview?
Yes, if it runs cleanly and every key step is explained. A notebook full of errors or unexplained cells can hurt you more than having no link, so audit it first.
Is it okay to say I do not remember why I wrote a cell?
Saying it once, and then reasoning aloud about why the step might be needed, is acceptable and often recovers the moment. Saying it repeatedly suggests the work is not yours, so prepare the key cells in advance.
Where can I practise answers like these with expert feedback?
Yes. Uncodemy's Data Analytics Training Course in Noida (classroom and online) includes live projects, one-to-one mock interviews and resume reviews, so you practise answers like these with trainer feedback before the real interview. You can book a free demo class from this page to see how the sessions work.
SECTION 09Related reads
Classroom & online · Noida
Build notebooks you can defend line by line
Our Data Analytics Training Course teaches Python, pandas and analysis workflows through projects, with reviews where trainers question your notebook the way an interviewer would.
₹15,500 · full programme- Hands-on pandas projects
- Notebook code reviews
- Project explanation mocks
- Weekday & weekend batches