Generation

generate functionWed, 01 Feb 2023

There is a Pandas dataframe: performer hits chart_debut time_on_chart consecutive_weeks decade num_of_hits 3428 Glee Cast Somebody To Love, Friday, Loser Like Me, Baby,... 2009 290 47.0 2000-2010 191 8478 Taylor Swift Fifteen, Fearless, London Boy, Teardrops On My... 2008 14299 11880.0 2000-2010 166 2543 Drake Summer Sixteen, The Language, Weston Road Flow... 2016 7449 6441.0 2010-2020 125 10397 YoungBoy Never Broke Again Kacey Talk, Put It On Me, Dirty Iyanna, Lil To... 2020 1012 625.0 2020-2030 75 458 Aretha Franklin Chain Of Fools, My Song, Respect, Until You Co... 1967 3490 2921.0 1960-1970 66 8625 The Beatles Sgt. Pepper's Lonely Hearts Club Band/With A L... 1978 3548 2798.0 1970-1980 66 Write a function year_leaders that will build a new dataframe and leave 1 line of performer and hits (having a maximum number of num_of_hits) in each chart_debut value

import pandas as pd performer = ['Glee Cast', 'Taylor Swift', 'Drake', 'YoungBoy Never Broke Again', 'Aretha Franklin', 'The Beatles'] hits = ['Somebody To Love', 'Friday', 'Loser Like Me', 'Baby', 'I Want You Back', 'Kacey Talk', 'Put It On Me', 'Dirty Iyanna', 'Lil Top', 'London Boy', 'Teardrops On My Guitar', 'Fifteen', 'Summer Sixteen', 'The Language', 'Weston Road Flow', 'Sgt. Pepper\'s Lonely Hearts Club Band/With A Little Help From My Friends'] chart_debut = [2009, 2008, 2016, 2020, 1967, 1978] time_on_chart = [290, 14299, 7449, 1012, 3490, 3548] consecutive_weeks = [47.0, 11880.0, 6441.0, 625.0, 2921.0, 2798.0] decade = ['2000-2010', '2000-2010', '2010-2020', '2020-2030

Questions about programming?Chat with your personal AI assistant