Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ def import_data():
return pd.read_csv('ttc-bus-delay-data-2023.csv')


def compute_avg_delay(data):
def compute_avg_delay(data, group_by: str = 'Route'):
"""
Compute the average delay for each route
Compute the average delay aggregated by specified column
"""
return data.groupby('Route').mean().reset_index()
return data.groupby('Route')['Min Delay'].mean().reset_index()


def main():
"""
Main function
"""
data = import_data()
avg_delay = compute_avg_delay(data)
avg_delay = compute_avg_delay(data, group_by='Route')

plt.hist(avg_delay['Min Delay'], bins=30)
plt.title('Average Delay Distribution')
Expand Down
Binary file added Homework_Task1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Homework_Task2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Homework_Task3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.