Spaces:
Herc
/
Runtime error

BBallv5 / app.py
Herc's picture
Create app.py
09cb456
raw
history blame
2.14 kB
import streamlit as st
import pandas as pd
from datetime import date, timedelta
import random
# Functions for schedule generation and date assignment are as defined earlier
def create_schedule(num_teams, num_conferences, num_inter_games):
"""Create the entire schedule based on user inputs."""
full_schedule = []
# Generate schedule for each conference
for i in range(num_conferences):
conference_name = chr(65 + i) # 'A', 'B', 'C', 'D', ...
combined_schedule = combine_schedules(conference_name, num_teams, num_inter_games)
schedule_with_dates = assign_dates_to_matches_v2(combined_schedule)
for match in schedule_with_dates:
full_schedule.append({
"Team 1": match[0],
"Team 2": match[1],
"Date": match[2]
})
return pd.DataFrame(full_schedule)
# Streamlit App
st.title("Basketball Game Schedule Generator")
# Configuration UI
st.header("Configuration")
num_teams = st.number_input("Number of teams per conference:", min_value=2, value=10)
num_conferences = st.number_input("Number of conferences:", min_value=2, value=4)
num_inter_games = st.number_input("Number of inter-conference games per team:", min_value=1, value=3)
commissioners = st.multiselect("Add commissioners:", options=[], default=[])
add_commissioner = st.text_input("New commissioner name:")
if add_commissioner:
commissioners.append(add_commissioner)
# Schedule Generation
if st.button("Generate Schedule"):
global schedule_df
schedule_df = create_schedule(num_teams, num_conferences, num_inter_games)
# Schedule Viewing
st.header("View Schedule")
conference_selector = st.selectbox("Select conference to view schedule:", options=["All"] + [f"Conference {chr(65+i)}" for i in range(num_conferences)])
if conference_selector == "All":
st.dataframe(schedule_df)
else:
filtered_schedule = schedule_df[(schedule_df["Team 1"].str.startswith(conference_selector)) | (schedule_df["Team 2"].str.startswith(conference_selector))]
st.dataframe(filtered_schedule)
# Export functionality can be added later