Tools

Analysing the data with Python and pandas

Load the published CSV straight from its address, check it, filter, reshape, summarise and plot — with a reproducible script.

Intermediate · about 15 minutes · reviewed 2026-11-25

You need Python 3 with pandas and matplotlib (pip install pandas matplotlib). Any notebook (Jupyter, Google Colab) or a plain script works.

1. Load the data and check it

import hashlib
import urllib.request

import pandas as pd

URL = "https://rescuedatalabs.org/files/south-sudan-wdi-indicators/1.0/observations.csv"

# Download once, keep the file, and check it is the published one.
raw = urllib.request.urlopen(URL).read()
print("SHA-256:", hashlib.sha256(raw).hexdigest())  # compare with the checksum on the site
with open("observations.csv", "wb") as f:
    f.write(raw)

df = pd.read_csv("observations.csv")
print(df.shape)
print(df.dtypes)
print(df["indicator_id"].value_counts())

Always look before you analyse: number of rows, column types, which indicators and years are present, and any missing values (df.isna().sum()).

2. Filter one indicator

pop = df[df["indicator_id"] == "pop-total"].sort_values("year")
print(pop[["year", "value"]].to_string(index=False))

3. Reshape to one column per indicator

wide = df.pivot(index="year", columns="indicator_id", values="value")
print(wide[["health-infant-mortality", "health-child-mortality"]])

pivot fails if a year appears twice for the same indicator — a useful check that the data has one value per indicator and year.

4. Change over time

pop = pop.set_index("year")["value"]
change = pd.DataFrame({
    "value": pop,
    "absolute_change": pop.diff(),
    "percent_change": pop.pct_change() * 100,
})
print(change.round(1))

Missing years stay missing (NaN). Do not fill them with zero.

5. Plot it

import matplotlib.pyplot as plt

ax = pop.plot(marker="o")
ax.set_title("Total population, South Sudan — World Bank estimates")
ax.set_xlabel("Year")
ax.set_ylabel("People")
ax.set_ylim(bottom=0)  # an honest axis for totals
ax.figure.text(0.01, 0.01, "Source: World Bank WDI via Rescue Data Labs, v1.0", fontsize=8)
plt.tight_layout()
plt.savefig("population.png", dpi=150)

6. Use the metadata and feeds

import json
meta = json.load(urllib.request.urlopen("https://rescuedatalabs.org/indicators.json"))

/catalog.json, /indicators.json and /data/<dataset>/metadata.json describe datasets, sources, licences, versions and checksums (see Downloading data).

Make it reproducible

  • Keep the script, the downloaded file and its checksum together.
  • Pin the version in the URL; never point a published analysis at “whatever is latest”.
  • Write down every transformation (see Preparing data for research).

Was this guide useful?

Tell us what was clear, unclear or missing. The link opens an email with the guide's address filled in — nothing else is sent, and nothing is recorded on this site.

Send feedback on this guide Suggest another guide