import expdpy as ex
from expdpy.data import load_kuznets, load_kuznets_data_def
df = ex.set_labels(load_kuznets(), load_kuznets_data_def(), set_panel=True)
ex.explore_missing_values_plot(df).figexplore_missing_values_plot
explore_missing_values_plot(
df,
*,
time=None,
entity=None,
by='time',
no_factors=False,
binary=False,
title=None,
subtitle=None,
)Heatmap of missing-value frequency by variable and panel dimension.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| df | pd.DataFrame | Data frame containing the data. | required |
| time | str | None | Time identifier column. Defaults to the panel time declared via :func:expdpy.set_panel. Required when by="time"; must not contain missing values. |
None |
| entity | str | None | Cross-sectional (unit) identifier column. Defaults to the panel entity. Required when by="entity"; must not contain missing values. |
None |
| by | Literal['time', 'entity'] | Whether to aggregate missingness over "time" periods (the default) or over "entity" units. |
'time' |
| no_factors | bool | If True, limit the plot to numeric/logical variables. |
False |
| binary | bool | If True, show only whether values are missing (any) rather than the fraction. |
False |
Returns
| Name | Type | Description |
|---|---|---|
| MissingValuesResult | df (the missingness matrix, rows = levels, columns = variables) and fig. |
Examples
Basic — fraction of missing values by variable and year:
Advanced — missingness by unit, restricted to numeric variables, shown as a flag:
import expdpy as ex
from expdpy.data import load_kuznets, load_kuznets_data_def
df = ex.set_labels(load_kuznets(), load_kuznets_data_def(), set_panel=True)
ex.explore_missing_values_plot(
df, by="entity", no_factors=True, binary=True
).fig