Agriculture · Beginner
Use 14 years of real WFP maize and bean prices to tell Kenyan farmers when to sell and show county officers which markets cost households most.
data/ folder of the Python Lab.Pamoja Agri-Advisory is a fictional Kenyan NGO that advises smallholder farmer groups and county food-security committees. Farmers keep asking one question: is it better to sell maize straight after harvest, or store it and sell a few months later? County officers ask another: which markets are always the most expensive for households? The NGO has no analyst yet, so they have asked you. You have one CSV of real monthly prices published by the World Food Programme (WFP): wholesale prices for a 90 KG bag of maize and beans in five big town markets, and retail prices per KG in nine county markets, from 2006 to 2019. The NGO is fictional; the prices are real.
Your role
Junior Data Analyst, Pamoja Agri-Advisory (fictional NGO)
Advice to farmers and county officers is based on stories, not numbers. Pamoja needs a simple, repeatable analysis of how maize prices move through the year and which markets are dearest, so its advisory calendar for next season rests on evidence.
Load food-prices-kenya.csv, turn the date column into real dates, add year and month columns, and fill the missing county and region for the market that has none.
Split the data into wholesale (per 90 KG bag) and retail (per KG) prices and never average them together. Add a price_per_kg column so you can compare what a trader pays per KG with what a household pays per KG.
One CSV file, food-prices-kenya.csv: 2,742 rows and 9 columns (182 KB). One row is the price of one commodity in one market for one month. Dates are the 15th of each month from January 2006 to December 2019. Prices are in Kenyan shillings (KES), with a US dollar version alongside. There are two kinds of price, and you must never mix them in one average: Wholesale prices are for a 90 KG bag, in Nairobi, Mombasa, Kisumu, Eldoret and Nakuru (maize and beans, 721 rows each; Nakuru starts in 2015). Retail prices are for 1 KG, in nine county markets: Garissa, Hola, Kajiado, Kilifi, Kitui, Lodwar, Mandera, Marigat and Marsabit (maize 955 rows; beans 345 rows in four of them). Five of the retail markets only start in 2015, so compare retail markets from 2015 to 2019. Source: WFP Kenya - Food Prices on the Humanitarian Data Exchange (HDX), licence CC BY-IGO 3.0, downloaded 24 October 2026. What we changed: the full file has 28,463 rows for dozens of foods, 2006 to 2026, and many markets with short or patchy records. We kept white maize and dry beans only, the markets above (which report almost every month for years), and 2006 to 2019, because from 2020 WFP switched to a different set of markets and names that do not line up with earlier years. We dropped ID, currency, flag and coordinate columns, renamed columns to snake_case and shortened market names (for example Eldoret town (Uasin Gishu) became Eldoret). Left for you to clean: Hola has no region or county in WFP's file (59 rows); it is in Tana River County, Coast.
food_prices_kenyaMonthly wholesale (90 KG bag) and retail (1 KG) prices of white maize and dry beans in 14 Kenyan markets, 2006 to 2019, from WFP via HDX (CC BY-IGO 3.0). · 2,742 rows
11 exercises worth 155 points. Your code runs in the Python Lab against this project’s data and is marked automatically.
Calculate the average wholesale maize price per bag for each year and the year-on-year change. Plot the yearly average as a line chart with the price in KES on the y-axis.
Average wholesale maize prices by month to find the seasonal pattern. Then compare each market's January and June price, year by year, to see how often storing maize for five months paid off.
Compare average retail maize prices across the nine county markets for 2015 to 2019, then rank the markets within each year. Write your note for Pamoja with advice backed by your numbers.
| Column | Type | Description | Example |
|---|---|---|---|
date | date | Month of the price, recorded as the 15th of the month (YYYY-MM-DD). | 2017-06-15 |
region | text | Former province the market is in, as recorded by WFP. Missing for Hola. | Rift Valley |
county | text | County the market is in. Missing for Hola (Tana River County). | Turkana |
market | text | Market (town) where the price was collected. | Lodwar |
commodity | text | Maize (white, dry grain) or Beans (dry). | Maize |
price_type | text | Wholesale (a 90 KG bag, what traders pay) or Retail (1 KG, what households pay). | Wholesale |
unit | text | Quantity the price is for: 90 KG for wholesale rows, KG for retail rows. | 90 KG |
price_kes | decimal | Price in Kenyan shillings for the quantity in unit. | 3150.0 |
price_usd | decimal | The same price converted to US dollars by WFP at that month's exchange rate. | 30.53 |
The exercises are marked automatically. The notebook and note are marked on whether every comparison is like-for-like (same commodity, price type and unit), whether each chart has a title, units and a one-line takeaway, and whether the advice follows from the numbers and mentions limits such as storage costs.
Recommended tools
Skills covered