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 pandas as pd
# Step 1: Load Data
data = pd.read_csv("trips_by_distance.csv")
# Step 2: Data Cleaning
data = data.dropna(axis=1, how='all')
# Handle Missing Values (if any)
# Remove Duplicates (if any)
data = data.dropna(axis=1, how='all')
# Step 3: Data Categorization
# Assuming the "Date" column needs to be converted to datetime format
data['Date'] = pd.to_datetime(data['Date'])
# Step 4: Data Aggregation
# Count People at Home per Week
people_at_home_per_week = data.groupby(pd.Grouper(key='Date', freq='W'))['Population Staying at Home'].sum()
# Step 5: Calculate Average
average_people_at_home_per_week = people_at_home_per_week.mean()
# Display the Result
print("Average number of people staying at home per week:", average_people_at_home_per_week)