Spaces:
Sleeping
Sleeping
jarajpu
commited on
Commit
·
5e636bc
1
Parent(s):
7254a2f
Adding fix
Browse files- app.py +39 -39
- leaders/users.json +13 -13
- match_outcomes.json +15 -0
- users.json +13 -13
app.py
CHANGED
|
@@ -266,56 +266,56 @@ def display_predictions():
|
|
| 266 |
st.write("No predictions for today's matches yet.")
|
| 267 |
|
| 268 |
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
#
|
| 274 |
-
|
| 275 |
|
| 276 |
-
#
|
| 277 |
-
|
| 278 |
|
| 279 |
-
#
|
| 280 |
-
|
| 281 |
|
| 282 |
-
#
|
| 283 |
-
|
| 284 |
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
|
| 289 |
|
| 290 |
-
def display_leaderboard():
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
|
| 307 |
-
|
| 308 |
-
|
| 309 |
|
| 310 |
-
|
| 311 |
-
|
| 312 |
|
| 313 |
-
|
| 314 |
-
|
| 315 |
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
|
| 320 |
|
| 321 |
# Streamlit UI
|
|
|
|
| 266 |
st.write("No predictions for today's matches yet.")
|
| 267 |
|
| 268 |
|
| 269 |
+
def display_leaderboard():
|
| 270 |
+
if st.button("Show Leaderboard"):
|
| 271 |
+
try:
|
| 272 |
+
users = load_users(USERS_JSON)
|
| 273 |
+
# Convert the dataset to a pandas DataFrame
|
| 274 |
+
df_users = pd.DataFrame([{'User': key, 'Points': value} for key, value in users.items()])
|
| 275 |
|
| 276 |
+
# Sort DataFrame by points in descending order
|
| 277 |
+
leaderboard = df_users.sort_values(by='Points', ascending=False).reset_index(drop=True)
|
| 278 |
|
| 279 |
+
# Add a 'Rank' column starting from 1
|
| 280 |
+
leaderboard['Rank'] = leaderboard.index + 1
|
| 281 |
|
| 282 |
+
# Reorder DataFrame columns so 'Rank' is first
|
| 283 |
+
df_leaderboard = leaderboard[['Rank', 'User', 'Points']]
|
| 284 |
|
| 285 |
+
st.dataframe(df_leaderboard, hide_index=True)
|
| 286 |
+
except FileNotFoundError:
|
| 287 |
+
st.write("Leaderboard data not available.")
|
| 288 |
|
| 289 |
|
| 290 |
+
# def display_leaderboard():
|
| 291 |
+
# if st.button("Show Leaderboard"):
|
| 292 |
+
# try:
|
| 293 |
+
# # Load the 'leaders' configuration or split from your dataset
|
| 294 |
+
# dataset = load_dataset("Jay-Rajput/DIS_IPL_Dataset", "leaders", split='train')
|
| 295 |
+
# # Convert the dataset to a pandas DataFrame
|
| 296 |
+
# df_users = pd.DataFrame(dataset)
|
| 297 |
|
| 298 |
+
# # Transform the DataFrame to have 'user_name' and 'points' columns
|
| 299 |
+
# # Since your JSON structure is quite unique, this step may need adjustment based on how the DataFrame is loaded
|
| 300 |
+
# users_data = []
|
| 301 |
+
# for column in df_users.columns:
|
| 302 |
+
# points = df_users[column].iloc[0] # Assuming the first (and only) row contains the points for each user
|
| 303 |
+
# users_data.append({'User': column, 'Points': points})
|
| 304 |
+
|
| 305 |
+
# df_leaderboard = pd.DataFrame(users_data)
|
| 306 |
|
| 307 |
+
# # Sort DataFrame by points in descending order
|
| 308 |
+
# df_leaderboard = df_leaderboard.sort_values(by='Points', ascending=False)
|
| 309 |
|
| 310 |
+
# # Add a 'Rank' column starting from 1
|
| 311 |
+
# df_leaderboard['Rank'] = range(1, len(df_leaderboard) + 1)
|
| 312 |
|
| 313 |
+
# # Select and order the columns for display
|
| 314 |
+
# df_leaderboard = df_leaderboard[['Rank', 'User', 'Points']]
|
| 315 |
|
| 316 |
+
# st.dataframe(df_leaderboard, hide_index=True)
|
| 317 |
+
# except Exception as e:
|
| 318 |
+
# st.write("Failed to load leaderboard data: ", str(e))
|
| 319 |
|
| 320 |
|
| 321 |
# Streamlit UI
|
leaders/users.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
| 1 |
{
|
| 2 |
"Arpit": 10100,
|
| 3 |
"Ganesh": 8151,
|
| 4 |
-
"Haaris":
|
| 5 |
-
"Jay":
|
| 6 |
-
"Kishore":
|
| 7 |
-
"Megha":
|
| 8 |
-
"Naveein":
|
| 9 |
-
"Neha":
|
| 10 |
-
"Praveen":
|
| 11 |
-
"Rakesh":
|
| 12 |
-
"Sai":
|
| 13 |
-
"Sahil":
|
| 14 |
-
"Sunil":
|
| 15 |
-
"Vaibhav":
|
| 16 |
-
"Vinay":
|
| 17 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"Arpit": 10100,
|
| 3 |
"Ganesh": 8151,
|
| 4 |
+
"Haaris": 15100,
|
| 5 |
+
"Jay": 7700,
|
| 6 |
+
"Kishore": 8700,
|
| 7 |
+
"Megha": 11250,
|
| 8 |
+
"Naveein": 8000,
|
| 9 |
+
"Neha": 7600,
|
| 10 |
+
"Praveen": 17100,
|
| 11 |
+
"Rakesh": 7300,
|
| 12 |
+
"Sai": 9984,
|
| 13 |
+
"Sahil": 9550,
|
| 14 |
+
"Sunil": 7689,
|
| 15 |
+
"Vaibhav": 7999,
|
| 16 |
+
"Vinay": 7900
|
| 17 |
}
|
match_outcomes.json
CHANGED
|
@@ -48,5 +48,20 @@
|
|
| 48 |
"match_id": "20240329_10",
|
| 49 |
"winning_team": "KKR",
|
| 50 |
"man_of_the_match": "Sunil Narine"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
}
|
| 52 |
]
|
|
|
|
| 48 |
"match_id": "20240329_10",
|
| 49 |
"winning_team": "KKR",
|
| 50 |
"man_of_the_match": "Sunil Narine"
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"match_id": "20240330_11",
|
| 54 |
+
"winning_team": "LSG",
|
| 55 |
+
"man_of_the_match": "Mayank Yadav"
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"match_id": "20240331_12",
|
| 59 |
+
"winning_team": "GT",
|
| 60 |
+
"man_of_the_match": "Mohit Sharma"
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"match_id": "20240331_13",
|
| 64 |
+
"winning_team": "DC",
|
| 65 |
+
"man_of_the_match": "Khaleel Ahmed"
|
| 66 |
}
|
| 67 |
]
|
users.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
| 1 |
{
|
| 2 |
"Arpit": 10100,
|
| 3 |
"Ganesh": 8151,
|
| 4 |
-
"Haaris":
|
| 5 |
-
"Jay":
|
| 6 |
-
"Kishore":
|
| 7 |
-
"Megha":
|
| 8 |
-
"Naveein":
|
| 9 |
-
"Neha":
|
| 10 |
-
"Praveen":
|
| 11 |
-
"Rakesh":
|
| 12 |
-
"Sai":
|
| 13 |
-
"Sahil":
|
| 14 |
-
"Sunil":
|
| 15 |
-
"Vaibhav":
|
| 16 |
-
"Vinay":
|
| 17 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"Arpit": 10100,
|
| 3 |
"Ganesh": 8151,
|
| 4 |
+
"Haaris": 15100,
|
| 5 |
+
"Jay": 7700,
|
| 6 |
+
"Kishore": 8700,
|
| 7 |
+
"Megha": 11250,
|
| 8 |
+
"Naveein": 8000,
|
| 9 |
+
"Neha": 7600,
|
| 10 |
+
"Praveen": 17100,
|
| 11 |
+
"Rakesh": 7300,
|
| 12 |
+
"Sai": 9984,
|
| 13 |
+
"Sahil": 9550,
|
| 14 |
+
"Sunil": 7689,
|
| 15 |
+
"Vaibhav": 7999,
|
| 16 |
+
"Vinay": 7900
|
| 17 |
}
|