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 that shows the best decade with a maximum rating of 5.0

# import pandas import pandas as pd # import the data data = pd.read_csv('https://s3.amazonaws.com/assets.datacamp.com/production/course_2023/datasets/imdb_1000.csv') # check the data data # check the shape of the data data.shape # drop the rows with null values data.dropna(inplace=True) # drop the rows with null values data.dropna(inplace=True) # check the shape of the data data.shape # find the best decade data.groupby('decade')['rating'].mean().sort_values(ascending=False)

Questions about programming?Chat with your personal AI assistant