# Visualize Missing Data in Python with missingno

> Visualize missing data in Python with missingno. Call msno.matrix(df), msno.bar(df), msno.heatmap(df) and msno.dendrogram(df) to see where NaNs are, which columns go missing together, and how to read each chart.

Source: https://www.pythoncharts.com/python/missing-data-plots-python/ | Published: 2026-12-06 | Author: Alex Scott | Category: Python | Tags: missing-data, missingno, nan, eda, data-cleaning, pandas, matplotlib, heatmap

To see missing data in a pandas DataFrame, call `msno.matrix(df)` from the [missingno](https://github.com/ResidentMario/missingno) package. It draws one row per record and one column per variable, filled where a value exists and white where it is `NaN`, so outages, gaps and shared patterns stand out at a glance. `msno.bar()`, `msno.heatmap()` and `msno.dendrogram()` summarize the same information as counts and correlations.

This post was run with missingno 0.5.2, Matplotlib 3.11 and pandas 3.1. Install it with `pip install missingno`.

## Quick Example

The data is a year of simulated daily readings from a weather station (seeded, so you get the same chart). Three things went wrong with it: the humidity and pressure sensors were offline for 45 days, the wind sensor drops out at random, and the UV sensor fails on about half of the hot days.

```python
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import missingno as msno

rng = np.random.default_rng(21)
days = pd.date_range("2025-01-01", periods=365, freq="D", name="date")
day = np.arange(365)
df = pd.DataFrame({
    "temp_c": 12 + 10 * np.sin(2 * np.pi * (day - 110) / 365) + rng.normal(0, 2.5, 365),
    "humidity": rng.normal(65, 10, 365),
    "pressure_hpa": rng.normal(1013, 6, 365),
    "wind_kph": rng.gamma(4, 4, 365),
    "rain_mm": rng.exponential(2, 365) * (rng.random(365) < 0.35),
    "uv_index": np.clip(5 + 4 * np.sin(2 * np.pi * (day - 110) / 365) + rng.normal(0, 1, 365), 0, 11),
}, index=days).round(1)

outage = (day >= 120) & (day < 165)                      # humidity and pressure sensor offline
df.loc[outage, ["humidity", "pressure_hpa"]] = np.nan
df.loc[rng.random(365) < 0.08, "wind_kph"] = np.nan      # random dropouts
hot = df["temp_c"] > 18                                  # the UV sensor drops out on hot days
df.loc[hot & (rng.random(365) < 0.5), "uv_index"] = np.nan
df.loc[rng.random(365) < 0.04, "rain_mm"] = np.nan
df.loc[rng.random(365) < 0.03, "temp_c"] = np.nan

msno.matrix(df, freq="ME", figsize=(9, 5), fontsize=11)
plt.show()
```

![Nullity matrix of a year of weather station data with a white block in the humidity and pressure columns, scattered white gaps in wind and UV, and a sparkline on the right](https://www.pythoncharts.com/python/missing-data-plots-python/images/missingno-matrix-quick-example.png)

Each row is a day and each column a variable. The white block in `humidity` and `pressure_hpa` is the 45-day outage, from May 1 to June 14, and it lines up exactly in both columns. `wind_kph`, `rain_mm` and `temp_c` have thin scattered gaps, while `uv_index` is solid in winter and spotty from May to September. The sparkline on the right counts the filled cells in each row, from 2 to 6 (the dip in May and June is the outage). Of the 365 days, 235 have every column filled.

## How many values are missing in each column?

Before plotting, count them. `df.isna().sum()` gives counts and `.mean()` gives the share:

```python
summary = pd.DataFrame({"missing": df.isna().sum(), "share": df.isna().mean().round(3)})
print(summary)
```

```text
              missing  share
temp_c             13  0.036
humidity           45  0.123
pressure_hpa       45  0.123
wind_kph           25  0.068
rain_mm            13  0.036
uv_index           55  0.151
```

## Bar chart of missing values

`msno.bar(df)` draws one bar per column showing how many values are *present*, with the count along the top. Use `log=True` if one column is almost empty and the others are not visible next to it:

```python
fig, ax = plt.subplots(figsize=(8, 4))
msno.bar(df, ax=ax, color="#2a9d8f", fontsize=11)
plt.show()
```

![Bar chart of non-null counts for six columns, with UV index and humidity the shortest bars](https://www.pythoncharts.com/python/missing-data-plots-python/images/missingno-bar.png)

The bar heights are the fraction of values present, and the numbers on top are the counts (352 for `temp_c`, 310 for `uv_index`). The bar chart ranks the columns by completeness but hides *where* the gaps are: `humidity` has one block of 45 missing days and `wind_kph` has 25 separate ones, and the bars cannot tell them apart. That is what the matrix is for.

## Which columns go missing together?

`msno.heatmap(df)` shows the correlation between the *missingness* of each pair of columns (not between their values). A value near 1 means that when one is missing, the other is too. A value near 0 means the gaps are unrelated:

```python
fig, ax = plt.subplots(figsize=(6.5, 5.5))
msno.heatmap(df, ax=ax, fontsize=11, cbar=False)
plt.show()
```

![Nullity correlation heatmap where humidity and pressure_hpa have a correlation of 1 and all other pairs are near 0](https://www.pythoncharts.com/python/missing-data-plots-python/images/missingno-heatmap.png)

`humidity` and `pressure_hpa` have a nullity correlation of 1, since they went offline together. Every other pair is close to 0 (the small cells that are labeled show about -0.1). The `uv_index` gaps do not correlate with any other column's gaps, even though they have a clear cause, because the cause is a *value* (hot weather) and not another gap. The heatmap cannot show that, so the section on dependence below checks it directly.

## Group columns by how they go missing

`msno.dendrogram(df)` clusters the columns hierarchically by their missing-value pattern. Columns that join at the far left of the tree (small distance) go missing together:

```python
fig, ax = plt.subplots(figsize=(8, 4.5))
msno.dendrogram(df, ax=ax, fontsize=11, orientation="left")
plt.show()
```

![Dendrogram joining humidity and pressure_hpa at zero distance, with the other four columns joining at larger distances](https://www.pythoncharts.com/python/missing-data-plots-python/images/missingno-dendrogram.png)

`humidity` and `pressure_hpa` join at a distance of 0, so they are interchangeable in terms of when they are missing. `temp_c`, `rain_mm` and `wind_kph` form a looser group of columns with a few random gaps, and `uv_index` joins last, since its pattern is unlike any other. On a table with 30 columns, this is the quickest way to find sets of columns that share a cause.

## Show only the worst columns or a slice of rows

A wide table makes the matrix unreadable. `filter="bottom"` with `n=3` keeps the three columns with the most missing values (`filter="top"` keeps the most complete ones instead). Adding `p=0.9` limits the choice to columns that are at most 90% complete. To zoom into a period, slice the DataFrame first:

```python
fig, axes = plt.subplots(1, 2, figsize=(11, 4), gridspec_kw={"width_ratios": [1, 1.4]})
msno.matrix(df, filter="bottom", n=3, ax=axes[0], sparkline=False, fontsize=10, color=(0.55, 0.42, 0.62))
axes[0].set_title("Three most incomplete columns", fontsize=11)
msno.matrix(df.loc["2025-04":"2025-07"], ax=axes[1], sparkline=False, fontsize=10, color=(0.55, 0.42, 0.62))
axes[1].set_title("April to July only", fontsize=11)
plt.show()
```

![Two nullity matrices: the three columns with most missing values for the whole year, and all columns for April to July only](https://www.pythoncharts.com/python/missing-data-plots-python/images/missingno-filter-slice.png)

The left panel keeps `humidity`, `pressure_hpa` and `uv_index`, the three columns with the most gaps. The right panel is the 122 days from April through July: the outage sits in the middle and the UV dropouts begin in May.

## Does the missingness depend on other values?

The matrix shows *where* data is missing, not *why*. If gaps cluster at certain values of another column, dropping or averaging them will bias the result. Compare a column's summary statistics for rows where another column is missing and where it is not:

```python
for col in ["uv_index", "wind_kph"]:
    gap = df[col].isna()
    print(f"{col:9} missing: mean temp {df.loc[gap, 'temp_c'].mean():.1f} C | present: {df.loc[~gap, 'temp_c'].mean():.1f} C")
```

```text
uv_index  missing: mean temp 21.1 C | present: 10.3 C
wind_kph  missing: mean temp 11.0 C | present: 12.0 C
```

Days with a missing UV reading average 21.1 °C, against 10.3 °C when it was recorded, so the UV gaps depend on temperature (in statistics terms the data is not missing completely at random). The wind gaps show no such link: 11.0 °C against 12.0 °C. If you filled the UV gaps with the column average, you would pull the summer values down, since the missing days are mostly hot, sunny ones. A model-based fill that uses temperature, or an explicit "missing" flag, would be safer.

## Missing data plot without missingno

If you cannot install a package, `df.isna()` is a boolean DataFrame, and `imshow` draws it. Grouping by month gives a more readable version for long time series: the share of missing values per column per month:

```python
share = df.isna().groupby(df.index.month).mean().T

fig, ax = plt.subplots(figsize=(9, 3.8))
im = ax.imshow(share, aspect="auto", cmap="Reds", vmin=0, vmax=1)
ax.set_xticks(range(12), ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
                          "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"])
ax.set_yticks(range(len(share)), share.index)
fig.colorbar(im, ax=ax, label="Share missing")
plt.show()
```

![Heatmap of the share of missing values per column per month, with humidity and pressure fully missing in May and partly in April and June](https://www.pythoncharts.com/python/missing-data-plots-python/images/missingno-monthly-share.png)

The outage is clear: `humidity` and `pressure_hpa` are 100% missing in May and 47% missing in June. `uv_index` is missing on 10% of days in May, climbing to 58% in July and falling back to 20% in September, which matches the hot-weather dropout. The scattered gaps in the other columns stay below about 15% in every month.

## missingno chart types compared

| Function | Shows | Use it to |
|---|---|---|
| `msno.matrix()` | Every cell, filled or empty | Find outages, gaps in time, shared patterns |
| `msno.bar()` | Count of present values per column | Rank columns by completeness |
| `msno.heatmap()` | Correlation of missingness between pairs | Find columns that fail together |
| `msno.dendrogram()` | Hierarchical clusters of missingness | The same, for many columns |

## Practical Tips

- **`matrix()` drops the column labels above 50 columns.** Its sparkline on the right counts the filled cells in each row. Pass `sparkline=False` to drop it, and `freq="ME"` (with a DatetimeIndex) to label the rows by month.
- **Complete columns are left out of the heatmap and dendrogram,** since their missingness has no variance. If `rain_mm` had no gaps at all, it would vanish from both charts.
- **The heatmap measures co-missingness, not cause.** A value of 1 says two columns are always missing together, which usually means one broken sensor or one skipped form section.
- **Every missingno function takes `ax=`,** so you can place them on a subplot grid. With `matrix()`, also pass `sparkline=False`, since the sparkline needs its own axes.
- **Check the missing share before choosing a fix.** A column that is 5% missing at random can be imputed. One that is 45% missing in a single block should probably be reported as a data gap.

## Similar Topics

- [Heatmaps in Seaborn](https://www.pythoncharts.com/seaborn/heatmaps-seaborn/)
- [Seasonal Decomposition in Python](https://www.pythoncharts.com/python/seasonal-decomposition-python/)
- [Dendrogram in Python](https://www.pythoncharts.com/python/dendrogram-python/)
