Spaces:
Sleeping
Sleeping
Commit
·
1356e88
1
Parent(s):
82f926c
Updated leads repo
Browse files
app.py
CHANGED
|
@@ -269,53 +269,31 @@ def display_predictions():
|
|
| 269 |
def display_leaderboard():
|
| 270 |
if st.button("Show Leaderboard"):
|
| 271 |
try:
|
| 272 |
-
|
|
|
|
| 273 |
# Convert the dataset to a pandas DataFrame
|
| 274 |
-
df_users = pd.DataFrame(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
|
|
|
|
|
|
|
| 276 |
# Sort DataFrame by points in descending order
|
| 277 |
-
|
| 278 |
|
| 279 |
# Add a 'Rank' column starting from 1
|
| 280 |
-
|
| 281 |
|
| 282 |
-
#
|
| 283 |
-
df_leaderboard =
|
| 284 |
|
| 285 |
st.dataframe(df_leaderboard, hide_index=True)
|
| 286 |
-
except
|
| 287 |
-
st.write("
|
| 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_Leads", 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
|
|
|
|
| 269 |
def display_leaderboard():
|
| 270 |
if st.button("Show Leaderboard"):
|
| 271 |
try:
|
| 272 |
+
# Load the 'leaders' configuration or split from your dataset
|
| 273 |
+
dataset = load_dataset("Jay-Rajput/DIS_IPL_Leads", split='train')
|
| 274 |
# Convert the dataset to a pandas DataFrame
|
| 275 |
+
df_users = pd.DataFrame(dataset)
|
| 276 |
+
|
| 277 |
+
# Transform the DataFrame to have 'user_name' and 'points' columns
|
| 278 |
+
users_data = []
|
| 279 |
+
for column in df_users.columns:
|
| 280 |
+
points = df_users[column].iloc[0] # Assuming the first (and only) row contains the points for each user
|
| 281 |
+
users_data.append({'User': column, 'Points': points})
|
| 282 |
|
| 283 |
+
df_leaderboard = pd.DataFrame(users_data)
|
| 284 |
+
|
| 285 |
# Sort DataFrame by points in descending order
|
| 286 |
+
df_leaderboard = df_leaderboard.sort_values(by='Points', ascending=False)
|
| 287 |
|
| 288 |
# Add a 'Rank' column starting from 1
|
| 289 |
+
df_leaderboard['Rank'] = range(1, len(df_leaderboard) + 1)
|
| 290 |
|
| 291 |
+
# Select and order the columns for display
|
| 292 |
+
df_leaderboard = df_leaderboard[['Rank', 'User', 'Points']]
|
| 293 |
|
| 294 |
st.dataframe(df_leaderboard, hide_index=True)
|
| 295 |
+
except Exception as e:
|
| 296 |
+
st.write("Failed to load leaderboard data: ", str(e))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
|
| 298 |
|
| 299 |
# Streamlit UI
|