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 Pandas dataframe is available: song artist 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 Write a function that will group all rows by the performer column (so that no duplicates are left), and all corresponding (unique) values to that column are written through the "," sign into a new hits column. All values of both time_on_chart and consecutive_weeks columns must be summed if the performer value matches.

def group_by_performer(df): pass

Questions about programming?Chat with your personal AI assistant