module data.elections
¶
Short summary¶
module actuariat_python.data.elections
Various function to download data about French elections.
Classes¶
class |
truncated documentation |
---|---|
Functions¶
function |
truncated documentation |
---|---|
Retrieves data from Résultat des élections législatives françaises de 2012 au niveau bureau de vote. … |
|
Retrieves data from Countours des circonscriptions des législatives. … |
|
Downloads the data for the French elections from data.gouv.fr. |
|
Returns the list of files included in this module about French elections. |
|
Scrapes and extracts addresses for every vote place (bureau de vote in French). |
|
Retrieves data vote places (bureaux de vote in French) with geocodes. |
|
Given a piece of HTML, return the plain text it contains. This handles entities and char refs, but not javascript and … |
|
Retrieves data vote places (bureaux de vote in French) with geocodes. |
Methods¶
method |
truncated documentation |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
Documentation¶
Various function to download data about French elections.
-
class
actuariat_python.data.elections.
_HTMLToText
¶ Bases :
html.parser.HTMLParser
Initialize and reset this instance.
If convert_charrefs is True (the default), all character references are automatically converted to the corresponding Unicode characters.
-
__init__
()¶ Initialize and reset this instance.
If convert_charrefs is True (the default), all character references are automatically converted to the corresponding Unicode characters.
-
-
actuariat_python.data.elections.
_elections_vote_place_address_patterns_
()¶
-
actuariat_python.data.elections.
elections_legislatives_bureau_vote
(source=None, folder='.', fLOG=<function noLOG>)¶ Retrieves data from Résultat des élections législatives françaises de 2012 au niveau bureau de vote.
- Paramètres
source – should be None unless you want to use the backup plan (« xd »)
folder – where to download
- Renvoie
list of dataframe
Others sources:
-
actuariat_python.data.elections.
elections_legislatives_circonscription_geo
(source='xd', folder='.', fLOG=<function noLOG>)¶ Retrieves data from Countours des circonscriptions des législatives.
- Paramètres
source – should be None unless you want to use the backup plan (« xd »)
folder – where to download
- Renvoie
list of dataframe
-
actuariat_python.data.elections.
elections_presidentielles
(url=None, local=False, agg=None)¶ Downloads the data for the French elections from data.gouv.fr.
- Paramètres
url – url (None for default value)
local – prefer local data instead of remote
agg – kind of aggregation desired (see below)
- Renvoie
dictionaries of DataFrame (one entry for each round)
The default url comes from Elections présidentielle 2012 - Résultats. You can get more at Elections présidentielles 1965-2012.
If url is None, we pull some data from folder data/election.
Parameter agg:
circ or None for no aggregation
dep to aggregate per department
-
actuariat_python.data.elections.
elections_presidentielles_local_files
(load=False)¶ Returns the list of files included in this module about French elections.
- Paramètres
load – True: load the data
- Renvoie
list of local files
If the data is loaded, the function returns a dictionary of dataframe, one per round.
-
actuariat_python.data.elections.
elections_vote_place_address
(folder='.', hide_warning=False, fLOG=<function noLOG>)¶ Scrapes and extracts addresses for every vote place (bureau de vote in French).
- Paramètres
folder – where to download the scraped pages
hide_warnings – hide warnings
fLOG – logging function
- Renvoie
dictionary
The function does not retrieve everything due to the irregular format. Sometimes, the city is missing or written above.
-
actuariat_python.data.elections.
elections_vote_places_geo
(source='xd', folder='.', fLOG=<function noLOG>)¶ Retrieves data vote places (bureaux de vote in French) with geocodes.
- Paramètres
source – should be None unless you want to use the backup plan (« xd »)
folder – where to download
fLOG – logging function
- Renvoie
list of dataframe
-
actuariat_python.data.elections.
html_to_text
(html)¶ Given a piece of HTML, return the plain text it contains. This handles entities and char refs, but not javascript and stylesheets.
-
actuariat_python.data.elections.
villes_geo
(folder='.', as_df=False, fLOG=<function noLOG>)¶ Retrieves data vote places (bureaux de vote in French) with geocodes.
- Paramètres
folder – where to download
as_df – return as a dataframe
fLOG – logging function
- Renvoie
list of dataframe