research/dfbnet/competitions.py
2024-11-30 09:57:00 +01:00

60 lines
1.7 KiB
Python

import pandas as pd
def get_teams_from_staffel(staffel=None):
dresden = pd.read_excel("data/beispiel_daten_dresden.xlsx")
# staffeln = dresden["STAFFEL"].unique()
if staffel:
teams_in_staffel = {}
teams = dresden[dresden["STAFFEL"] == staffel][
[
"MANNSCHAFT",
"MS_ART",
"SP_KLASSE",
"SCHLUESSEL_ZAHL",
"WUNSCH_WOCHENTAG",
"WUNSCH_TAG",
"WUNSCH_ZEIT",
"SPIELSTAETTE",
]
].to_dict(orient="records")
for t in teams:
if t['MANNSCHAFT'] not in teams_in_staffel:
teams_in_staffel[t['MANNSCHAFT']] = t
return teams_in_staffel
else:
staffeln = dresden["STAFFEL"].unique()
teams_in_staffel = {}
staffel_type = None
for staffel in staffeln:
find_duplicates = []
teams_in_staffel[staffel] = []
teams = dresden[dresden["STAFFEL"] == staffel][
[
"MANNSCHAFT",
"MS_ART",
"SP_KLASSE",
"SCHLUESSEL_ZAHL",
"WUNSCH_WOCHENTAG",
"WUNSCH_TAG",
"WUNSCH_ZEIT",
"SPIELSTAETTE",
]
].to_dict(orient="records")
for t in teams:
if t['MANNSCHAFT'] not in find_duplicates:
teams_in_staffel[staffel].append(t)
find_duplicates.append(t['MANNSCHAFT'])
return staffeln, teams_in_staffel