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/number1e.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
23 lines (19 sloc)
851 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 | |
import matplotlib.pyplot as plt | |
# Step 1: Load the dataset | |
trips_data = pd.read_csv("Trips_Full_Data.csv") | |
# Step 2: Extract columns related to distance-trips | |
distance_columns = ['Trips <1 Mile', 'Trips 1-25 Miles', 'Trips 25-50 Miles', 'Trips 50-100 Miles', | |
'Trips 100-250 Miles', 'Trips 250-500 Miles', 'Trips 500+ Miles'] | |
# Step 3: Sum up the number of travelers for each distance category | |
total_travelers_by_distance = trips_data[distance_columns].sum() | |
# Step 4: Plot the summed values | |
plt.figure(figsize=(10, 6)) | |
total_travelers_by_distance.plot(kind='bar', color='skyblue') | |
plt.title('Total Number of Travelers by Distance-Trips') | |
plt.xlabel('Distance Trips') | |
plt.ylabel('Total Number of Travelers') | |
plt.xticks(rotation=45) | |
plt.grid(axis='y', linestyle='--', alpha=0.7) | |
plt.tight_layout() | |
plt.show() |