Abhishek Thakur commited on
Commit
48a5e54
·
1 Parent(s): 53034cd
Files changed (1) hide show
  1. competitions/submissions.py +29 -15
competitions/submissions.py CHANGED
@@ -248,26 +248,40 @@ class Submissions:
248
  first_submission = submissions_df.iloc[0]
249
  if isinstance(first_submission["public_score"], dict):
250
  # split the public score dict into columns
251
- public_score_df = pd.DataFrame.from_dict(first_submission["public_score"], orient="index")
252
- public_score_df = public_score_df.transpose()
253
- public_score_df.columns = [f"public_score_{col}" for col in public_score_df.columns]
254
- submissions_df = submissions_df.drop(columns=["public_score"])
255
- submissions_df = pd.concat([submissions_df, public_score_df], axis=1)
 
 
 
 
256
  else:
257
  first_submission = submissions_df.iloc[0]
258
  if isinstance(first_submission["private_score"], dict):
259
- private_score_df = pd.DataFrame.from_dict(first_submission["private_score"], orient="index")
260
- private_score_df = private_score_df.transpose()
261
- private_score_df.columns = [f"private_score_{col}" for col in private_score_df.columns]
262
- submissions_df = submissions_df.drop(columns=["private_score"])
263
- submissions_df = pd.concat([submissions_df, private_score_df], axis=1)
 
 
 
 
 
264
 
265
  if isinstance(first_submission["public_score"], dict):
266
- public_score_df = pd.DataFrame.from_dict(first_submission["public_score"], orient="index")
267
- public_score_df = public_score_df.transpose()
268
- public_score_df.columns = [f"public_score_{col}" for col in public_score_df.columns]
269
- submissions_df = submissions_df.drop(columns=["public_score"])
270
- submissions_df = pd.concat([submissions_df, public_score_df], axis=1)
 
 
 
 
 
271
 
272
  return submissions_df
273
 
 
248
  first_submission = submissions_df.iloc[0]
249
  if isinstance(first_submission["public_score"], dict):
250
  # split the public score dict into columns
251
+ temp_scores_df = submissions_df["public_score"].apply(pd.Series)
252
+ temp_scores_df = temp_scores_df.rename(columns=lambda x: "public_" + str(x))
253
+ submissions_df = pd.concat(
254
+ [
255
+ submissions_df.drop(["public_score"], axis=1),
256
+ temp_scores_df,
257
+ ],
258
+ axis=1,
259
+ )
260
  else:
261
  first_submission = submissions_df.iloc[0]
262
  if isinstance(first_submission["private_score"], dict):
263
+ # split the public score dict into columns
264
+ temp_scores_df = submissions_df["private_score"].apply(pd.Series)
265
+ temp_scores_df = temp_scores_df.rename(columns=lambda x: "private_" + str(x))
266
+ submissions_df = pd.concat(
267
+ [
268
+ submissions_df.drop(["private_score"], axis=1),
269
+ temp_scores_df,
270
+ ],
271
+ axis=1,
272
+ )
273
 
274
  if isinstance(first_submission["public_score"], dict):
275
+ # split the public score dict into columns
276
+ temp_scores_df = submissions_df["public_score"].apply(pd.Series)
277
+ temp_scores_df = temp_scores_df.rename(columns=lambda x: "public_" + str(x))
278
+ submissions_df = pd.concat(
279
+ [
280
+ submissions_df.drop(["public_score"], axis=1),
281
+ temp_scores_df,
282
+ ],
283
+ axis=1,
284
+ )
285
 
286
  return submissions_df
287