The Problem
Property listings in Nairobi are a mess. Prices are inconsistent ("45k", "Ksh 45,000", "45000"), bedroom counts are buried in random text ("2br", "2 bed", "Two Bedroom"), and the data is scattered across various sites. If you're trying to figure out where you can afford to live—or just analyzing the market—you'll spend more time cleaning data than actually using it.
What This Does
This repo is a full pipeline for scraping, cleaning, and analyzing Nairobi property data. The scrapelistings.py script pulls raw data from websites, dumping it into allrawlistings.csv. From there, cleanproperties.py handles price normalization and bedroom extraction using hardcoded logic in parser.py (no fancy machine learning, just regex and string parsing that actually works). The cleaned output lands in cleanedproperties.csv.
Once the data is usable, scripts like buildsummary.py and eda.py generate insights: average prices, price-per-bedroom, and location summaries (locationsummaryclean.csv). The real cherry on top is the interactive map (nairobiaffordabilitymap.html), built using Nairobi's geoJSON boundaries (nairobicounty.geojson). It visualizes affordability metrics by neighborhood.
Bonus: the repo includes a bunch of pre-generated charts in the charts/ folder, so you don’t have to set up matplotlib just to see results.
Real-World Use
Imagine you're moving to Nairobi and need a 2-bedroom place under 50k Ksh/month. Run the pipeline, then filter cleanedproperties.csv or explore the nairobiaffordabilitymap.html to quickly find affordable neighborhoods.
Or, maybe you're a data analyst working on urban planning. Use the location summary data (locationsummaryclean.csv) to identify rental hotspots or compare premium vs. affordable areas.
Want to hack on it? Extend the scraper (nairobipropertyscraper_v2.py) to include more websites or tweak parser.py to handle even messier input.
The Bottom Line
This repo does what it says: it turns Nairobi's chaotic property data into something useful. The code is Python-heavy and a bit procedural, but it's clear and easy to follow. If you're working with Nairobi real estate data, this is a solid starting point. Just know you'll likely want to tweak things—it’s not plug-and-play for non-technical users.