FunctionRacerProblemsRace

Top of the Curve

MediumstatsmodelsPython

df has columns x and y, and y follows a curve that bends once: up then down, or down then up. Fit y on x and x squared with a statsmodels formula, and return the x where the fitted curve turns around.

Example 1

df {"x":[0,1,2,3,4,5,6],"y":[0,5,8,9,8,5,0]}
returns 3.0

The points follow 9 - (x - 3) squared, which peaks at x = 3.

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