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
import matplotlib.pyplot as plt
# Step 1: Load Data
data = pd.read_csv("trips_by_distance.csv")
# Step 2: Data Filtering
# Filter data for > 10,000,000 people conducting 10-25 trips
filtered_data_10_25 = data[(data['Number of Trips 10-25'] > 0) & (data['Number of Trips 10-25'] < 100) & (data['Population Not Staying at Home'] > 10000000)]
# Filter data for > 10,000,000 people conducting 50-100 trips
filtered_data_50_100 = data[(data['Number of Trips 50-100'] > 0) & (data['Number of Trips 50-100'] < 100) & (data['Population Not Staying at Home'] > 10000000)]
# Step 3: Extract Dates
# Get dates where > 10,000,000 people conducted 10-25 trips
dates_10_25 = filtered_data_10_25['Date'].unique()
# Get dates where > 10,000,000 people conducted 50-100 trips
dates_50_100 = filtered_data_50_100['Date'].unique()
# Step 4: Comparison
# Print dates for > 10,000,000 people conducted 10-25 trips
print("Dates where > 10,000,000 people conducted 10-25 trips:")
print(dates_10_25)
# Print dates for > 10,000,000 people conducted 50-100 trips
print("Dates where > 10,000,000 people conducted 50-100 trips:")
print(dates_50_100)
# Step 5: Visualization
plt.figure(figsize=(10, 6))
# Plot total population (assuming it's represented by Population Not Staying at Home)
plt.plot(data['Date'], data['Population Not Staying at Home'], label='Total Population Not Staying at Home')
# Plot > 10,000,000 people conducting 10-25 trips
plt.scatter(filtered_data_10_25['Date'], filtered_data_10_25['Population Not Staying at Home'], color='red', label='> 10,000,000 people (10-25 trips)')
# Plot > 10,000,000 people conducting 50-100 trips
plt.scatter(filtered_data_50_100['Date'], filtered_data_50_100['Population Not Staying at Home'], color='green', label='> 10,000,000 people (50-100 trips)')
# Add labels and legend
plt.xlabel('Date')
plt.ylabel('Population Not Staying at Home')
plt.title('Population Not Staying at Home vs. Date')
plt.legend()
plt.xticks(rotation=45)
plt.tight_layout()
# Show plot
plt.show()