rcv.tables.RCV_tables¶
- class rcv.tables.RCV_tables¶
Bases:
objectExtra methods added into RCV class
- __init__()¶
Methods
__init__()get_candidate_details_table([tabulation_num])Generate table of candidate round by round vote counts.
Returns a two condorcet tables as a pandas data frame with candidate names as row and column indices.
Return cumulative ranking tables.
Create a pandas dataframe describing the first choice candidate distribution and which finalist candidate those ballots ended the tabulation allocated to.
Return pandas dataframes containing first and second choice candidate distributions across ballots.
get_round_by_round_dict([tabulation_num])Create a dictionary containing election round by round information that matches the nesting structure of RCVIS upload format.
get_round_by_round_table([tabulation_num])Create a table containing round by round details for the tabulation.
Measure where winners ranked on ballots that ended up in their final pile.
- get_candidate_details_table(tabulation_num: int = 1) DataFrame | None¶
Generate table of candidate round by round vote counts.
- Parameters:
tabulation_num (int, optional) – tabulation num, defaults to 1
- Return type:
Optional[pd.DataFrame]
- get_condorcet_tables() Tuple[DataFrame | str | None]¶
Returns a two condorcet tables as a pandas data frame with candidate names as row and column indices. One contains counts and the other contains percents. Also return the name of the condorcet winner, or None.
Each cell indicates the count/percentage of ballots that ranked the row-candidate over the column-candidate (including ballots that only ranked the row-candidate). When calculating percents, the denominator is each cell is the number of ballots that ranked the row-candidate OR the column-candidate.
Symmetric cells about the diagonal should sum to 100 (for the percent table).
Ballots used in condorcet calculation have election rules applied to them.
- Returns:
Tuple containing count table, percent table, and name of condorcet winner.
- Return type:
Tuple[Union[pd.DataFrame, Optional[str]]]
- get_cumulative_ranking_tables() Tuple[DataFrame]¶
Return cumulative ranking tables. Rows are candidate names and columns are rank numbers. Reading across columns, the tables show the accumulating count/percentage of ballots that marked a candidate as more ranks are considered. The final column shows the count/percentage of ballots that never marked the candidate. Ballots used for calculation have election rules applied to them.
- Returns:
Tuple containing count table and percentage table
- Return type:
Tuple[pd.DataFrame]
- get_first_choice_to_finalist_table(tabulation_num: int = 1) DataFrame¶
Create a pandas dataframe describing the first choice candidate distribution and which finalist candidate those ballots ended the tabulation allocated to.
- Parameters:
tabulation_num (int, optional) – tabulation number, defaults to 1
- Returns:
table
- Return type:
pd.DataFrame
- get_first_second_tables() Tuple[DataFrame]¶
Return pandas dataframes containing first and second choice candidate distributions across ballots. The first row of the table contains the first choice distribution. The following rows in each column indicate the second choice distribution for only the ballots in each first choice ballot pile. Percentages in the first row should sum to 100, and each column below the first row should sum to 100. Ballots used for calculation have election rules applied to them.
Three versions of the dataframe are returned: one containing ballot counts and two containing ballot percentages. Two percentage dataframes are included, one with an exhaustion category for second choices and one without.
- Returns:
Tuple containing count table, percentage table, and percentage table without exhausted second choices
- Return type:
Tuple[pd.DataFrame]
- get_round_by_round_dict(tabulation_num: int = 1) Dict¶
Create a dictionary containing election round by round information that matches the nesting structure of RCVIS upload format.
- Parameters:
tabulation_num (int, optional) – tabulation number, defaults to 1
- Returns:
Dictionary containing election round by round details
- Return type:
Dict
- get_round_by_round_table(tabulation_num: int = 1) DataFrame¶
Create a table containing round by round details for the tabulation.
- Parameters:
tabulation_num (int, optional) – tabulation number, defaults to 1
- Returns:
round by round table
- Return type:
pd.DataFrame
- get_winner_final_pile_rank_distribution_table(tabulation_num: int = 1) DataFrame | None¶
Measure where winners ranked on ballots that ended up in their final pile. Only applicable for single winner elections.
- Parameters:
tabulation_num (int, optional) – Tabulation number (only applies to Sequential), defaults to 1
- Returns:
A single row dataframe with contest details and counts of winner final ballots across ranking positions.
- Return type:
Optional[pd.DataFrame]