find the best book for each year based on ‘ avg_rating ‘ value. You…

  

find the best book for each year based on ‘ avg_rating ‘ value. You… find the best book for each year based on ‘avg_rating’ value. You may want to use groupby method with the values of ‘year_published’. The output format should be “Year  Title Avg_rating”.  The correct outputThe total number of the output list is 58. Here are the outputs of year 1821, 1977, 1999, and 2012 for debugging.                      1821 Narratives of the Wreck of the Whale-Ship Essex 3.9        1977 At Random 4.16        1999 Harry Potter and the Prisoner of Azkaban 4.55        2012 Wool 4.24 import numpy as npimport pandas as pdimport pickledf = pd.read_pickle(“./lab3-data.pkl”) # read_pickle() is used to read the pkl format filesdf.describe() # This will show number of NaN values in the data frame#df1 = df_filtered#group_author = df.groupby(‘author’)#print(group_author.count())#print(group_author[‘author’].count())#for author, subset in df.groupby(‘author’): #print(author) #print(subset.title) #print(subset.year_published)# We first group df1 by year_published. Then considering the avg_rating column, take out row which gives max value of avg_rating best_books_per_year = df.groupby(“year_published”, sort=False)[“avg_rating”].max()best_books_per_yearImage transcription textbest_books_per year year_published 2009 4.38 2014 4.60 2016 4.50 2010 30.49 1998 4.39 1980 3.90 19753.47 1976 3.76 1905 3.57 -2002 3.52 Name: avg rating, Length: 67, dtype: float64… Show more Computer Science Engineering & Technology Python Programming ITS 265

Don't use plagiarized sources. Get Your Custom Essay on
find the best book for each year based on ‘ avg_rating ‘ value. You…
Just from $13/Page
Order Essay
  

Leave a Reply

Your email address will not be published.

Related Post

Open chat
💬 Need help?
Hello 👋
Can we help you?