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_city_reviews(df): fig, ax = plt.subplots() df.sort_values('perc_of_5star', ascending=False)[:10].plot.barh(x='place', y='perc_of_5star', figsize=(10,6), ax=ax) _ = ax.set(ylabel='Decade', xlabel='% of 5-star reviews')

Questions about programming?Chat with your personal AI assistant