In [ ]:
#Building Dataframe for popularity of stations
station_popularity = trip.pivot_table('trip_id', aggfunc='count', index=['from_station_id'])
station_popularity = pd.DataFrame(station_popularity)
station_popularity.columns = ['Nber_starts']
station_popularity.index.names = ['station_id']
station_popularity['Nber_stops']= trip.pivot_table('trip_id', aggfunc='count', index=['to_station_id'])
display(station_popularity.head())
#Visualization
ax = station_popularity.sort_values('Nber_starts',ascending=False).plot(kind='bar', figsize = (30,10), fontsize = 15)
ax.set_title('Start Station Popularity',fontsize=25)
ax.set_ylabel('Total Number of Trips',fontsize=15)
ax.legend(fontsize=15)
plt.show()