Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
import matplotlib.pyplot as plt
import pandas as pd
df_full = pd.read_csv('Trips_Full Data.csv')
distance_columns = [
'Trips <1 Mile', 'Trips 1-25 Miles', 'Trips 1-3 Miles', 'Trips 10-25 Miles',
'Trips 100-250 Miles', 'Trips 100+ Miles', 'Trips 25-100 Miles', 'Trips 25-50 Miles',
'Trips 250-500 Miles', 'Trips 3-5 Miles', 'Trips 5-10 Miles', 'Trips 50-100 Miles',
'Trips 500+ Miles'
weekly_average = df_full.groupby('Week of Date')[distance_columns].mean()
weekly_average = weekly_average.reset_index().melt(id_vars=['Week of Date'], var_name='Distance Category', value_name='Average Trips')
plt.figure(figsize=(10, 7))
for category in weekly_average['Distance Category'].unique():
subset = weekly_average[weekly_average['Distance Category'] == category]['Week of Date'], subset['Average Trips'], label=category)
plt.ylabel("Average Number of Trips")
plt.title("Average Number of Trips per Week by Distance Category")
plt.legend(title='Distance Category')
plt.xticks(rotation=90) # Rotate the x-axis labels for better readability
plt.grid(True) # Display grid
plt.savefig('Average Number of Trips per Week by Distance Category'.png')