Back to index
Project 07 March 2020 Scraping · Network Graphs · Selenium

Peruvian party switching: ideologists or opportunists?

Analyzing tendencies in party switching among 2020 Peruvian parliamentary candidates — a Selenium-based crawler, network graphs, and a sankey diagram.

Flag of Peru

For the course Computer Science for Public Policy at the University of Chicago, my team and I built a data-driven study of candidate behavior in Peru's 2020 parliamentary elections. We were curious: do candidates change parties out of conviction, or out of convenience?

Data collection

We built a Selenium-based crawler to scrape the Jurado Nacional de Elecciones website, collecting political candidate profiles — prior party affiliations, income, criminal record disclosures, and region of candidacy.

Methodology

We visualized party-switching histories with a network graph (edges = transitions between parties) and a sankey diagram tracing candidates' paths over successive elections. We then looked for correlations between switching behavior and candidate attributes — wealth, criminal-record flags, and regional Gini index.

Selected visualizations

Alianza por el Progreso network graph
Fig. 1 — Alianza por el Progreso · network of transitions
Solidaridad Nacional income overlay
Fig. 2 — Solidaridad Nacional · candidates by declared income
Somos Peru with Gini index
Fig. 3 — Somos Perú · candidates overlaid against regional Gini index

Team & code

Built with Andrei Bartra, Angelo Cozzubo, and Marc Richardson. The repository — including the scraper, cleaning pipeline, and visualization code — is here.

Return to main