You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Bubble Plot indicates that number of rides and drivers both are more in urban cities as compared to suburban and rural cities. Although average fare is more for suburban and rural cities for few instances.
All three pie charts show that urban cities have a good percentage of total fare, total rides and total drivers.
From this analysis, this can be predicted that there are many new opportunities to expand the business in suburban and rural cities, in terms of hiring more drivers to operate in these cities.
# Dependencies
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
# Create separate data frames based on city types - Urban, Suburban and Ruralurban_city=pyber_data.loc[(pyber_data["type"] =="Urban")]
suburban_city=pyber_data.loc[(pyber_data["type"] =="Suburban")]
rural_city=pyber_data.loc[(pyber_data["type"] =="Rural")]
# Per city calculations of Average Fare, Total Rides and Total Drivers for Urban citiesavg_fare_urban_city=urban_city.groupby(['city'])['fare'].mean()
total_rides_urban_city=urban_city.groupby(['city']).count()['ride_id']
total_drivers_urban_city=urban_city.groupby(['city'])['driver_count'].value_counts()
# Per city calculations of Average Fare, Total Rides and Total Drivers for Suburban citiesavg_fare_suburban_city=suburban_city.groupby(['city'])['fare'].mean()
total_rides_suburban_city=suburban_city.groupby(['city']).count()['ride_id']
total_drivers_suburban_city=suburban_city.groupby(['city'])['driver_count'].value_counts()
# Per city calculations of Average Fare, Total Rides and Total Drivers for Rural citiesavg_fare_rural_city=rural_city.groupby(['city'])['fare'].mean()
total_rides_rural_city=rural_city.groupby(['city']).count()['ride_id']
total_drivers_rural_city=rural_city.groupby(['city'])['driver_count'].value_counts()
<matplotlib.collections.PathCollection at 0x2aee6c18be0>
# Chart titleplt.title("Pyber Ride Sharing Data (2016)")
# x labelplt.xlabel("Total Numbers of Rides (Per City))")
# y labelplt.ylabel("Average Fare($)")
# legend plt.legend(loc='upper right')
<matplotlib.legend.Legend at 0x2aee69e2860>
# Save an image of the chart and print to screenplt.savefig("Images/Pyber Ride Sharing.png")
plt.show()
Total Fares by City Type¶
# Calculate Total Fare by City Typetotal_fare=pyber_data.groupby(['type'])['fare'].sum()
# Labels for the sections of our pie chartlabels= ["Rural","Suburban","Urban" ]
# The colors of each section of the pie chartcolors= ["gold","lightskyblue","lightcoral"]
explode= (0, 0, 0.1)
plt.title("% of Total Fares By City Types")
plt.pie(total_fare, explode=explode, labels=labels, colors=colors, autopct="%1.1f%%",shadow=True, startangle=160)
plt.axis("equal")
plt.savefig("Images/% of Total Fares By City Types.png")
plt.show()
Total Rides by City Type
# Calculate Total Fare by City Typetotal_rides=pyber_data.groupby(['type'])['ride_id'].count()
# Labels for the sections of our pie chartlabels= ["Rural","Suburban","Urban" ]
# The colors of each section of the pie chartcolors= ["gold","lightskyblue","lightcoral"]
explode= (0, 0, 0.1)
plt.title("% of Total Rides By City Types")
plt.pie(total_rides, explode=explode, labels=labels, colors=colors,
autopct="%1.1f%%", shadow=True, startangle=140)
plt.axis("equal")
plt.savefig("Images/% of Total Rides By City Types.png")
plt.show()
Total Drivers by City Type
# Calculate Total Drivers by City Typetotal_drivers=city_data.groupby(['type'])['driver_count'].sum()
# Labels for the sections of our pie chartlabels= ["Rural","Suburban","Urban" ]
# The colors of each section of the pie chartcolors= ["gold","lightskyblue","lightcoral"]
explode= (0, 0, 0.1)
plt.title("% of Total Drivers By City Types")
plt.pie(total_drivers, explode=explode, labels=labels, colors=colors,
autopct="%1.1f%%", shadow=True, startangle=140)
plt.axis("equal")
plt.savefig("Images/% of Total Drivers By City Types.png")
plt.show()
About
Analysis of ride sharing mock data utilizing matplotlib graphs.