Permalink
Cannot retrieve contributors at this time
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?
5011-BIG-DATA/number1.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
24 lines (18 sloc)
771 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |