Generation

generate functionThu, 09 Feb 2023

There is 'actors' Pandas dataframe: actorid name date_of_birth birth_city birth_country height_inches biography gender ethnicity networth 1002 1155 Jackie Chan 1954-04-07 Victoria Peak Hong Kong 68.0 Hong Kong's cheeky, lovable and best known fil... Male NaN 400000000.0 1387 69 Keanu Reeves 1964-09-02 Beirut Lebanon 73.0 Keanu Charles Reeves, whose first name means "... Male Lebanese 360000000.0 2252 141 Sean Connery 1930-08-25 Edinburgh UK 74.0 The tall, handsome and muscular Scottish actor... Male White 350000000.0 291 6 Bruce Willis 1955-03-19 Idar-Oberstein West Germany 72.0 Actor and musician Bruce Willis is well known ... Male White 250000000.0 Write a function that sorts all rows in the 'networth' column in descending order and creates a new dataframe with only the first 393 rows remaining

def sort_and_return(df): df = df.sort_values('networth', ascending=False) df = df[0:393] return df

Questions about programming?Chat with your personal AI assistant