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 matplotlib
matplotlib.use('Agg') # Use the Agg backend
import dask.dataframe as dd
import matplotlib.pyplot as plt
# Read data using Dask
df_data = dd.read_csv('Trips_Full_Data.csv', dtype = {'Trips 1-25 Miles': 'float64',
'Trips 1-3 Miles': 'float64',
'Trips 10-25 Miles': 'float64',
'Trips 100-250 Miles': 'float64',
'Trips 25-50 Miles': 'float64',
'Trips 250-500 Miles': 'float64',
'Trips 3-5 Miles': 'float64',
'Trips 5-10 Miles': 'float64',
'Trips 50-100 Miles': 'float64',
'Trips <1 Mile': 'float64',
'Trips >=500 Miles': 'float64',
'Population Not Staying at Home': 'float64',
'Population Staying at Home': 'float64',
'Week': 'float64'
})
Trips = [
'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'
]
# Group and sum
df_merge = df_data[Trips].sum().compute()
print(df_merge)
# Plot
plt.figure(figsize=(10, 6))
df_merge.plot(kind='bar', color='orange')
plt.title('Number of Participants of Travelers by Distance Trips')
plt.xlabel('Number of Trips by Distance')
plt.ylabel('Population Not Staying at Home')
plt.xticks(rotation=45)
plt.tight_layout()
plt.savefig('bar_plot11data.png')