Melt a wide leaderboard into long rows and drop missing scores
Why it matters Long format is what plotting libraries, groupby and SQL loaders expect, and eval results usually arrive wide.
Leaderboards are stored wide, one column per benchmark, but plotting and joining need long rows. Models that skipped a benchmark have NaN there, and those cells should not become rows.
Write to_long(df) where df has a column model (str) and one float column per benchmark; cells may be NaN.
Return a DataFrame with columns exactly [model, benchmark, score], one row per non-missing cell, sorted by model then benchmark ascending, with a plain 0..n-1 index.
def to_long(df)Example
model ['a', 'b'], math [0.5, NaN], code [0.7, 0.9] gives model ['a', 'a', 'b'], benchmark ['code', 'math', 'code'], score [0.7, 0.5, 0.9].
Understand the idea
Wide data has one column per variable, like a spreadsheet with a column per benchmark. Long data has one row per observation: (model, benchmark, score). melt goes from wide to long; pivot goes back.
Worked example: row a has math 0.5 and code 0.7; row b has math NaN and code 0.9. melt gives four rows: (a, math, 0.5), (b, math, NaN), (a, code, 0.7), (b, code, 0.9). Dropping NaN leaves three, and sorting by model then benchmark gives (a, code, 0.7), (a, math, 0.5), (b, code, 0.9).
Rule: long = wide.melt(id_vars=[keys], var_name='variable', value_name='value'). The number of rows is keys x value columns before dropping missing cells.
Eval dashboards and experiment trackers store results long so new benchmarks need no new columns.