Update app.py
Browse files
app.py
CHANGED
|
@@ -44,6 +44,8 @@ st.markdown("""
|
|
| 44 |
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
| 45 |
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
| 46 |
animation: slideInUp 0.5s ease-in-out;
|
|
|
|
|
|
|
| 47 |
}
|
| 48 |
.team-card:hover {
|
| 49 |
transform: scale(1.1) rotate(2deg);
|
|
@@ -104,9 +106,24 @@ st.markdown("""
|
|
| 104 |
batting_path = "Batting_10_Teams_Final.csv"
|
| 105 |
bowling_path = "Bowling_10_Teams_Final.csv"
|
| 106 |
|
| 107 |
-
# Load datasets
|
| 108 |
-
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
# Title
|
| 112 |
st.markdown('<h1 class="title">BowLChaL</h1>', unsafe_allow_html=True)
|
|
@@ -119,17 +136,35 @@ st.markdown('<div class="team-container">', unsafe_allow_html=True)
|
|
| 119 |
row1 = st.columns(5)
|
| 120 |
for i, t in enumerate(teams[:5]):
|
| 121 |
with row1[i]:
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
st.session_state['selected_team'] = t
|
| 124 |
-
st.markdown(f'<div class="team-card">{t}</div>', unsafe_allow_html=True)
|
| 125 |
|
| 126 |
# Second row (5 teams)
|
| 127 |
row2 = st.columns(5)
|
| 128 |
for i, t in enumerate(teams[5:10]):
|
| 129 |
with row2[i]:
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
st.session_state['selected_team'] = t
|
| 132 |
-
st.markdown(f'<div class="team-card">{t}</div>', unsafe_allow_html=True)
|
| 133 |
|
| 134 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 135 |
|
|
|
|
| 44 |
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
| 45 |
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
| 46 |
animation: slideInUp 0.5s ease-in-out;
|
| 47 |
+
border: none;
|
| 48 |
+
cursor: pointer;
|
| 49 |
}
|
| 50 |
.team-card:hover {
|
| 51 |
transform: scale(1.1) rotate(2deg);
|
|
|
|
| 106 |
batting_path = "Batting_10_Teams_Final.csv"
|
| 107 |
bowling_path = "Bowling_10_Teams_Final.csv"
|
| 108 |
|
| 109 |
+
# Load datasets with caching
|
| 110 |
+
@st.cache_data
|
| 111 |
+
def load_data(batting_path, bowling_path):
|
| 112 |
+
try:
|
| 113 |
+
batting_df = pd.read_csv(batting_path)
|
| 114 |
+
bowling_df = pd.read_csv(bowling_path)
|
| 115 |
+
return batting_df, bowling_df
|
| 116 |
+
except FileNotFoundError:
|
| 117 |
+
st.error("Data files not found. Please check file paths.")
|
| 118 |
+
st.stop()
|
| 119 |
+
|
| 120 |
+
# Load data
|
| 121 |
+
batting_df, bowling_df = load_data(batting_path, bowling_path)
|
| 122 |
+
|
| 123 |
+
# Data validation
|
| 124 |
+
if batting_df.empty or bowling_df.empty:
|
| 125 |
+
st.warning("No data available in the datasets")
|
| 126 |
+
st.stop()
|
| 127 |
|
| 128 |
# Title
|
| 129 |
st.markdown('<h1 class="title">BowLChaL</h1>', unsafe_allow_html=True)
|
|
|
|
| 136 |
row1 = st.columns(5)
|
| 137 |
for i, t in enumerate(teams[:5]):
|
| 138 |
with row1[i]:
|
| 139 |
+
# Use a custom HTML button with the team-card class
|
| 140 |
+
button_html = f"""
|
| 141 |
+
<form>
|
| 142 |
+
<button class="team-card" type="submit" name="team_button" value="{t}">
|
| 143 |
+
{t}
|
| 144 |
+
</button>
|
| 145 |
+
</form>
|
| 146 |
+
"""
|
| 147 |
+
st.markdown(button_html, unsafe_allow_html=True)
|
| 148 |
+
# Check if this button was clicked
|
| 149 |
+
if st.session_state.get('team_button') == t:
|
| 150 |
st.session_state['selected_team'] = t
|
|
|
|
| 151 |
|
| 152 |
# Second row (5 teams)
|
| 153 |
row2 = st.columns(5)
|
| 154 |
for i, t in enumerate(teams[5:10]):
|
| 155 |
with row2[i]:
|
| 156 |
+
# Use a custom HTML button with the team-card class
|
| 157 |
+
button_html = f"""
|
| 158 |
+
<form>
|
| 159 |
+
<button class="team-card" type="submit" name="team_button" value="{t}">
|
| 160 |
+
{t}
|
| 161 |
+
</button>
|
| 162 |
+
</form>
|
| 163 |
+
"""
|
| 164 |
+
st.markdown(button_html, unsafe_allow_html=True)
|
| 165 |
+
# Check if this button was clicked
|
| 166 |
+
if st.session_state.get('team_button') == t:
|
| 167 |
st.session_state['selected_team'] = t
|
|
|
|
| 168 |
|
| 169 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 170 |
|