import geopandas as gpd
import matplotlib.pyplot as plt
plt.rcParams['font.size'] = 14
chicago = gpd.read_file("Boundaries_Community_Areas/areas.shp")
pickup_df = df.groupby(['Start Community Area Number']).size().reset_index(name = 'pickup_counts')
dropoff_df = df.groupby(['End Community Area Number']).size().reset_index(name = 'dropoff_counts')
pickup_df['area_numbe'] = pickup_df['Start Community Area Number']
dropoff_df['area_numbe'] = dropoff_df['End Community Area Number']
chicago['area_numbe'] = chicago.area_numbe.astype(float)
pickup = chicago.set_index('area_numbe').join(pickup_df.set_index('area_numbe')).reset_index()
dropoff = chicago.set_index('area_numbe').join(dropoff_df.set_index('area_numbe')).reset_index()
fig = plt.figure(figsize = (14, 8))
for i in [1, 2]:
ax = fig.add_subplot(1, 2, i)
if i == 1:
pickup.plot('pickup_counts', cmap = 'YlOrRd', legend = True,
legend_kwds = {'shrink': 0.618, 'label': 'Pickup trip count'},
vmin = 0, vmax = 2.5e+5, ax = ax)
elif i == 2:
dropoff.plot('dropoff_counts', cmap = 'YlOrRd', legend = True,
legend_kwds = {'shrink': 0.618, 'label': 'Dropoff trip count'},
vmin = 0, vmax = 2.5e+5, ax = ax)
plt.xticks([])
plt.yticks([])
plt.show()
fig.savefig("E_scooter_pickup_dropoff_trips_chicago_2022.png", bbox_inches = "tight")