tensorturnBETA
Home › Data Cleaning & Analytics

How to Handle Missing Values in a Dataset

To handle missing values, first measure how much is missing per column and whether the gaps follow a pattern, then decide per column to drop rows, drop the column, or impute with the mean, median, mode or a constant. The right choice depends on why the data is missing (MCAR, MAR or MNAR) and whether missingness itself predicts your target. TensorTurn shows missing percentages, a missing-value presence grid and missingness-to-target dependence on upload, and fills or drops gaps with steps you approve.

Why missing values matter

Most algorithms cannot accept empty cells at all, and the ones that can still learn from whatever pattern the gaps leave behind. Silently dropping incomplete rows can shrink a dataset by half and bias it toward customers who fill in every form field. Filling everything with zero invents data. Missing values are a modelling decision, not a nuisance to delete, and the best approach is different for a column that is 2 percent empty than for one that is 70 percent empty.

The three types of missing data

TypeMeaningExampleImplication
MCAR (missing completely at random)Missingness is unrelated to any value, observed or notA sensor randomly drops readings due to a network glitchDropping rows loses data but does not bias results
MAR (missing at random)Missingness depends on other observed columnsYounger respondents skip the income question more oftenImputation that uses other columns works well; simple dropping can bias
MNAR (missing not at random)Missingness depends on the missing value itselfPeople with very high income decline to report itNo simple fix; the missingness is information, so model it explicitly

You can rarely prove which type you have, but you can collect evidence. If missingness in one column lines up with values in another, it is not MCAR. If missingness lines up with the outcome you are predicting, treat it as a signal.

Measure before you fix

Start with the missing percentage per column, then look at the pattern. TensorTurn's column profile shows missing % for every column, and the missing-value presence grid shows where gaps fall across rows, so you can see whether several columns go missing together (often one system or form section failing) or whether gaps are scattered.

Drop or impute: choosing a method

MethodWhen to use itRisk
Drop rows with missing valuesFew rows affected (a few percent) and data looks MCARShrinks data and biases it if missingness is not random
Drop the columnMost of the column is empty and it carries little signalLoses a feature that might matter, especially if MNAR
Fill with meanNumeric, roughly symmetric distribution, light missingnessShrinks variance; pulled by outliers
Fill with medianNumeric and skewed (income, prices, durations)Shrinks variance, but robust to outliers
Fill with modeCategorical columns with a dominant categoryOver-represents the most common value
Fill with a constant ("Unknown", 0, -1)Categoricals where missing is its own meaningful group, or where empty genuinely means zeroA numeric sentinel like -1 can mislead linear models
Add a missing indicator plus imputeMissingness may be informative (MAR or MNAR)Adds columns; still needs an imputed value
Model-based (KNN, iterative imputation)Strong relationships between columns, MARSlower, more complex, must be fitted on training data only

TensorTurn's AI data editor covers the most common methods directly: drop rows with missing values, delete a column, and fill missing with mean, median, mode or a constant. Model-based imputation such as KNN or iterative imputation belongs in the training pipeline, and because TensorTurn's training notebooks are generated Python you can ask for it in plain English.

When missingness predicts the target

Sometimes the fact that a value is missing is one of the strongest signals in the data. A blank "last login date" may mean the customer never activated, which strongly predicts churn. A missing lab result may mean the doctor did not think the test was needed. TensorTurn's target analysis measures missingness-to-target dependence: for a chosen target column it checks whether rows with gaps in a feature have a different outcome rate or average than rows without. If they do, keep that information with a missing indicator rather than erasing it with a fill.

Avoid leakage when imputing

Imputation values are statistics, and statistics computed on the full dataset include the test rows. For quick analysis that is harmless, but for a strict model evaluation the mean, median or mode should be learned from the training split only and then applied to the test split, ideally inside a preprocessing pipeline. TensorTurn's preprocessing playbook for a target column suggests a per-column plan and can be exported as Python code, so imputation can run inside the training pipeline instead of before the split.

Step by step on TensorTurn

Common mistakes

Start building free

Frequently asked questions

Should I drop or impute missing values?

Drop when very few rows are affected and the gaps look random, or when a column is mostly empty and uninformative. Impute when dropping would lose a meaningful share of data, using the median for skewed numbers, the mean for symmetric ones and the mode or "Unknown" for categories.

What is the difference between MCAR, MAR and MNAR?

MCAR means missingness is unrelated to any data, MAR means it depends on other observed columns, and MNAR means it depends on the missing value itself. MCAR is safest to drop, MAR suits imputation from other columns, and MNAR needs the missingness treated as information.

Is mean or median imputation better?

Median is usually safer because it is not pulled by outliers, which matters for skewed data like income or prices. Mean is fine for roughly symmetric numeric columns with light missingness.

How much missing data is too much?

There is no universal cut-off, but columns that are mostly empty rarely help unless the missingness itself predicts the target. Check missingness-to-target dependence before deleting a heavily missing column.

Can TensorTurn fill missing values automatically?

Yes. In the AI data editor you can ask it to fill missing values with the mean, median, mode or a constant, or to drop rows with missing values, and you approve each step before it is applied.