Skip to content
Permalink
main
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 pandas as pd
import matplotlib.pyplot as plt
# Reading the Trips by Distance data
df = pd.read_csv('Trips_by_Distance.csv')
# Since the 'Week' column exists in Trips_by_Distance.csv, proceed with original plan
unique_weeks = df['Week'].nunique()
avg_population_staying_home = df.groupby('Week')['Population Staying at Home'].mean()
df_full = pd.read_csv('Trips_Full Data.csv')
trip_distance_columns = [col for col in df_full.columns if 'Trips' in col and 'Miles' in col]
avg_trips_by_distance = df_full.groupby('Week of Date')[trip_distance_columns].mean()
# Plotting the barplot for People staying at home vs Week
plt.figure(figsize=(10, 5))
plt.bar(avg_population_staying_home.index, avg_population_staying_home.values, label='Population Staying at Home')
plt.xlabel('Week')
plt.ylabel('Average Population Staying at Home')
plt.title('Average Population Staying at Home by Week')
plt.legend()
plt.xticks(rotation=90)
plt.tight_layout()
# Adjust the path as needed for your environment
plt.savefig('population_staying_home_vs_week.png')