jontingvold / pyrankvote

PyRankVote is a python library for different ranked-choice voting systems, like IRV, STV and PBV. Created in June 2019.
MIT License
53 stars 16 forks source link

Ballots formatted with numbers #4

Closed ikatza closed 4 years ago

ikatza commented 4 years ago

Hi, great project! thanks for doing this.

I ran an STV election and the outcome is a csv file with a table like this:

A B C
1 2 3
2 3 1
3 1 2
3 2 1
2 1 3

Is there a straightforward way in this project to use that table as input or convert it to the expected input:

ballots = [
    Ballot(ranked_candidates=[A, B, C]),
    Ballot(ranked_candidates=[C, A, B]),
    Ballot(ranked_candidates=[B, C, A]),
    Ballot(ranked_candidates=[C, B, A]),
    Ballot(ranked_candidates=[B, A, C])
]
ikatza commented 4 years ago

Well I've managed to scratch my back for this one, a quick gist: https://gist.github.com/ikatza/c4f8ad349af740787de8d13fb0f1e5f3

jontingvold commented 4 years ago

I'm sorry. It is not a straightforward way to convert from that table format.

I see most users of the library have formats like these, so I will put on the todo list. 😀