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
#DATE PRE PROCESSING CODE =
import pandas as pd
import dask.dataframe as dd
import numpy as np
import matplotlib.pyplot as plt
#This loads datasets
df = dd.read_csv("Trips_By_Distance.csv")
df_full = dd.read_csv("Trips_Full_Data.csv")
#This handles missing Values
df = df.fillna(df.mean())
df_full = df_full.fillna(df_full.mean())
#Data Cleaning
df["Population Staying at Home"] = df["Population Staying at Home"].astype("int64")
df_full["Week"] = df_full["Week"].astype("int64")
#Grouping Data
weekly_stay_home = df.groupby(by='Week')['Population Staying at Home'].mean().compute()
weekly_trips = df_full.groupby(by='Week')['Trips 1-25 Miles'].mean().compute()
#Data Visualization
plt.figure(figsize=(10, 7))
plt.bar(weekly_stay_home.index, weekly_stay_home.values, color='orange', width=0.4)
plt.xlabel("Week")
plt.ylabel("Average Population Staying at Home")
plt.title("Average Population Staying at Home per Week")
plt.grid()
plt.show()
plt.figure(figsize=(10, 7))
plt.bar(weekly_trips.index, weekly_trips.values, color='blue', width=0.4)
plt.xlabel("Week")
plt.ylabel("Average Trips 1-25 Miles")
plt.title("Average Trips 1-25 Miles per Week")
plt.grid()
plt.show()