Examples

Single Dances

Following Wikipedia, we can obtain places for the following results after judging:

Results with a Clear Majority for Each Place

With judges as A,...,E and competitors 11, 12 and 13, we have the following places:

CompetitorABCDE
1111212
1222131
1333323

We create a DataFrame with these results

results = DataFrame(Number = [11, 12, 13],
        JudgeA = [1, 2, 3],
        JudgeB = [1, 2, 3],
        JudgeC = [2, 1, 3],
        JudgeD = [1, 3, 2],
        JudgeE = [2, 1, 3])

and obtain the final results by

calculation, places = skating_single_dance(results)

The output contains the full calculation as a dataframe

calculation
3×5 DataFrame
RowNumber1-11-21-3Place
StringStringStringStringString
1113*--1
21224*-2
313015*3

as well as just the places:

places
3×2 DataFrame
RowNumberPlace
Int64Float64
1111.0
2122.0
3133.0

No Majority

With the following judgements

CompetitorABCDE
1111223
1222112
1333331

we obtain

results = DataFrame(Number = [11, 12, 13],
        JudgeA = [1, 2, 3],
        JudgeB = [1, 2, 3],
        JudgeC = [2, 1, 3],
        JudgeD = [2, 1, 3],
        JudgeE = [3, 2, 1])
calculation, places = skating_single_dance(results)
calculation
3×5 DataFrame
RowNumber1-11-21-3Place
StringStringStringStringString
11124*-2
21225*-1
313115*3

Shared Places and Wins with 2nd Place

CompetitorABCDE
1111334
1222222
1333411
1444143

gives

results = DataFrame(Number = [11, 12, 13, 14],
        JudgeA = [1, 2, 3, 4],
        JudgeB = [1, 2, 3, 4],
        JudgeC = [3, 2, 4, 1],
        JudgeD = [3, 2, 1, 4],
        JudgeE = [4, 2, 1, 3])
calculation, places = skating_single_dance(results)
calculation
4×6 DataFrame
RowNumber1-11-21-31-4Place
StringStringStringStringStringString
111224*(8)5*(12)2.5
21205*--1
313224*(8)5*(12)2.5
4141125*4

Multiple Dances

1st Example

The following examples are from the TSO Homepage (in German).

Assume we have a tournament with the following dances

  • Waltz (abbreviated W)
  • Tango (T)
  • Viennese Waltz (V)
  • Slowfox (S)
  • Quickstep (Q)

and the following individual placements from the judges:

Nr.W-AW-BW-CW-DW-ET-AT-BT-CT-DT-EV-AV-BV-CV-DV-ES-AS-BS-CS-DS-EQ-AQ-BQ-CQ-DQ-E
251125312234112232251526261
352252553122321121125215152
454531131313533615632332424
553363644441266343313651513
656614425555445566466444636
755446266666654454544163345

We set up the results as follows:

dances = ["Waltz", "Tango", "Viennese Waltz", "Slowfox", "Quickstep"]

resultsW = DataFrame(Number = [25, 35, 45, 55, 65, 75],
    JudgeA = [1, 2, 4, 3, 6, 5],
    JudgeB = [1, 2, 5, 3, 6, 4],
    JudgeC = [2, 5, 3, 6, 1, 4],
    JudgeD = [5, 2, 1, 3, 4, 6],
    JudgeE = [3, 5, 1, 6, 4, 2])

resultsT = DataFrame(Number = [25, 35, 45, 55, 65, 75],
    JudgeA = [1, 5, 3, 4, 2, 6],
    JudgeB = [2, 3, 1, 4, 5, 6],
    JudgeC = [2, 1, 3, 4, 5, 6],
    JudgeD = [3, 2, 1, 4, 5, 6],
    JudgeE = [4, 2, 3, 1, 5, 6])

resultsV = DataFrame(Number = [25, 35, 45, 55, 65, 75],
    JudgeA = [1, 3, 5, 2, 4, 6],
    JudgeB = [1, 2, 3, 6, 4, 5],
    JudgeC = [2, 1, 3, 6, 5, 4],
    JudgeD = [2, 1, 6, 3, 5, 4],
    JudgeE = [3, 2, 1, 4, 6, 5])

resultsS = DataFrame(Number = [25, 35, 45, 55, 65, 75],
    JudgeA = [2, 1, 5, 3, 6, 4],
    JudgeB = [2, 1, 6, 3, 4, 5],
    JudgeC = [5, 2, 3, 1, 6, 4],
    JudgeD = [1, 5, 2, 3, 6, 4],
    JudgeE = [5, 2, 3, 6, 4, 1])

resultsQ = DataFrame(Number = [25, 35, 45, 55, 65, 75],
    JudgeA = [2, 1, 3, 5, 4, 6],
    JudgeB = [6, 5, 2, 1, 4, 3],
    JudgeC = [2, 1, 4, 5, 6, 3],
    JudgeD = [6, 5, 2, 1, 3, 4],
    JudgeE = [1, 2, 4, 3, 6, 5])

results = [resultsW, resultsT, resultsV, resultsS, resultsQ]

We calculate the final result by

places_text, rule10_11, reports, places = skating_combined(dances, results)

We can see the final placement in the places DataFrame:

places
6×2 DataFrame
RowNumberPlace
Int64Float64
1252.0
2351.0
3453.0
4554.0
5656.0
6755.0

The calculation of the sum of the individual places can be found in the first return value

places_text
6×8 DataFrame
RowNumberWaltzTangoViennese WaltzSlowfoxQuickstepSumPlace
StringStringStringStringStringStringStringString
1251.01.01.52.02.07.52
2352.02.01.51.01.07.51
3453.03.03.04.04.017.03
4554.04.04.03.03.018.04
5655.05.05.56.06.027.56
6756.06.05.55.05.027.55

In this example, Rule 11 needed to be applied. The separate calculations are reported for Rule 10 in

rule10_11[1]
6×8 DataFrame
RowNumber1-11-21-31-41-51-6Place
StringStringStringStringStringStringStringString
125-------
235-------
345-------
455-------
565-------
675-------

and for Rule 11 in

rule10_11[2]
6×8 DataFrame
RowNumber1-11-21-31-41-51-6Place
StringStringStringStringStringStringStringString
125716*----2
235717*----1
345-------
455-------
565----17*(68)-6
675----17*(66)-5

Finally, reports contains the calculations for the individual dances (similar to the first section).

2nd Example

Consider the following results

Nr.W-AW-BW-CW-DW-ET-AT-BT-CT-DT-EV-AV-BV-CV-DV-ES-AS-BS-CS-DS-EQ-AQ-BQ-CQ-DQ-E
272252512234111113313626261
373363631313234561125244636
474531125555345624544115152
571125344441456235632363345
676614466666522342251551514
775446253122663456466432423

We set up and run the calculations:

dances = ["Waltz", "Tango", "Viennese Waltz", "Slowfox", "Quickstep"]

resultsW = DataFrame(Number = [27, 37, 47, 57, 67, 77],
        JudgeA = [2, 3, 4, 1, 6, 5],
        JudgeB = [2, 3, 5, 1, 6, 4],
        JudgeC = [5, 6, 3, 2, 1, 4],
        JudgeD = [2, 3, 1, 5, 4, 6],
        JudgeE = [5, 6, 1, 3, 4, 2])

    resultsT = DataFrame(Number = [27, 37, 47, 57, 67, 77],
        JudgeA = [1, 3, 2, 4, 6, 5],
        JudgeB = [2, 1, 5, 4, 6, 3],
        JudgeC = [2, 3, 5, 4, 6, 1],
        JudgeD = [3, 1, 5, 4, 6, 2],
        JudgeE = [4, 3, 5, 1, 6, 2])

    resultsV = DataFrame(Number = [27, 37, 47, 57, 67, 77],
        JudgeA = [1, 2, 3, 4, 5, 6],
        JudgeB = [1, 3, 4, 5, 2, 6],
        JudgeC = [1, 4, 5, 6, 2, 3],
        JudgeD = [1, 5, 6, 2, 3, 4],
        JudgeE = [1, 6, 2, 3, 4, 5])

    resultsS = DataFrame(Number = [27, 37, 47, 57, 67, 77],
        JudgeA = [3, 1, 4, 5, 2, 6],
        JudgeB = [3, 1, 5, 6, 2, 4],
        JudgeC = [1, 2, 4, 3, 5, 6],
        JudgeD = [3, 5, 4, 2, 1, 6],
        JudgeE = [6, 2, 1, 3, 5, 4])

    resultsQ = DataFrame(Number = [27, 37, 47, 57, 67, 77],
        JudgeA = [2, 4, 1, 6, 5, 3],
        JudgeB = [6, 4, 5, 3, 1, 2],
        JudgeC = [2, 6, 1, 3, 5, 4],
        JudgeD = [6, 3, 5, 4, 1, 2],
        JudgeE = [1, 6, 2, 5, 4, 3])

results = [resultsW, resultsT, resultsV, resultsS, resultsQ]
places_text, rule10_11, reports, places = skating_combined(dances, results)

We obtain the following final places

places_text
6×8 DataFrame
RowNumberWaltzTangoViennese WaltzSlowfoxQuickstepSumPlace
StringStringStringStringStringStringStringString
1272.01.01.03.02.09.01
2374.03.04.01.06.018.02
3473.05.04.05.01.018.03
4571.04.04.04.05.018.04
5675.06.02.02.04.019.05
6776.02.06.06.03.023.06

Calculations for Rule 10:

rule10_11[1]
6×8 DataFrame
RowNumber1-11-21-31-41-51-6Place
StringStringStringStringStringStringStringString
127-------
237-------
347--2---3
457--1----
567-------
677-------

...and for Rule 11:

rule10_11[2]
6×8 DataFrame
RowNumber1-11-21-31-41-51-6Place
StringStringStringStringStringStringStringString
127-------
237-715*---2
347-81015*---
457-61218*---
567-------
677-------