Rename your columns to match the expected names:
time_periodlocationdisease_casesFor a complete example of a valid Chap CSV, see the Laos dengue dataset. In addition to the required columns, this file also includes the optional covariate columns: population, location_name, rainfall, mean_temperature, and mean_relative_humidity.
Convert your dates to the correct format:
YYYY-MM (e.g. 2023-01, 2023-12)YYYY-Wnn (e.g. 2023-W01, 2023-W52)All time periods must be consecutive with no gaps. Every location must have data for every time period in the dataset.
If you want spatial visualizations, create a GeoJSON file where each feature’s identifier matches the location values in your CSV. Name the GeoJSON file with the same base name as your CSV (e.g. my_data.csv and my_data.geojson) for automatic discovery.
import pandas as pd
# Suppose you have a DataFrame with different column names
df = pd.DataFrame({
"date": ["2023-01-01", "2023-02-01", "2023-01-01", "2023-02-01"],
"region": ["Region_A", "Region_A", "Region_B", "Region_B"],
"cases": [12, 8, 30, 22],
"rain_mm": [37.9, 8.5, 55.3, 12.1],
})
# Rename columns to match Chap format
df = df.rename(columns={
"region": "location",
"cases": "disease_cases",
"rain_mm": "rainfall",
})
# Convert dates to YYYY-MM format
df["time_period"] = pd.to_datetime(df["date"]).dt.strftime("%Y-%m")
df = df.drop(columns=["date"])
# Reorder columns
df = df[["time_period", "rainfall", "disease_cases", "location"]]
An example of how to do this with climate tools is here.