diff --git a/Public-Transport-Delay/Untitled.ipynb b/Public-Transport-Delay/Untitled.ipynb deleted file mode 100644 index 10a465c..0000000 --- a/Public-Transport-Delay/Untitled.ipynb +++ /dev/null @@ -1,187 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "id": "0b0d18b4-ed84-4189-ae4c-db599edd5ee9", - "metadata": {}, - "outputs": [], - "source": [ - "import pandas as pd\n", - "import matplotlib.pyplot as plt\n", - "import seaborn as sns\n", - "import numpy as np" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "2407a8c4-e8a5-4e56-a075-bb9804334b26", - "metadata": {}, - "outputs": [], - "source": [ - "# Setting up visualization style\n", - "sns.set_style(\"whitegrid\")\n", - "plt.rcParams['figure.figsize'] = (10, 6)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "f6cbdb6e-768d-40f8-94c0-f05c19cf52ca", - "metadata": {}, - "outputs": [], - "source": [ - "# Loading the dataset\n", - "df = pd.read_csv(\"city_transit_data_sample.csv\")" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "3fd9b3b6-c5cd-4f6f-90d8-8bccafe6e8b7", - "metadata": {}, - "outputs": [], - "source": [ - "# Converting timestamp columns to datetime\n", - "df['Scheduled_Arrival'] = pd.to_datetime(df['Scheduled_Arrival'])\n", - "df['Actual_Arrival'] = pd.to_datetime(df['Actual_Arrival'])\n", - "df['Date'] = df['Scheduled_Arrival'].dt.date\n", - "df['Hour'] = df['Scheduled_Arrival'].dt.hour" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "b8454256-7be8-4a32-9f6d-1715e699c4a9", - "metadata": {}, - "outputs": [], - "source": [ - "# Handling missing values (if any)\n", - "df = df.dropna(subset=['Delay_Minutes', 'Weather_Condition', 'Route', 'Station'])" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "67e53abb-209d-4274-9975-b5fc2f6c6dfe", - "metadata": {}, - "outputs": [], - "source": [ - "# Time Series Analysis: Average delay by hour\n", - "hourly_delays = df.groupby('Hour')['Delay_Minutes'].mean()\n", - "plt.figure()\n", - "hourly_delays.plot(kind='line', marker='o', color='b')\n", - "plt.title('Average Delay by Hour of Day')\n", - "plt.xlabel('Hour of Day')\n", - "plt.ylabel('Average Delay (Minutes)')\n", - "plt.xticks(range(0, 24))\n", - "plt.savefig('hourly_delays.png')\n", - "plt.close()" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "d9653086-6d49-4411-98bf-1bb734213d5a", - "metadata": {}, - "outputs": [], - "source": [ - "# Route-Based Analysis: Average delay by route\n", - "route_delays = df.groupby('Route')['Delay_Minutes'].mean().sort_values()\n", - "plt.figure()\n", - "route_delays.plot(kind='bar', color='green')\n", - "plt.title('Average Delay by Route')\n", - "plt.xlabel('Route')\n", - "plt.ylabel('Average Delay (Minutes)')\n", - "plt.savefig('route_delays.png')\n", - "plt.close()" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "c3ac8925-da76-400e-a19e-9cbc860d8179", - "metadata": {}, - "outputs": [], - "source": [ - "# Station-Based Analysis: Average delay by station\n", - "station_delays = df.groupby('Station')['Delay_Minutes'].mean().sort_values()\n", - "plt.figure()\n", - "station_delays.plot(kind='bar', color='purple')\n", - "plt.title('Average Delay by Station')\n", - "plt.xlabel('Station')\n", - "plt.ylabel('Average Delay (Minutes)')\n", - "plt.savefig('station_delays.png')\n", - "plt.close()" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "3d784220-3ac9-428c-abe2-b4b6bbe8b524", - "metadata": {}, - "outputs": [], - "source": [ - "# Weather Impact Analysis: Average delay by weather condition\n", - "weather_delays = df.groupby('Weather_Condition')['Delay_Minutes'].mean().sort_values()\n", - "plt.figure()\n", - "weather_delays.plot(kind='bar', color='orange')\n", - "plt.title('Average Delay by Weather Condition')\n", - "plt.xlabel('Weather Condition')\n", - "plt.ylabel('Average Delay (Minutes)')\n", - "plt.savefig('weather_delays.png')\n", - "plt.close()" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "id": "a53d9a1e-2fde-41e8-9443-83379721518f", - "metadata": {}, - "outputs": [], - "source": [ - "# Correlation Analysis: Create numeric proxy for weather conditions\n", - "weather_map = {'Clear': 0, 'Cloudy': 1, 'Rainy': 2, 'Snow': 3, 'Foggy': 4}\n", - "df['Weather_Score'] = df['Weather_Condition'].map(weather_map)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "5782616c-6765-46ae-aaee-85c3ac5c517e", - "metadata": {}, - "outputs": [], - "source": [ - "# Correlation matrix\n", - "corr_matrix = df[['Delay_Minutes', 'Weather_Score']].corr()\n", - "plt.figure()\n", - "sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', center=0)\n", - "plt.title('Correlation Matrix: Delay vs. Weather Score')\n", - "plt.savefig('correlation_matrix.png')\n", - "plt.close()\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "anaconda-panel-2023.05-py310", - "language": "python", - "name": "conda-env-anaconda-panel-2023.05-py310-py" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.5" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/Public-Transport-Delay/delay_reasons.png b/Public-Transport-Delay/delay_reasons.png deleted file mode 100644 index 2a84a8f..0000000 Binary files a/Public-Transport-Delay/delay_reasons.png and /dev/null differ diff --git a/Public-Transport-Delay/delay_summary.csv b/Public-Transport-Delay/delay_summary.csv deleted file mode 100644 index 504a71f..0000000 --- a/Public-Transport-Delay/delay_summary.csv +++ /dev/null @@ -1,21 +0,0 @@ -Route,Weather_Condition,mean,count -Route A,Clear,10.0,2 -Route A,Cloudy,9.333333333333334,3 -Route A,Foggy,6.0,3 -Route A,Rainy,7.166666666666667,6 -Route A,Snow,8.0,2 -Route B,Clear,3.5,2 -Route B,Cloudy,13.333333333333334,3 -Route B,Foggy,8.0,6 -Route B,Rainy,5.333333333333333,3 -Route B,Snow,7.75,4 -Route C,Clear,8.0,4 -Route C,Cloudy,6.666666666666667,6 -Route C,Foggy,5.666666666666667,3 -Route C,Rainy,7.166666666666667,6 -Route C,Snow,7.833333333333333,6 -Route D,Clear,7.833333333333333,6 -Route D,Cloudy,6.5,2 -Route D,Foggy,1.0,2 -Route D,Rainy,6.75,4 -Route D,Snow,6.0,2 diff --git a/Public-Transport-Delay/hourly_delays.png b/Public-Transport-Delay/hourly_delays.png deleted file mode 100644 index 487a6d5..0000000 Binary files a/Public-Transport-Delay/hourly_delays.png and /dev/null differ diff --git a/Public-Transport-Delay/route_delays.png b/Public-Transport-Delay/route_delays.png deleted file mode 100644 index 4d8fa32..0000000 Binary files a/Public-Transport-Delay/route_delays.png and /dev/null differ diff --git a/Public-Transport-Delay/station_delays.png b/Public-Transport-Delay/station_delays.png deleted file mode 100644 index 7d56cb0..0000000 Binary files a/Public-Transport-Delay/station_delays.png and /dev/null differ diff --git a/Public-Transport-Delay/weather_delays.png b/Public-Transport-Delay/weather_delays.png deleted file mode 100644 index 850174a..0000000 Binary files a/Public-Transport-Delay/weather_delays.png and /dev/null differ