Generation

generate functionThu, 19 Jan 2023

There is a Pandas dataframe: place decade perc_of_5star 0 1 2010-2020 2.300 1 2 1900-1910 1.379 2 3 1970-1980 1.179 3 4 2000-2010 1.176 4 5 1960-1970 1.133 build a horizontal barchart with perc_of_5star columns in descending order and decade values on the y-axis

def plot_barchart(df): df = df.sort_values('perc_of_5star', ascending = False).head(10) return df.plot.barh(x = 'decade', y = 'perc_of_5star', title = '% 5-star ratings by decade'); plot_barchart(df)

Questions about programming?Chat with your personal AI assistant