suazojaime / servel_elections_data

Data scraping for Chilean presidential elections

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

servel.py

Librarie servel.py provides a variety of functions to connect to servel.cl and get the data from last presidentail elections. The original data comes in json sintaxis but the functions from this library return pandas dataframes so its easy work with, e.g plot the data

  • servel.all_regions() gets the data from all regions by region
  • servel.get_region_code(region_name) gets the code that servel uses to identify that region in particular
  • servel.get_regiondata(region_name) gets the data from that region in particular
  • servel.get_comunas_by_region(region_name) gets a list of all the "comunas" inside that region in particular
  • servel.get_allcomunas() show a list of all "comunas" of the country
  • servel.get_comuna_code(comuna_name) gets the code that servel uses to identify that "comuna" in particular
  • servel.get_comunadata(comuna_name) gets the data from that comuna in particular
  • servel.get_allchile() gets the global results
  • servel.votes_by_region() gets the vote by region
  • servel.votes_by_comunas(region_name) gets the votes by "comuna" inside that region in particular

image

image

elections_data.py

this file contains the code that runs a tkinter app that allow the user to choose the region and "comuna" to get the data from, after that it plots the data as its shown below in the examples. The code its fairly simple and it runs after you choose the Region and the "comuna" and press "run".

examples:

image

image

image

image

image

About

Data scraping for Chilean presidential elections


Languages

Language:Python 100.0%