Rakshitjan commited on
Commit
10db18a
·
verified ·
1 Parent(s): 8ca33c0

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +19 -0
main.py CHANGED
@@ -504,6 +504,25 @@ async def get_sorted_scores(data: CoachingCodeRequest):
504
  merged_data = pd.merge(merged_journal_panic, test_df_processed, on='user_id', how='outer')
505
  merged_data_cleaned = merged_data.dropna(subset=['productivity_yes_no', 'productivity_rate', 'panic_button', 'test_chapter'], how='all')
506
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
507
  # Define scoring weights
508
  academic_weights = {'BACKLOGS': -5, 'MISSED CLASSES': -4, 'NOT UNDERSTANDING': -3, 'BAD MARKS': -3, 'LACK OF MOTIVATION': -3}
509
  non_academic_weights = {'EMOTIONAL FACTORS': -3, 'PROCRASTINATE': -2, 'LOST INTEREST': -4, 'LACK OF FOCUS': -2, 'GOALS NOT ACHIEVED': -2, 'LACK OF DISCIPLINE': -2}
 
504
  merged_data = pd.merge(merged_journal_panic, test_df_processed, on='user_id', how='outer')
505
  merged_data_cleaned = merged_data.dropna(subset=['productivity_yes_no', 'productivity_rate', 'panic_button', 'test_chapter'], how='all')
506
 
507
+ def process_group(group):
508
+ # Panic button counts
509
+ panic_button_series = group['panic_button'].dropna()
510
+ panic_button_dict = panic_button_series.value_counts().to_dict()
511
+
512
+ # Test scores aggregation
513
+ test_scores = group[['test_chapter', 'test_score']].dropna()
514
+ test_scores['test_score'] = pd.to_numeric(test_scores['test_score'], errors='coerce')
515
+
516
+ # Create the test_scores_dict excluding NaN values
517
+ test_scores_dict = test_scores.groupby('test_chapter')['test_score'].mean().dropna().to_dict()
518
+
519
+ return pd.Series({
520
+ 'productivity_yes_no': group['productivity_yes_no'].iloc[0],
521
+ 'productivity_rate': group['productivity_rate'].iloc[0],
522
+ 'panic_button': panic_button_dict,
523
+ 'test_scores': test_scores_dict
524
+ })
525
+
526
  # Define scoring weights
527
  academic_weights = {'BACKLOGS': -5, 'MISSED CLASSES': -4, 'NOT UNDERSTANDING': -3, 'BAD MARKS': -3, 'LACK OF MOTIVATION': -3}
528
  non_academic_weights = {'EMOTIONAL FACTORS': -3, 'PROCRASTINATE': -2, 'LOST INTEREST': -4, 'LACK OF FOCUS': -2, 'GOALS NOT ACHIEVED': -2, 'LACK OF DISCIPLINE': -2}