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
# Load the data from CSV file
data_file = "/Users/thecreator/Downloads/Trips_by_Distance.csv"
df = pd.read_csv(data_file)
# Check the column names to find the exact name to use
print(df.columns)
# Assuming the correct column name is 'Number of Trips 0-1 Miles', filter and sum
if 'Number of Trips 0-1 Miles' in df.columns:
# Filter data where 'Number of Trips 0-1 Miles' is greater than 0
home_stayers = df[df['Number of Trips 0-1 Miles'] > 0]
# Calculate the total number of people who stayed home
total_home_stayers = home_stayers['Number of Trips 0-1 Miles'].sum()
print(f"Total number of people who stayed home: {total_home_stayers}")
else:
print("Column 'Number of Trips 0-1 Miles' not found in the DataFrame. Check column names.")