.. _f-elections: module ``special.elections`` ============================ .. inheritance-diagram:: ensae_teaching_cs.special.elections Short summary +++++++++++++ module ``ensae_teaching_cs.special.elections`` Contains a class to process elections results (France) :githublink:`%|py|6` Classes +++++++ +--------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ | class | truncated documentation | +================================================================================+=======================================================================================================================================================+ | :class:`ElectionResults ` | Processes data coming from `data.gouv.fr `_. ... | +--------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ Properties ++++++++++ +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+ | property | truncated documentation | +=======================================================================================+===============================================================================+ | :meth:`Level ` | Returns the level (``département`` or ``canton``). | +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+ | :meth:`LevelCol ` | Returns the column associated to the level (their name depends on the level). | +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+ | :meth:`T0 ` | Returns the dataframe for the first round. | +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+ | :meth:`T1 ` | Returns the dataframe for the second round. | +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+ | :meth:`WeightsNorm ` | Returns the proportion of voters for each regions. | +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+ | :meth:`Year ` | Returns the year. | +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+ Static Methods ++++++++++++++ +-------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------+ | staticmethod | truncated documentation | +=======================================================================================================+========================================================================+ | :meth:`combine_into_string ` | Combines two matrices into one before displaying it. | +-------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------+ | :meth:`min_max_mean_std ` | returns the mean standard deviation, bounds of the confidence interval | +-------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------+ Methods +++++++ +---------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+ | method | truncated documentation | +=========================================================================================================+===========================================================================================================================================================+ | :py:meth:`__init__ ` | Loads the data downloaded from `data.gouv.fr `_. ... | +---------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+ | :py:meth:`__str__ ` | usual | +---------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+ | :meth:`bootstrap ` | Uses the bootstrap method to compute confidence intervals see `bootstrap `_. ... | +---------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+ | :meth:`correct ` | Corrects the second round in a way there is the same number of voters. | +---------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+ | :meth:`get_candidates_votes ` | Returns the numbers of voters for each candidate. | +---------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+ | :meth:`get_people ` | Returns the number of people per regions. | +---------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+ | :meth:`GetNbCandidates ` | Returns the number of candidates. | +---------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+ | :meth:`process_tour ` | Keeps the interesting columns, move candidates name as column name. | +---------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+ | :meth:`resample ` | Builds a new sample: it produces a results with the same number of rows, but each rows is randomly drawn from the ... | +---------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+ | :meth:`vote_transfer ` | Computes the votes between the two rounds using contrainsts optimization, the optimization requires :epkg:`cvxopt`. ... | +---------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+ Documentation +++++++++++++ .. automodule:: ensae_teaching_cs.special.elections :members: :special-members: __init__ :show-inheritance: