Brazilian Election Polls Tracker 2010–2026
Interactive dashboard that collects 1,370 opinion polls from 52 pollsters with a Python web crawler and shows how vote intentions changed in every Brazilian election from 2010 to 2026.
Context
Election polls in Brazil are spread across news sites, pollster releases and Wikipedia tables. Each one is a single snapshot, so it's hard to see the trend over the campaign, compare pollsters or check which ones got the result right. Nothing brought 16 years of polls together in one view.
The challenge
Build a pipeline that collects historical and current polls automatically and normalizes them into a single format, even though every source uses different candidate names, date formats and table layouts. The data then had to feed a lightweight dashboard that works on phones, covering president (1st and 2nd round), governor and senator in all 27 states.
What was built
- Wrote a Python web crawler that scrapes the historical polling tables (2010, 2014, 2018 and 2022) and news sources for 2026.
- Cleaned and normalized the data: pollster names, fieldwork dates, sample sizes, undecided/blank votes and hypothetical runoff scenarios.
- Handled edge cases such as 2026's two-seat Senate race, where the two votes are rescaled to 100% and pollsters that publish raw sums are excluded.
- Built the front end with D3.js: each poll is a point, a smoothed average line runs through them, and a band shows the spread between pollsters. A marker on election day shows the official result.
- Added a comparison of the final polling average against the actual result, plus a ranking of which pollsters came closest, based on mean absolute error.
- Delivered it as a single self-contained HTML file with light and dark themes and a responsive layout.
Outcome
- 1,370 polls from 52 pollsters in one place: 708 presidential polls across 5 elections and 662 state-level polls for governor and senator in all 27 states.
- Shows how accurate each pollster was. For example, in the 2022 runoff the best pollster missed by an average of just 0.19 points.
- Lightweight, with no backend, and published at danillogomes.com/urna.
Technologies
Python · Web Scraping · BeautifulSoup · Pandas · D3.js · JavaScript · HTML · CSS
Links
Gallery


Next project: Code Forge RPG