Handle messy data by detecting each defect with a quick check, choosing the least destructive fix, and writing down every decision. Drop rows only when the damage is small and random, impute when the column matters and the pattern is understood, and escalate to your mentor when the fix would change what the data means. This guide gives you a catalogue of ten defects with pandas code, plus a decision guide you can use inside a 14-day project.
Why messy data decides the quality of a short internship project
In a two-week internship you will not have time to build elaborate models. What separates a convincing submission from a weak one is usually whether the data was understood before it was modelled. A reviewer reading your notebook wants to see that you noticed problems, chose a reasoned response, and can say what that choice did to the results.
Messy data is rarely a single big problem. It is a pile of small ones: a date stored as text, a column where “NA”, “n/a” and a blank mean the same thing, a duplicated customer, an age of 240. Each is easy alone. Together they eat days if you handle them without a system. The catalogue below gives you that system.
If you do not yet have a project to practise on, the free two-week online internship from CareerSwami offers 26 tracks, a free offer letter and a free completion certificate after successful completion, and gives you a realistic setting in which to apply these habits.
Set up a cleaning log before you touch a single row
Keep the raw file untouched and do all work in code, never by hand in a spreadsheet. Create a small log as you go. Every cleaning step should record what you found, how many rows it affected, what you did and why.
import pandas as pd
import numpy as np
raw = pd.read_csv("data_raw.csv")
df = raw.copy()
log = []
def note(issue, rows, action, reason):
log.append({"issue": issue, "rows": rows,
"action": action, "reason": reason})
At the end, pd.DataFrame(log) becomes a table you can paste into your report. It is the cheapest way to show rigour.
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.
Catalogue of ten common data defects with detection code and fix options
All snippets below are illustrative and assume a DataFrame called df with columns named as shown. Adapt column names to your dataset and check results on your own data.
| # | Defect | Detection code | Fix options |
|---|---|---|---|
| 1 | Missing values | df.isna().mean().sort_values(ascending=False) |
Drop rows, drop column, impute (median, mode, group-wise), or flag with an indicator column |
| 2 | Hidden missing values (“NA”, “?”, “-“, 0) | df["col"].value_counts().head(15) |
Replace with np.nan on read, using na_values=[...] |
| 3 | Exact duplicate rows | df.duplicated().sum() |
drop_duplicates() after confirming they are true repeats |
| 4 | Duplicates by key with conflicting values | df[df.duplicated("id", keep=False)].sort_values("id") |
Keep latest by timestamp, aggregate, or escalate |
| 5 | Wrong data types | df.dtypes and pd.to_numeric(df["x"], errors="coerce") |
Convert types; inspect what became NaN after coercion |
| 6 | Inconsistent categories (“Chennai”, “chennai “, “CHN”) | df["city"].str.strip().str.lower().value_counts() |
Normalise case and whitespace, then map variants with a dictionary |
| 7 | Inconsistent date formats | pd.to_datetime(df["date"], errors="coerce").isna().sum() |
Parse with explicit format=, handle day-first ambiguity |
| 8 | Outliers | q1,q3 = df["x"].quantile([.25,.75]); iqr=q3-q1; ((df["x"]<q1-1.5*iqr)|(df["x"]>q3+1.5*iqr)).sum() |
Keep, cap (winsorise), transform (log), or remove if clearly an error |
| 9 | Impossible or out-of-range values | df[(df["age"]<0)|(df["age"]>100)] |
Set to NaN then treat as missing, or correct from a trusted source |
| 10 | Class imbalance and label noise | df["target"].value_counts(normalize=True) |
Stratified split, class weights, resampling only on training data; verify odd labels |
Defects 1 and 2: missing and disguised missing values
Start with the disguised kind, because it hides from isna(). Reading the file with explicit markers fixes it at the source.
df = pd.read_csv("data_raw.csv",
na_values=["NA", "N/A", "n/a", "?", "-", "null", ""])
print(df.isna().mean().sort_values(ascending=False))
Zero deserves suspicion in columns such as blood pressure, price or age, where zero is not a believable measurement. Check the distribution before deciding that zero is real.
Defects 3 and 4: duplicates, exact and conflicting
Exact duplicates are usually safe to remove. Key duplicates are different: two rows for the same customer ID with different addresses are a question, not a cleanup. Sort them side by side and look for a pattern, such as one row always being older.
dups = df[df.duplicated("customer_id", keep=False)].sort_values("customer_id")
print(len(dups), "rows share an ID")
Defects 5 to 7: types, categories and dates
Coercion is powerful but silent. After errors="coerce", always count how many values turned into NaN, then print a few of the originals that failed.
num = pd.to_numeric(df["income"], errors="coerce")
bad = df.loc[num.isna() & df["income"].notna(), "income"]
print(bad.unique()[:20])
For dates, the day-first versus month-first problem is the classic trap: 03/04/2025 can be 3 April or 4 March. Check whether any value has a first part greater than 12, which tells you the convention, and then pass dayfirst=True if appropriate.
Defects 8 and 9: outliers versus impossible values
An outlier is unusual but possible; an impossible value is wrong. A salary ten times the median may be a genuine senior hire. An age of 240 is an entry error. Treat them differently: keep or cap the first after thinking, and convert the second to missing.
Defect 10: imbalance and label noise
If only 3 percent of rows are the positive class, accuracy will look excellent for a model that predicts nothing. Report precision, recall and F1, split with stratification, and apply any resampling to the training portion only to avoid leakage.
Decision guide: when to drop, impute or escalate to your mentor
Use these questions in order. They keep you from the two most common errors: deleting too much, and quietly inventing data.
- Is the damage tiny and random? If under roughly 5 percent of rows are affected and nothing suggests a pattern, dropping is usually acceptable. Treat 5 percent as a rule of thumb, not a law.
- Does the column matter to the question? If it is unused or mostly empty, drop the column instead of the rows.
- Is the missingness patterned? Compare the missing group with the rest. If missing income clusters in one city or one month, imputing blindly will bias results.
- Can you impute with a defensible rule? Median for skewed numbers, mode for categories, group-wise median when groups differ. Add an indicator column so the model can see which values were filled.
- Would the fix change the meaning of the data? Deciding which of two conflicting records is true, redefining a label, or removing a whole segment is a business judgement. Escalate.
| Situation | Drop | Impute | Escalate |
|---|---|---|---|
| 2 percent of rows have random missing values in a feature | Yes | Also fine | No |
| 40 percent of a column is empty | Consider dropping the column | Only with strong justification | If the column is central to the brief |
| Missing target label | Usually drop those rows from training | No | If many rows are affected |
| Missingness clusters in one group | Risky | Group-wise, with a flag | Yes, ask why |
| Conflicting duplicate records | Not before understanding | No | Yes |
| Impossible values in a few rows | Acceptable | Set to NaN, then impute | If it is widespread |
| Outliers that may be real | No | Cap or transform | If they drive the results |
How to escalate without wasting your mentor’s time
Short written questions get faster answers than vague ones. A good message has four parts: what you found, how many rows, the two options you see, and which you would pick by default. For example: “3,100 of 41,000 rows have no delivery date, mostly from March. I can drop them or fill using the order date plus the median delay. Unless you advise otherwise I will drop them and note the effect.” Then keep working on something else while you wait.
Worked illustration: cleaning a small retail orders file
This scenario is invented for teaching and no code was run for it. Suppose a file of 10,000 orders has columns order_id, order_date, city, amount and returned.
- Detect. Checks show 120 exact duplicate rows,
citywith variants such as “Chennai”, “chennai” and “Chennai “, 400 blank amounts, 15 negative amounts, and dates in two formats. - Exact duplicates: drop the 120. Log it.
- City: strip, lowercase, map variants. Rows affected are many but no information is lost.
- Dates: parse both formats explicitly, then check for any date that landed in the future.
- Negative amounts (15): these could be refunds rather than errors. Ask the mentor before touching them. This is an escalation because the fix changes meaning.
- Blank amounts (400, 4 percent): compare blanks against city and month. If spread evenly, impute with the city-wise median and add
amount_missing. If concentrated in one city, escalate. - Report. State final row count, each step’s effect, and re-run your main metric with and without imputation to show sensitivity.
A 14-day schedule that leaves room for data cleaning
- Days 1-2: read the brief, load the data, profile every column, start the cleaning log.
- Days 3-5: work through the catalogue, send written questions to the mentor early.
- Days 6-8: exploratory analysis on the cleaned data, revisit any cleaning that EDA exposes as wrong.
- Days 9-11: modelling or the main analysis, with a simple baseline first.
- Days 12-13: sensitivity checks, write-up, tidy the notebook so it runs top to bottom.
- Day 14: final review and submission.
Cap cleaning at about a third of the total time. Past that point, further polish rarely changes conclusions.
Data-cleaning context for Dr. M.G.R. Educational and Research Institute students
The institution’s website describes it as Dr.M.G.R. Educational and Research Institute – Deemed to be University, and its menu lists a Faculty of Engineering & Technology with departments including Computer Science and Engineering, Data Science, Artificial Intelligence and Information Technology, as well as a Faculty of Computer Applications and a Faculty of Management Studies. That mix means students from very different programmes may end up doing the same kind of data project, so the cleaning habits above apply whichever department you belong to.
What the public pages do not settle is how an external internship project is treated in your own programme. No internship, project-work or evaluation rules for B.Tech, MCA, MBA or similar programmes were verified here. The only internship regulation that surfaced is an excerpt from the 2017 B.Sc. Allied Health Science regulations, which concern a different discipline and an older year, so do not assume they apply to you. Check the current version of any rule before relying on it.
The site’s Placement section lists sub-pages for students, recruiters and industry collaborations, and also shows package figures without stating an academic year. Treat those figures as unverified for any specific batch, and do not use them in a report or resume.
Whatever rules apply, a cleaning log and a clear notebook are exactly what a department coordinator or mentor will want to see.
Steps to verify how your internship project will be treated
- Ask your department coordinator in writing whether an online internship completed outside the university is recognised for your programme and semester.
- Find the current regulations or curriculum document for your programme and look for sections titled internship, industrial training or project work.
- Ask what evidence is expected, such as an offer letter, completion certificate, report or logbook, and in what format.
- Confirm whether the data you use may be shared in a report or viva, particularly if the dataset was supplied by someone else.
- Check the university’s Policies page and mandatory disclosure documents, linked from the homepage, for anything on academic integrity and external work.
- Keep the reply in writing and save it with your project files.
Documenting your cleaning decisions so a reviewer can trust them
Your final report should include one compact table: issue, rows affected, action, reason. Add a short paragraph on limitations, for instance “imputation of 4 percent of amounts used city medians; results were similar when those rows were dropped.” Reviewers rarely expect perfection. They expect honesty about what you assumed.
- Save the cleaned dataset under a new name and never overwrite the raw file.
- Put all cleaning in one function or one notebook section so it can be re-run.
- Fix random seeds for any sampling so results reproduce.
- Describe every row removal as a count and percentage.
Frequently Asked Questions
How much missing data is too much to impute?
There is no universal cutoff. As a working guide, a column that is mostly empty is better dropped, while a few percent missing can be imputed. What matters more is whether the missingness has a pattern. If it does, ask your mentor before filling anything.
Should I remove outliers before or after splitting into train and test sets?
Decide rules using training data only, then apply the same rules to the test data. Removing or capping based on the full dataset leaks information. Clear entry errors can be fixed before splitting because they are not a modelling choice.
Is mean or median imputation better for skewed columns?
Median is usually safer for skewed values such as income or price, because a few large values pull the mean upwards. For categories use the mode, and consider a separate “missing” category when absence itself could carry information.
How do I tell a genuine outlier from a data entry error?
Ask whether the value is physically or logically possible. An age of 240 is not; a very large order might be. Look at neighbouring columns for support, and if you cannot decide, write the question to your mentor with examples.
What should I do when duplicate IDs carry different values?
Do not delete automatically. Sort them side by side and look for a rule, such as a timestamp showing one is an update. If no rule is evident, escalate with a few example pairs and your proposed approach.
Can I use fillna on the entire DataFrame to finish quickly?
That is risky because one fill value rarely suits every column and it hides patterns. Handle numeric, categorical and date columns separately, and keep an indicator column for any field where a meaningful share was filled.
How can a short online internship project show good data cleaning skills?
Include the cleaning log table, the before and after row counts, and a sensitivity check. These show judgement in a few lines, and they fit comfortably inside a 14-day project such as those in the CareerSwami internship tracks.
Do I need to write down cleaning steps if the notebook already has the code?
Yes. Code shows what you did but rarely why. A short log with reasons lets a reviewer follow your thinking without reading every cell, and it helps you write the final summary quickly.
Related Data Science guides
- Dr. B.R. Ambedkar University Delhi Students: Social Science Data Internships With NGOs and Think Tanks
- Geeta University Students: Making a Data Science Internship Certificate Count With Evidence
- Lalit Narayan Mithila University Students: Building a Data Science Practice Routine With Limited Resources
- 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.














