Skip to content

Data Cleaning Interview Questions for Data Analytics

33 Data Cleaning questions with answers for data analytics roles — 8 easy, 18 medium, 7 hard.

About Data Cleaning

Data cleaning questions ask how you handle missing values, duplicates, inconsistent labels, wrong data types, mixed date formats, outliers and broken joins, in Excel, Power Query, SQL and pandas. Since cleaning takes most of an analyst's time, interviewers look for a careful, repeatable and documented approach rather than manual fixes that cannot be repeated.

Sheet progressStart practicing
3 QUESTIONS FREESign up to unlock the full question bank and track your progress.Unlock every question and answer, then continue practising company-wise and package-wise.
3 questions free Unlock the rest in seconds
01

What is data cleaning and why does it take so much of an analyst's time?

Save to ▾
Show answer
Data cleaning means fixing or removing incorrect, incomplete, duplicated or inconsistent data so analysis is trustworthy. Real data comes from many systems and manual entry, so you meet typos, mixed formats, missing values and duplicates. Analysts often spend half or more of a project on it because every later chart and model depends on it. Wrong inputs give confident but wrong answers, which is worse than no answer.
02

Numbers in an Excel column are stored as text and SUM returns zero. How do you fix it?

Save to ▾
Show answer
Signs are left-aligned numbers, green triangles, and COUNT returning less than COUNTA. Fix options: select the column and use the warning menu Convert to Number; use Data, Text to Columns and Finish; or a helper column with =VALUE(TRIM(A2)). If there are hidden characters, use =VALUE(SUBSTITUTE(TRIM(A2), CHAR(160), "")) to remove non-breaking spaces from web exports. In Power Query, simply change the column type to number.
03

Write pandas code to trim whitespace and lower-case every text column in a DataFrame.

Save to ▾
Show answer
text_cols = df.select_dtypes(include='object').columns for col in text_cols: df[col] = ( df[col] .astype('string') .str.strip() .str.lower() .replace('', pd.NA) ) # also tidy column names df.columns = df.columns.str.strip().str.lower().str.replace(' ', '_')
04

What is data profiling?

Save to ▾
Show answer
Data profiling is a quick systematic look at a dataset before analysis: row counts, data types, null percentages, distinct counts, minimum and maximum, common values and value patterns per column. In pandas, df.info(), df.describe(include='all') and value_counts() cover most of it; Power Query has column quality and distribution views. Profiling reveals problems like a date column stored as text or a status field with unexpected values early.
05

How do you unpivot a wide monthly sales sheet into a long table in Power Query?

Save to ▾
Show answer
Load the table into Power Query. Select the identifier columns such as Region and Product, then choose Transform, Unpivot Other Columns. The month columns become two columns, Attribute and Value; rename them Month and Sales. Change Month to a date type and Sales to a decimal number. Using Unpivot Other Columns rather than Unpivot Columns means new months added later are picked up automatically on refresh.
06

What is tidy data?

Save to ▾
Show answer
Tidy data follows three rules: each variable is a column, each observation is a row, and each type of observational unit is a table. A sheet with months as columns is not tidy; unpivoting it to Region, Month and Sales columns makes it tidy. Tidy data is easy to filter, group, join and chart in pandas, SQL, Power BI and Tableau, so reshaping into this form is a core cleaning step.
07

How do you split a full name column into first and last name in Excel?

Save to ▾
Show answer
-- A2 = 'Priya Ramesh Iyer' -- first name =TEXTBEFORE(TRIM(A2), " ") -- last name (text after the last space) =TEXTAFTER(TRIM(A2), " ", -1) -- older Excel: first name =LEFT(TRIM(A2), FIND(" ", TRIM(A2)&" ")-1) -- or use Data > Text to Columns or Flash Fill (Ctrl+E) for a one-off task
08

Pin codes in your CSV lost their leading zeros after opening in Excel. Why and how do you prevent it?

Save to ▾
Show answer
Excel guessed the column was a number and dropped leading zeros; the same happens with long IDs turning into scientific notation. Identifiers that are not used in arithmetic should be stored as text. Import through Data, From Text/CSV or Power Query and set the column type to Text, or read it in pandas with dtype={'pincode': str}. To repair, use =TEXT(A2, "000000") when the original length is known.
09

How do you handle a dataset with 30% missing values in a key column?

Save to ▾
Show answer
Understand why it is missing, consider imputation or a missing flag, test sensitivity, and talk to data owners about fixing collection if it is systematic.
10

How do you clean messy text data in Excel?

Save to ▾
Show answer
Use TRIM, CLEAN, UPPER or PROPER, Text to Columns, Flash Fill, SUBSTITUTE, and Power Query for repeatable cleaning steps.
11

What are the main dimensions of data quality?

Save to ▾
Show answer
Common dimensions are accuracy, values reflect reality; completeness, required fields are present; consistency, the same fact matches across systems; validity, values follow formats and rules such as a 6-digit pin code; uniqueness, no unwanted duplicates; and timeliness, data is fresh enough for its use. Measuring these with simple checks, like percent missing or duplicate rate, turns vague complaints about bad data into fixable issues.
12

Write pandas code to standardise inconsistent city names such as 'delhi ', 'New Delhi' and 'DELHI'.

Save to ▾
Show answer
city_map = { 'delhi': 'Delhi', 'new delhi': 'Delhi', 'bombay': 'Mumbai', 'mumbai': 'Mumbai', 'bengaluru': 'Bengaluru', 'bangalore': 'Bengaluru', } clean = df['city'].str.strip().str.lower().str.replace(r'\s+', ' ', regex=True) df['city_clean'] = clean.map(city_map).fillna(clean.str.title()) print(df['city_clean'].value_counts())
13

When would you drop missing values, and when would you impute with mean or median?

Save to ▾
Show answer
Drop rows when few are missing, roughly under 5 percent, and missingness looks random. Impute when dropping would lose too much data. Use the median for skewed numbers such as income or order value, the mean for roughly symmetric data, and the mode or an Unknown category for categoricals. Group-wise imputation, such as median by city, is better than one global value. Always add a flag column showing what was imputed.
14

A file has dates in mixed formats, some dd/mm/yyyy and some mm/dd/yyyy. How do you handle it?

Save to ▾
Show answer
Find out which system or region produced each format, since a source column often explains it. Values with a day above 12 reveal the format unambiguously. Parse with an explicit format per source, for example pd.to_datetime(col, format='%d/%m/%Y', errors='coerce'), rather than letting the tool guess. Check failed or suspicious parses, such as future dates, and ask the source team to send ISO format yyyy-mm-dd going forward.
15

Write SQL to flag rows that fail basic validation rules in a customer table.

Save to ▾
Show answer
SELECT customer_id, CASE WHEN email IS NULL OR email NOT LIKE '%_@_%._%' THEN 1 ELSE 0 END AS bad_email, CASE WHEN LENGTH(pincode) <> 6 THEN 1 ELSE 0 END AS bad_pincode, CASE WHEN signup_date > CURRENT_DATE THEN 1 ELSE 0 END AS future_signup, CASE WHEN age NOT BETWEEN 18 AND 100 THEN 1 ELSE 0 END AS bad_age FROM customers; -- sum each flag to report the error rate per rule
16

What is the difference between an outlier and a data error?

Save to ▾
Show answer
An outlier is a genuine but unusual value, such as a bulk corporate order of 50 laptops; it is real and may be important. A data error is an incorrect value, such as an age of 250 or a price entered in paise instead of rupees. Errors should be fixed or removed. Outliers should be investigated and often kept, perhaps analysed separately or with median-based metrics so they do not distort averages.
17

What steps would you apply in Power Query to clean a messy system export?

Save to ▾
Show answer
Typical steps: remove top junk rows and promote the real header row, remove blank rows and columns, set correct data types, trim and clean text, split combined columns such as Name - City, replace error values, fill down for grouped labels, remove duplicates on the business key, and unpivot wide month columns. Rename steps meaningfully so others can follow them, and keep the query foldable when the source is a database.
18

An inner join between orders and customers returns fewer orders than the orders table has. What could be wrong?

Save to ▾
Show answer
Orphan records are child rows whose foreign key has no matching parent, such as orders with a customer_id that does not exist in the customer table. They break joins silently: an inner join drops them and totals fall short. Find them with a LEFT JOIN from the child to the parent and filter where the parent key IS NULL. Then fix the source, add an Unknown member, or report them separately.
19

How should you document data cleaning decisions?

Save to ▾
Show answer
Keep a cleaning log or README listing each rule, why it exists and its impact, for example removed 1,240 test orders flagged by email domain. Code-based cleaning in SQL, Python or Power Query steps is itself documentation if steps are named clearly. Record counts before and after each major step. This lets reviewers trust the numbers, helps a colleague rerun the work, and answers the question why your total differs from the raw file.
20

Write Python code to extract valid 10-digit Indian mobile numbers from a messy text column.

Save to ▾
Show answer
import re pattern = re.compile(r'(?:\+?91[\s-]?|0)?([6-9]\d{9})') def get_mobile(text): if not isinstance(text, str): return None digits = re.sub(r'[\s()-]', '', text) m = pattern.search(digits) return m.group(1) if m else None df['mobile'] = df['contact'].apply(get_mobile)
21

Customer names in your file show strange characters like 'é' instead of accented letters. What is wrong and how do you fix it?

Save to ▾
Show answer
This is an encoding mismatch: a UTF-8 file was read as a different encoding such as Latin-1 or Windows-1252. Re-read it with the right encoding, for example pd.read_csv(path, encoding='utf-8') or 'utf-8-sig' for files with a byte order mark, or set the file origin in Excel and Power Query import. Avoid re-saving through tools that change encoding, and agree on UTF-8 for all exchanges, especially for Hindi or other Indian language text.
22

Tell me about a time you found a serious data quality issue.

Save to ▾
Show answer
Situation: while building a returns report I noticed one warehouse had zero returns for three months. Task: confirm whether it was real. Action: I compared with the source system and found its return codes had changed after a software update, so my filter missed them. I informed the data owner, updated the mapping and back-filled the history. Result: the corrected report showed that warehouse had the highest return rate, which led to a packaging review.
23

Your sales data contains negative quantities. What do you do with them?

Save to ▾
Show answer
Do not delete them blindly. First find out what they mean: often they are returns, cancellations or credit notes, which are valid business events. Check with the source team or a documentation note. If they are returns, keep them but report gross sales, returns and net sales separately. If some are clearly entry errors, such as a negative quantity on a new order, flag and correct them and log the rule.
24

Write pandas code to fill missing values in a column with the median of each group.

Save to ▾
Show answer
# Fill missing delivery_days with the median for that city df['delivery_days'] = ( df['delivery_days'] .fillna(df.groupby('city')['delivery_days'].transform('median')) ) # Rows in a city with no values at all stay NaN; fall back to overall median df['delivery_days'] = df['delivery_days'].fillna(df['delivery_days'].median())
25

What is referential integrity and how do orphan records appear in analytics data?

Save to ▾
Show answer
Referential integrity means every foreign key value points to an existing row in the parent table, for example every order's customer_id exists in customers. Orphan records break this rule. They appear when source systems load tables at different times, records are deleted without cascading, or IDs are formatted differently across systems. Detect them with a LEFT JOIN where the parent key is NULL, and decide whether to fix, map or flag them.
26

Your event logs store timestamps in UTC, but the business reports daily sales in IST, and late-night orders land on the wrong day. How do you fix it?

Save to ▾
Show answer
Convert timestamps to the business time zone before deriving the date. IST is UTC plus 5 hours 30 minutes, so an order at 20:00 UTC belongs to the next day in IST. In SQL use AT TIME ZONE or CONVERT_TZ, and in pandas use tz_localize('UTC') followed by tz_convert('Asia/Kolkata'). Store raw UTC, add a local date column in the model, and document which one each report uses.
27

What are MCAR, MAR and MNAR missing data?

Save to ▾
Show answer
MCAR, missing completely at random, means missingness is unrelated to anything, like a random sensor glitch; dropping rows is mostly safe. MAR, missing at random, means missingness depends on other observed variables, for example older customers skipping the email field; impute using those variables. MNAR, missing not at random, means it depends on the missing value itself, like high earners hiding income; this biases results and needs careful handling or extra data.
28

The customer table has near-duplicates like 'Rahul Sharma, 98xxxx1234' and 'Rahul Sharma, +91 98xxxx1234'. How do you deduplicate?

Save to ▾
Show answer
First normalise: trim and lower-case names, collapse spaces, and strip country codes and symbols from phones and emails. Then match on strong keys such as phone or email. For remaining records use fuzzy matching on names with a similarity score, restricted to the same city or pin code to limit comparisons. Review borderline scores manually, keep a mapping from old IDs to a master ID, and fix entry at the source.
29

You loaded a month of sales into the warehouse. How do you check the load is complete and correct?

Save to ▾
Show answer
Reconcile against the source: compare row counts, total amount, and counts by day and by store between source and target. Check for duplicate keys, nulls in mandatory columns, and dates outside the expected month. Compare with the previous month to spot big unexplained jumps. Spot-check a few individual transactions end to end. Automate these checks so each future load produces a small pass or fail report.
30

Sales data from different countries mixes currencies and some weights are in grams while others are in kilograms. How do you handle it?

Save to ▾
Show answer
Never add mixed units. Identify the unit for each row from a currency or unit column, or infer it from the source system. Convert to one standard, for example INR using a dated exchange rate table joined on transaction date, and kilograms using a conversion factor. Keep the original value and unit columns for audit. Document which rates were used, and flag rows where the unit could not be determined.
31

The column names in a monthly vendor file keep changing. How do you make your cleaning pipeline robust?

Save to ▾
Show answer
Agree a data contract with the vendor if possible. In the pipeline, normalise headers by trimming, lower-casing and replacing spaces, then map known variants to standard names through a lookup table you maintain. Validate that all required columns exist after mapping and fail with a clear message if not, instead of producing silent blanks. Select columns by name, never by position, and log any unexpected new columns for review.
32

Where should data cleaning happen: Excel, SQL, Python or Power Query?

Save to ▾
Show answer
Clean as close to the source as is practical and in a repeatable tool. Fixes everyone needs belong upstream in the database or warehouse via SQL so all reports share them. Power Query suits report-specific shaping and Excel users. Python is best for complex logic like fuzzy matching or regex at scale. Manual Excel edits are fine for one-off exploration but should not be part of recurring reports because they cannot be reproduced.
33

How can you automate data quality checks in a reporting pipeline?

Save to ▾
Show answer
Define tests as code that run after every load: not-null and unique checks on keys, accepted value lists, referential integrity, row count within an expected range compared with recent days, and freshness of the latest timestamp. Store results in a table and alert the team on failures before dashboards refresh. Start with checks on the few tables behind key KPIs, then expand. This catches issues before stakeholders do.

Frequently asked questions

How important is Data Cleaning in Data Analytics interviews?

Data cleaning questions ask how you handle missing values, duplicates, inconsistent labels, wrong data types, mixed date formats, outliers and broken joins, in Excel, Power Query, SQL and pandas. Since cleaning takes most of an analyst's time, interviewers look for a careful, repeatable and documented approach rather than manual fixes that cannot be repeated.

How should I use the Data Cleaning sheet?

Go top to bottom — easy to hard. Answer before opening each answer, tick what you solved and save misses to Last-Minute Revision.