prepare_missing_values_graph
prepare_missing_values_graph(df, ts_id, *, no_factors=False, binary=False)Heatmap of missing-value frequency by variable and time period.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| df | pd.DataFrame | Data frame containing the data. | required |
| ts_id | str | Column indicating the time dimension (coercible to an ordered factor); must not contain missing values. | required |
| 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 |
|---|---|---|
| plotly.graph_objects.Figure | The missing-values heatmap. |
Examples
Basic — fraction of missing values by variable and year (this function returns a Plotly figure directly, so there is no .fig attribute):
import expdpy as ex
from expdpy.data import load_kuznets
df = load_kuznets()
ex.prepare_missing_values_graph(df, ts_id="year")Advanced — restrict to numeric variables and show only whether values are missing:
ex.prepare_missing_values_graph(df, ts_id="year", no_factors=True, binary=True)