Generation

generate functionWed, 18 Jan 2023

There is a Pandas dataframe: id title rating decade 4728 Bad Education (2019) 0.5 2010-2020 35638 35638 Palooka (1934) 0.5 1934 1930-1940 21445 21445 High Moon (2019) 0.5 2019 2010-2020 40291 40291 Saint Maud (2019) 0.5 2019 2010-2020 29462 29462 Mad at the Moon (1992) 0.5 1992 1990-2000 46978 46978 The Butterfly Ball (1977) 0.5 1977 1970-1980 42931 42931 Snowboarďáci (2004) 0.5 2004 2000-2010 38670 38670 Recon 2020: The Caprini Massacre (2004) 0.5 2004 2000-2010 25506 25506 Karagoez catalogo 9,5 (1983) 0.5 1983 1980-1990 43989 43989 Starting a Skyscraper (1902) 0.5 1902 1900-1910 Write code with value_counts and sorting by decade column and rating

def sort_df(df): return df.groupby('decade').rating.value_counts().sort_index()

Questions about programming?Chat with your personal AI assistant