Generation

generate functionWed, 01 Feb 2023

There is a Pandas dataframe: song performer chart_debut peak_position worst_position time_on_chart consecutive_weeks 261636 Stupid Cupid Connie Francis 1958-08-02 17 72 12 11.0 46383 Chantilly Lace Big Bopper 1958-08-02 6 40 18 17.0 46384 Chantilly Lace Big Bopper 1958-08-02 6 40 19 18.0 46385 Chantilly Lace Big Bopper 1958-08-02 6 40 20 19.0 46386 Chantilly Lace Big Bopper 1958-08-02 6 40 21 20.0 Leave only 1 unique row in each 'song' column in case the 'peak_position' column has a value of 1

df.groupby('song').first().reset_index()

Questions about programming?Chat with your personal AI assistant