jarajpu commited on
Commit
e0d7127
·
1 Parent(s): 36b88a5

enhanced admin panel

Browse files
Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -349,13 +349,23 @@ ADMIN_PASSPHRASE = "admin123"
349
 
350
 
351
  def fetch_latest_predictions(match_id):
352
- dataset = load_dataset("Jay-Rajput/DIS_IPL_Dataset", name="predictions")
353
- # Convert to pandas DataFrame
 
 
354
  df = pd.DataFrame(dataset)
355
- # Remove duplicate rows
356
- df_unique = df.drop_duplicates(subset=['user_name'])
357
- predictions = df_unique['train'].filter(lambda example: example['match_id'] == match_id)
358
- return predictions
 
 
 
 
 
 
 
 
359
 
360
 
361
  def save_match_outcomes(outcomes):
@@ -369,7 +379,7 @@ def update_leaderboard_and_outcomes(match_id, winning_team, man_of_the_match):
369
 
370
  outcomes = load_data(OUTCOMES_JSON) # Load existing match outcomes
371
  # Load existing match outcomes and user data from the test split
372
- dataset = load_dataset("Jay-Rajput/DIS_IPL_Dataset", name="leaders")
373
  users = pd.DataFrame(dataset)
374
 
375
  # Directly update or add the match outcome
 
349
 
350
 
351
  def fetch_latest_predictions(match_id):
352
+ # Load the dataset. Adjust "split" to "train" or appropriate if "predictions" is a configuration.
353
+ dataset = load_dataset("Jay-Rajput/DIS_IPL_Dataset", "predictions", split='train')
354
+
355
+ # Convert the dataset to a pandas DataFrame
356
  df = pd.DataFrame(dataset)
357
+
358
+ # Ensure the DataFrame is not empty and contains the required columns
359
+ if not df.empty and {'user_name', 'match_id'}.issubset(df.columns):
360
+ # Filter rows by 'match_id'
361
+ filtered_df = df[df['match_id'] == match_id]
362
+
363
+ # Drop duplicate rows based on 'user_name'
364
+ unique_df = filtered_df.drop_duplicates(subset=['user_name'])
365
+
366
+ return unique_df
367
+ else:
368
+ return pd.DataFrame()
369
 
370
 
371
  def save_match_outcomes(outcomes):
 
379
 
380
  outcomes = load_data(OUTCOMES_JSON) # Load existing match outcomes
381
  # Load existing match outcomes and user data from the test split
382
+ dataset = load_dataset("Jay-Rajput/DIS_IPL_Dataset", "leaders", split='train')
383
  users = pd.DataFrame(dataset)
384
 
385
  # Directly update or add the match outcome