If you want to see what imibare gives you, load a dataset and inspect it. This tutorial installs the package, reads Rwanda’s monthly Consumer Price Index (CPI), and plots the general index.
Before you start
You need Python 3.11 or later and pip, which comes with most Python installations. We install
matplotlib with the package because you will use it for the final chart.
Install the package
Run this in a terminal:
pip install imibare matplotlib
The install is complete when pip reports that it installed imibare. You only need to run this
command once for an environment.
Load the Consumer Price Index
Create a Python file, or use an interactive Python session, and run:
import imibare as imi
df = imi.load("rw.nisr.cpi.monthly")
print(df.head())
imi.load() returns a pandas DataFrame. It downloads the current Parquet file from the API on the
first call, then keeps a local copy under ~/.imibare/cache/ so another call within an hour does
not download it again.
The first rows will look broadly like this:
date category value
0 2009-02-01 alcoholic_beverages_and_tobacco 87.380474
1 2009-02-01 bread_and_cereals 92.058744
2 2009-02-01 clothing_and_footwear 83.509793
The exact newest rows change when NISR publishes an update. The column names and the meaning of the data stay documented on the dataset page.
Check what you loaded
Before plotting a dataset, inspect its shape and the values that identify each series. This CPI dataset is in long format: 1 row for each category in each month.
print(df.dtypes)
print(df.shape)
print(df["category"].nunique())
print(sorted(df["category"].unique())[:4])
You should find 3 columns: date, category, and value. There are 18 CPI categories, so the
row count grows by 18 whenever NISR adds a month; pandas 2 may display category as object
rather than str.
Plot the general index
The headline CPI series is general_index_(cpi). Filter to it before plotting, because the other
17 categories are components rather than duplicate observations of the same series.
import matplotlib.pyplot as plt
general = df[df["category"] == "general_index_(cpi)"].sort_values("date")
plt.figure(figsize=(12, 4))
plt.plot(general["date"], general["value"], linewidth=1.5)
plt.title("Rwanda CPI, general index (2014 = 100)")
plt.xlabel("Date")
plt.ylabel("Index value")
plt.tight_layout()
plt.savefig("rw_cpi.png", dpi=150)
plt.show()
This saves rw_cpi.png and opens the chart when your environment supports it. The line stays near
100 through 2014 because the series uses 2014 as its base year, so a value of 241 means prices
were about 2.4 times their 2014 level.
Find another dataset
Use imi.catalog() when you know the country but not the ID. The returned records include the ID,
institution, coverage, columns, source, and pipeline label for each dataset.
datasets = imi.catalog(country="RW")
for dataset in datasets[:5]:
print(f"{dataset.id:45s} {dataset.name}")
Change country="RW" to country="KE" for Kenya. You can also browse the full catalog
and copy an ID from a dataset page.
Keep going
You now have a real DataFrame, a chart, and a way to find the next dataset. These are the common next steps:
- Load exchange rates:
imi.load("rw.bnr.fx.daily") - Load Kenyan CPI:
imi.load("ke.knbs.cpi.monthly") - Limit a date range:
imi.load("rw.nisr.cpi.monthly", start="2020-01", end="2023-12") - Return a Polars DataFrame:
imi.load("rw.nisr.cpi.monthly", engine="polars") - Check every parameter: Python package reference
If you prefer SQL, DuckDB can read the same file directly. The DuckDB guide shows the URL pattern and several queries.