Premium problem87. Tracks in the Top Ten

Easy Locked

songs has columns track, position, date and country. The same track charts on many days and in many countries, so it appears repeatedly.

Return the tracks that reached a position of 1 through 10 inclusive, one row per track, as a DataFrame with columns track and position holding that track's best (lowest) qualifying position. Sort by position ascending and then track alphabetically, and renumber the index from 0.

Input

    track  position        date country
0    Halo         3  2021-01-01      US
1    Halo         7  2021-01-02      GB
2  Royals         1  2021-01-01      US
3   Creep        12  2021-01-01      US
4   Creep         4  2021-01-03      GB
5    Blue        10  2021-01-02      US

Output

    track  position
0  Royals         1
1    Halo         3
2   Creep         4
3    Blue        10

Premium problem

This one's part of Premium. Unlock the full Pandas track plus every other premium problem on the site.

Implement solve(...)