albertvillanova HF staff commited on
Commit
1582397
1 Parent(s): 045a182

Rename functions

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -52,16 +52,16 @@ def load_data(result_path) -> pd.DataFrame:
52
  def load_result(model_id):
53
  result_path = get_result_path_from_model(model_id, latest_result_path_per_model)
54
  data = load_data(result_path)
55
- df = to_dataframe_all(data)
56
  result = [
57
  to_vertical(df),
58
- to_vertical(to_dataframe_results(df))
59
  ]
60
  return result
61
 
62
 
63
- def to_dataframe(data):
64
- return pd.DataFrame.from_records([data])
65
 
66
 
67
  def to_vertical(df):
@@ -71,7 +71,7 @@ def to_vertical(df):
71
  return df
72
 
73
 
74
- def to_dataframe_all(data):
75
  df = pd.json_normalize([{key: value for key, value in data.items() if key not in EXCLUDED_KEYS}])
76
  # df.columns = df.columns.str.split(".") # .split return a list instead of a tuple
77
  df.columns = list(map(lambda x: tuple(x.split(".")), df.columns))
@@ -98,7 +98,7 @@ def to_dataframe_all(data):
98
  # return pd.concat(dfs.values(), axis="columns")
99
 
100
 
101
- def to_dataframe_results(df):
102
  df = df.loc[:, df.columns.str[0] == "results"]
103
  df = df.loc[:, ~df.columns.str[1].isin(EXCLUDED_RESULTS_KEYS)]
104
  df = df.loc[:, ~df.columns.str[2].isin(EXCLUDED_RESULTS_LEADERBOARDS_KEYS)]
 
52
  def load_result(model_id):
53
  result_path = get_result_path_from_model(model_id, latest_result_path_per_model)
54
  data = load_data(result_path)
55
+ df = to_dataframe(data)
56
  result = [
57
  to_vertical(df),
58
+ to_vertical(filter_results(df))
59
  ]
60
  return result
61
 
62
 
63
+ # def to_dataframe(data):
64
+ # return pd.DataFrame.from_records([data])
65
 
66
 
67
  def to_vertical(df):
 
71
  return df
72
 
73
 
74
+ def to_dataframe(data):
75
  df = pd.json_normalize([{key: value for key, value in data.items() if key not in EXCLUDED_KEYS}])
76
  # df.columns = df.columns.str.split(".") # .split return a list instead of a tuple
77
  df.columns = list(map(lambda x: tuple(x.split(".")), df.columns))
 
98
  # return pd.concat(dfs.values(), axis="columns")
99
 
100
 
101
+ def filter_results(df):
102
  df = df.loc[:, df.columns.str[0] == "results"]
103
  df = df.loc[:, ~df.columns.str[1].isin(EXCLUDED_RESULTS_KEYS)]
104
  df = df.loc[:, ~df.columns.str[2].isin(EXCLUDED_RESULTS_LEADERBOARDS_KEYS)]