FunctionRacerProblemsRace

Group Gaps

EasystatsmodelsPython

df has columns team (a name) and score. Fit score ~ C(team) with a statsmodels formula: the intercept becomes the mean of the alphabetically first team and every other team gets its gap to it. Return the parameters as a dict (the keys are the names statsmodels gives them).

Example 1

df {"team":["a","a","b","b","c","c"],"score":[1,3,6,8,2,2]}
returns {"Intercept":2.0,"C(team)[T.b]":5.0,"C(team)[T.c]":0.0}

Team a averages 2. Team b averages 7, which is 5 more, and team c averages the same as a.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More statsmodels problems