Mentors approve Python code when they can read it once, run it top to bottom, and trust the result. That comes down to four habits: descriptive names, small single-purpose functions, comments that explain why, and notebooks that restart and run cleanly. The checklist below turns those habits into a review you can run on your own work in about ten minutes.
What a mentor actually checks when they open your data science notebook
A mentor reviewing a beginner’s notebook is rarely hunting for clever modelling. They are asking simpler questions. Can I tell what each variable holds? Can I see where the data comes from? If I press “Restart and run all”, does it finish? Can I change one number, such as a file path or a split ratio, without editing ten cells?
Code that fails these questions slows down feedback, because the mentor spends their time decoding instead of advising on your analysis. Code that passes them gets feedback on the things that matter: your features, your validation, your conclusions.
Most clean-code advice for Python traces back to PEP 8, the community style guide, which covers naming, spacing and line length. You do not need to memorise it. Installing a formatter and a linter in your editor handles most of the mechanical rules, leaving you to focus on judgement: names, structure and explanation.
The four-part code review checklist for Python data science work
Run through this table before sharing anything. Tick each row honestly. Any row you cannot tick is a specific fix, not a vague “improve the code”.
| Area | Check | Pass looks like |
|---|---|---|
| Naming | Variables describe their contents | monthly_sales, not df2 or x |
| Naming | Python conventions followed | snake_case for variables and functions, UPPER_CASE for constants, PascalCase for classes |
| Naming | Units and types hinted where it helps | price_inr, age_years, is_churned |
| Naming | No shadowing of built-ins | No variables called list, sum, id, type |
| Functions | Each does one job | You can describe it in one sentence without “and” |
| Functions | Inputs passed in, results returned | No hidden reliance on global variables |
| Functions | No magic numbers | Thresholds and ratios are named constants at the top |
| Functions | Short enough to read on one screen | Roughly 20 to 30 lines; longer ones are split |
| Comments | Explain why, not what | “Drop rows with zero fare: these are refunds, not trips” |
| Comments | Docstring on every function | One line on purpose, plus inputs and outputs if not obvious |
| Comments | No dead code | No commented-out blocks left from experiments |
| Notebook hygiene | Runs top to bottom after a restart | “Restart kernel and run all” ends with no errors |
| Notebook hygiene | Imports in one cell at the top | No imports scattered mid-notebook |
| Notebook hygiene | Markdown headings structure the story | Problem, data, cleaning, analysis, result, next steps |
| Notebook hygiene | Randomness is controlled | A seed set for splits and models |
| Notebook hygiene | Paths are not machine-specific | No C:\Users\yourname\Downloads\... in the code |
Free 2-Week CareerSwami Internship
Online, 14 days, with a free offer letter and a free completion certificate once you finish the work. Check with your college that it fits your requirement before you enrol.
Naming: the cheapest improvement you can make
Naming costs nothing and shows up in every line. A few working rules:
- Name the content, not the type.
customersbeatsdf. If you hold a cleaned version,customers_cleantells the reader what changed. - Avoid numbered chains.
df,df1,df2,df_final,df_final2forces the reader to trace history. Rename at each meaningful step, or chain operations. - Use verbs for functions.
load_orders(),remove_outliers(),plot_monthly_trend(). - Use question-style names for booleans.
is_valid,has_missing_values. - Keep single letters for tiny scopes only.
iin a short loop is fine.X_trainandy_trainare accepted machine learning convention.
Functions: from a wall of cells to reusable steps
A function is useful for data work when it takes a DataFrame in and gives a DataFrame out. That makes each step testable and reorderable. Watch for these smells:
- A cell that loads data, cleans it, trains a model and prints a score all at once.
- The same filtering code pasted three times with small differences.
- A function that modifies a global DataFrame instead of returning a new one.
- A long list of positional arguments. Use keyword arguments so calls read clearly.
Docstrings matter too. A one-line docstring such as """Return rows with a valid age between 0 and 100.""" saves a reviewer from reading the body.
Comments: say why the code does something
A comment that repeats the code, like # drop na above df.dropna(), adds noise. A good comment records a decision or a fact about the data that the code cannot show:
- Why you dropped, filled or capped values.
- Where an assumption came from, such as “column ‘fare’ is in rupees per the data dictionary”.
- Why you chose a threshold or a model setting.
- A warning about a trap, such as “sorting must happen before the rolling mean”.
If a comment is needed to explain a confusing name, rename the variable instead.
Notebook hygiene: making a Jupyter file trustworthy
Notebooks let you run cells in any order, which means a notebook can look fine yet fail from scratch. Hidden state is the main danger. Apply these habits:
- Before sharing, choose Kernel → Restart and run all. If anything breaks, fix it.
- Put imports and configuration (paths, seed, constants) in the first code cell.
- Use markdown cells as headings so the notebook reads like a short report.
- Delete scratch cells, repeated
df.head()calls and abandoned experiments. - Keep outputs sensible. Do not leave a 5,000-row printout visible.
- Use relative paths such as
data/orders.csvso a mentor can run it on their machine. - End with a short conclusion cell stating what you found and what you would try next.
Cleaning up a messy pandas snippet, step by step (illustrative)
The snippet below is an invented, illustrative example written for this article. It has not been executed, and the file and column names are made up. Treat it as a pattern for your own cleanup.
The messy version
import pandas as pd
df = pd.read_csv("C:/Users/me/Downloads/orders.csv")
df2 = df[df['amt'] > 0]
df2 = df2.dropna()
df2['d'] = pd.to_datetime(df2['d'])
x = df2[df2['d'] > '2025-04-01']
list = x.groupby('city')['amt'].sum()
print(list)
Step 1: fix the path and gather configuration
The absolute path only works on one laptop. Move it to a constant, make it relative, and name the cutoff date.
DATA_PATH = "data/orders.csv"
START_DATE = "2025-04-01"
Step 2: rename cryptic columns and variables
Rename amt and d right after loading, so the rest of the code reads naturally. Stop reusing list, which shadows a built-in.
Step 3: split into single-purpose functions
import pandas as pd
DATA_PATH = "data/orders.csv"
START_DATE = "2025-04-01"
def load_orders(path):
"""Load orders and give columns readable names."""
orders = pd.read_csv(path)
return orders.rename(columns={"amt": "amount", "d": "order_date"})
def clean_orders(orders):
"""Keep paid orders with complete data and parsed dates."""
cleaned = orders.dropna().copy()
# Zero or negative amounts are treated as refunds or errors (assumption: confirm with data owner).
cleaned = cleaned[cleaned["amount"] > 0]
cleaned["order_date"] = pd.to_datetime(cleaned["order_date"])
return cleaned
def revenue_by_city(orders, start_date):
"""Return total amount per city for orders after start_date."""
recent = orders[orders["order_date"] > start_date]
return recent.groupby("city")["amount"].sum()
orders = clean_orders(load_orders(DATA_PATH))
city_revenue = revenue_by_city(orders, START_DATE)
print(city_revenue)
Step 4: review the result against the checklist
- Naming:
orders,city_revenue, and verb-led function names replacedf2,xandlist. - Functions: each step takes input and returns output, so you can test or reorder them.
- Comments: one comment records an assumption a mentor might question.
- Notebook: constants sit at the top, and the path is relative. Place the function definitions in one cell and the three-line run in another.
Notice what changed and what did not: the logic is the same, but a reviewer can now question your refund assumption instead of puzzling over x.
Yogi Vemana University students: applying the code checklist to coursework and projects
Yogi Vemana University is a state university in Kadapa, Andhra Pradesh, and its syllabi reach students through both its own campus and affiliated colleges. A syllabus PDF hosted by Government Degree College, Porumamilla carries the Yogi Vemana University heading for the B.Com (Computer Applications) semester-5 course. It lists skill-enhancement labs and topics such as big data analytics and R. This is an excerpt, so check the current version. The practical point is that lab-style courses are where readable code earns marks and goodwill, whichever language your lab uses.
For postgraduates, a third-party page describes the MCA as a three-year programme with Seminar-I, a Mini Project and later Project Work. That page is not an official syllabus, so confirm the structure with your department. If it holds, you will hand in code that an examiner or guide reads, which is exactly when naming, docstrings and a clean notebook help.
The university’s distance and online arm states in its 2025-26 UGC portal application that one programme includes internships, field studies and project work. Internship and project-work rules for your own programme were not verified, so do not assume how an online internship is treated.
If you want practice material, the free two-week online internship at CareerSwami offers 26 tracks, a free offer letter and a free completion certificate after successful completion. It is independent of the university, and you can use the checklist above on whatever you build there.
Verification steps for YVU students before you rely on code in a graded or credited submission
- Ask your department office for the current syllabus PDF for your programme and semester, and note any lab or project components that involve programming.
- Email your project guide or HOD asking whether a specific code format, report template or language is required for mini projects and project work.
- Ask in writing whether an online internship is accepted for any internship requirement in your scheme, and what document proves it.
- Ask whether submissions must include code, a notebook, or only a report, and whether a viva will examine your code.
- Check the academic calendar your college follows, so you know when project submissions fall.
A 14-day plan to build clean-code habits during a two-week internship
| Days | Focus | Output |
|---|---|---|
| 1-2 | Set up editor, formatter, linter; read PEP 8 headings | Starter notebook with a config cell |
| 3-4 | Naming pass on any older notebook | Before and after versions |
| 5-7 | Convert repeated cells into functions with docstrings | Three tested helper functions |
| 8-9 | Rewrite comments to explain why | Assumptions list in the notebook |
| 10-11 | Restart-and-run-all discipline, relative paths, seeds | Notebook that runs cleanly from scratch |
| 12-13 | Self-review using the checklist table | Marked-up checklist with fixes |
| 14 | Write a conclusion cell and share for feedback | Final notebook ready for a mentor |
Pre-submission pass: the last five checks before you send code to a mentor
- Restart the kernel and run everything once more.
- Search for
df2,temp,testandxand rename what remains. - Delete commented-out code and unused imports.
- Read your markdown headings alone: do they tell the story?
- Write two lines at the top: the question you are answering and the data you are using.
Frequently Asked Questions
How long should a function be in a data science notebook?
There is no fixed limit, but a useful guide is that it fits on one screen and does one job. If you need “and” to describe it, split it.
Should I put everything in functions, even in a notebook?
Not everything. Exploration cells can stay loose. Once a step is repeated or becomes part of your final pipeline, wrap it in a function with a docstring.
Do I need to follow PEP 8 strictly?
Follow its core conventions, mainly naming and spacing, and let a formatter such as Black or Ruff handle the rest. Consistency matters more than any single rule.
How many comments are too many?
If a comment restates the code, remove it. Keep comments that record why you made a choice or what an assumption about the data is.
Why does my notebook work for me but fail for my mentor?
Usually hidden state: cells run out of order, variables defined in deleted cells, or absolute file paths. Restart and run all, and use relative paths to find these problems.
Should I submit a notebook or a .py script for a project?
Follow what your guide asks for. If no rule is given, ask in writing. A notebook suits analysis and storytelling, while a script suits reusable pipelines.
Can I use this checklist on work from the CareerSwami internship?
Yes. Apply the same naming, function, comment and notebook checks to anything you build there, so the notebook you share for feedback is easy to review.
What is the quickest improvement if I only have ten minutes?
Rename vague variables, delete dead cells, and run Restart and run all. Those three steps remove most of the problems mentors flag first.
Related Data Science guides
- Mata Gujri University Students: Asking Good Questions When You Are Stuck in a Data Internship
- Sunrise University Students: Spotting Fake or Low-Value Data Science Internship Offers
- KL University Students: Building a Text Analysis Project During a Data Science Internship
- All Data Science internship guides
Ready to put this into practice?
Join the free two-week CareerSwami online internship in Data Science. The internship, the offer letter and the completion certificate are free.




















