Skip to content

Commit fa84e4c

Browse files
authored
Merge pull request #1075 from surajparui/main
Hacktoberfest
2 parents ff020c4 + 288ed16 commit fa84e4c

File tree

4 files changed

+298
-0
lines changed

4 files changed

+298
-0
lines changed

New folder/IPD.ipynb

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"Represent one point in time"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": 4,
13+
"metadata": {},
14+
"outputs": [
15+
{
16+
"name": "stdout",
17+
"output_type": "stream",
18+
"text": [
19+
" 0 1 2 3 4 5 6 7 \\\n",
20+
"0 C8g//BgchSunBQFm//0rCA== 22 22 22 22 22 22 22 \n",
21+
"1 C8g/IhgdQiu/Bf+MAQgrHA== 21 21 21 21 21 21 21 \n",
22+
"2 C8g/JRgcXCu1A/8g/64rFg== 18 18 18 18 18 18 18 \n",
23+
"3 C8g/JRgpCBtrAgCV/58bCw== 51 51 51 51 51 51 51 \n",
24+
"4 C8g0Nhgw9CugAQAOAFUrAA== 30 30 30 30 30 30 30 \n",
25+
"... ... ... ... ... ... ... ... ... \n",
26+
"57409 C8ivDhhVaiuuAQAR/7srDw== 19 19 19 19 19 19 19 \n",
27+
"57410 C8ivxRheHiuoAwDC/5ArCw== 14 14 14 14 14 14 14 \n",
28+
"57411 C8iyGxhi+SuxAv/U/2krEQ== 10 10 10 10 10 10 10 \n",
29+
"57412 C8izrhhbFiuuAgBJ/6ArCg== 23 23 23 23 23 23 23 \n",
30+
"57413 C8izuBhkCCu6Bf7L/7IrFA== 19 19 19 19 19 19 19 \n",
31+
"\n",
32+
" 8 9 ... 2007 2008 2009 2010 2011 2012 2013 2014 2015 \\\n",
33+
"0 22 22 ... 22 22 22 22 22 22 22 22 22 \n",
34+
"1 21 21 ... 21 21 21 21 21 21 21 21 21 \n",
35+
"2 18 18 ... 18 18 18 18 18 18 18 18 18 \n",
36+
"3 51 51 ... 49 60 60 60 60 54 53 51 51 \n",
37+
"4 30 30 ... 30 30 30 30 30 30 30 30 30 \n",
38+
"... ... ... ... ... ... ... ... ... ... ... ... ... \n",
39+
"57409 19 19 ... 19 19 19 19 19 19 19 19 19 \n",
40+
"57410 14 14 ... 14 14 14 14 14 14 14 14 14 \n",
41+
"57411 10 10 ... 10 10 10 10 10 10 10 10 10 \n",
42+
"57412 23 23 ... 23 23 23 23 23 23 23 23 23 \n",
43+
"57413 19 19 ... 19 19 19 19 19 19 19 19 19 \n",
44+
"\n",
45+
" 2016 \n",
46+
"0 22 \n",
47+
"1 21 \n",
48+
"2 18 \n",
49+
"3 51 \n",
50+
"4 30 \n",
51+
"... ... \n",
52+
"57409 19 \n",
53+
"57410 14 \n",
54+
"57411 10 \n",
55+
"57412 23 \n",
56+
"57413 19 \n",
57+
"\n",
58+
"[57414 rows x 2017 columns]\n",
59+
" 0 1 398\n",
60+
"0 C8g//BgchSunBQFm//0rCA== 22 61\n",
61+
"1 C8g/IhgdQiu/Bf+MAQgrHA== 21 21\n",
62+
"2 C8g/JRgcXCu1A/8g/64rFg== 18 18\n",
63+
"3 C8g/JRgpCBtrAgCV/58bCw== 51 54\n",
64+
"4 C8g0Nhgw9CugAQAOAFUrAA== 30 30\n",
65+
"... ... ... ...\n",
66+
"57409 C8ivDhhVaiuuAQAR/7srDw== 19 14\n",
67+
"57410 C8ivxRheHiuoAwDC/5ArCw== 14 14\n",
68+
"57411 C8iyGxhi+SuxAv/U/2krEQ== 10 10\n",
69+
"57412 C8izrhhbFiuuAgBJ/6ArCg== 23 19\n",
70+
"57413 C8izuBhkCCu6Bf7L/7IrFA== 19 19\n",
71+
"\n",
72+
"[57414 rows x 3 columns]\n"
73+
]
74+
}
75+
],
76+
"source": [
77+
"import pandas as pd\n",
78+
"\n",
79+
"all_speeds = pd.read_csv('Mumbai.csv.gz', header=None, compression='gzip')\n",
80+
"monday_9am = all_speeds[[0, 1, 398]]\n",
81+
"monday_9am.to_csv('9am_speeds.csv', header=False, index=False)\n",
82+
"print(all_speeds)\n",
83+
"print(monday_9am)"
84+
]
85+
},
86+
{
87+
"cell_type": "markdown",
88+
"metadata": {},
89+
"source": [
90+
"Calculate aggregated traffic metrics"
91+
]
92+
},
93+
{
94+
"cell_type": "code",
95+
"execution_count": 6,
96+
"metadata": {},
97+
"outputs": [
98+
{
99+
"name": "stdout",
100+
"output_type": "stream",
101+
"text": [
102+
" start_node end_node average\n",
103+
"0 C8g//BgchSunBQFm//0rCA== 22 33.17\n",
104+
"1 C8g/IhgdQiu/Bf+MAQgrHA== 21 21.00\n",
105+
"2 C8g/JRgcXCu1A/8g/64rFg== 18 18.00\n",
106+
"3 C8g/JRgpCBtrAgCV/58bCw== 51 57.17\n",
107+
"4 C8g0Nhgw9CugAQAOAFUrAA== 30 37.33\n"
108+
]
109+
}
110+
],
111+
"source": [
112+
"import pandas as pd\n",
113+
"\n",
114+
"all_speeds = pd.read_csv('Mumbai.csv.gz', header=None, compression='gzip')\n",
115+
"monday_9_10_speeds = all_speeds.iloc[:, 398:410].mean(axis=1).round(2)\n",
116+
"monday_9_10_nodes_speeds = pd.concat([all_speeds[[0, 1]],monday_9_10_speeds], axis=1)\n",
117+
"monday_9_10_nodes_speeds.columns = ['start_node', 'end_node', 'average']\n",
118+
"print(monday_9_10_nodes_speeds.head())"
119+
]
120+
}
121+
],
122+
"metadata": {
123+
"kernelspec": {
124+
"display_name": "Python 3.10.3 64-bit",
125+
"language": "python",
126+
"name": "python3"
127+
},
128+
"language_info": {
129+
"codemirror_mode": {
130+
"name": "ipython",
131+
"version": 3
132+
},
133+
"file_extension": ".py",
134+
"mimetype": "text/x-python",
135+
"name": "python",
136+
"nbconvert_exporter": "python",
137+
"pygments_lexer": "ipython3",
138+
"version": "3.10.3"
139+
},
140+
"orig_nbformat": 4,
141+
"vscode": {
142+
"interpreter": {
143+
"hash": "52634da84371cba311ea128a5ea7cdc41ff074b781779e754b270ff9f8153cee"
144+
}
145+
}
146+
},
147+
"nbformat": 4,
148+
"nbformat_minor": 2
149+
}

New folder/Mumbai.csv.gz

19.3 MB
Binary file not shown.

Python/New folder/IPD.ipynb

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"Represent one point in time"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": 4,
13+
"metadata": {},
14+
"outputs": [
15+
{
16+
"name": "stdout",
17+
"output_type": "stream",
18+
"text": [
19+
" 0 1 2 3 4 5 6 7 \\\n",
20+
"0 C8g//BgchSunBQFm//0rCA== 22 22 22 22 22 22 22 \n",
21+
"1 C8g/IhgdQiu/Bf+MAQgrHA== 21 21 21 21 21 21 21 \n",
22+
"2 C8g/JRgcXCu1A/8g/64rFg== 18 18 18 18 18 18 18 \n",
23+
"3 C8g/JRgpCBtrAgCV/58bCw== 51 51 51 51 51 51 51 \n",
24+
"4 C8g0Nhgw9CugAQAOAFUrAA== 30 30 30 30 30 30 30 \n",
25+
"... ... ... ... ... ... ... ... ... \n",
26+
"57409 C8ivDhhVaiuuAQAR/7srDw== 19 19 19 19 19 19 19 \n",
27+
"57410 C8ivxRheHiuoAwDC/5ArCw== 14 14 14 14 14 14 14 \n",
28+
"57411 C8iyGxhi+SuxAv/U/2krEQ== 10 10 10 10 10 10 10 \n",
29+
"57412 C8izrhhbFiuuAgBJ/6ArCg== 23 23 23 23 23 23 23 \n",
30+
"57413 C8izuBhkCCu6Bf7L/7IrFA== 19 19 19 19 19 19 19 \n",
31+
"\n",
32+
" 8 9 ... 2007 2008 2009 2010 2011 2012 2013 2014 2015 \\\n",
33+
"0 22 22 ... 22 22 22 22 22 22 22 22 22 \n",
34+
"1 21 21 ... 21 21 21 21 21 21 21 21 21 \n",
35+
"2 18 18 ... 18 18 18 18 18 18 18 18 18 \n",
36+
"3 51 51 ... 49 60 60 60 60 54 53 51 51 \n",
37+
"4 30 30 ... 30 30 30 30 30 30 30 30 30 \n",
38+
"... ... ... ... ... ... ... ... ... ... ... ... ... \n",
39+
"57409 19 19 ... 19 19 19 19 19 19 19 19 19 \n",
40+
"57410 14 14 ... 14 14 14 14 14 14 14 14 14 \n",
41+
"57411 10 10 ... 10 10 10 10 10 10 10 10 10 \n",
42+
"57412 23 23 ... 23 23 23 23 23 23 23 23 23 \n",
43+
"57413 19 19 ... 19 19 19 19 19 19 19 19 19 \n",
44+
"\n",
45+
" 2016 \n",
46+
"0 22 \n",
47+
"1 21 \n",
48+
"2 18 \n",
49+
"3 51 \n",
50+
"4 30 \n",
51+
"... ... \n",
52+
"57409 19 \n",
53+
"57410 14 \n",
54+
"57411 10 \n",
55+
"57412 23 \n",
56+
"57413 19 \n",
57+
"\n",
58+
"[57414 rows x 2017 columns]\n",
59+
" 0 1 398\n",
60+
"0 C8g//BgchSunBQFm//0rCA== 22 61\n",
61+
"1 C8g/IhgdQiu/Bf+MAQgrHA== 21 21\n",
62+
"2 C8g/JRgcXCu1A/8g/64rFg== 18 18\n",
63+
"3 C8g/JRgpCBtrAgCV/58bCw== 51 54\n",
64+
"4 C8g0Nhgw9CugAQAOAFUrAA== 30 30\n",
65+
"... ... ... ...\n",
66+
"57409 C8ivDhhVaiuuAQAR/7srDw== 19 14\n",
67+
"57410 C8ivxRheHiuoAwDC/5ArCw== 14 14\n",
68+
"57411 C8iyGxhi+SuxAv/U/2krEQ== 10 10\n",
69+
"57412 C8izrhhbFiuuAgBJ/6ArCg== 23 19\n",
70+
"57413 C8izuBhkCCu6Bf7L/7IrFA== 19 19\n",
71+
"\n",
72+
"[57414 rows x 3 columns]\n"
73+
]
74+
}
75+
],
76+
"source": [
77+
"import pandas as pd\n",
78+
"\n",
79+
"all_speeds = pd.read_csv('Mumbai.csv.gz', header=None, compression='gzip')\n",
80+
"monday_9am = all_speeds[[0, 1, 398]]\n",
81+
"monday_9am.to_csv('9am_speeds.csv', header=False, index=False)\n",
82+
"print(all_speeds)\n",
83+
"print(monday_9am)"
84+
]
85+
},
86+
{
87+
"cell_type": "markdown",
88+
"metadata": {},
89+
"source": [
90+
"Calculate aggregated traffic metrics"
91+
]
92+
},
93+
{
94+
"cell_type": "code",
95+
"execution_count": 6,
96+
"metadata": {},
97+
"outputs": [
98+
{
99+
"name": "stdout",
100+
"output_type": "stream",
101+
"text": [
102+
" start_node end_node average\n",
103+
"0 C8g//BgchSunBQFm//0rCA== 22 33.17\n",
104+
"1 C8g/IhgdQiu/Bf+MAQgrHA== 21 21.00\n",
105+
"2 C8g/JRgcXCu1A/8g/64rFg== 18 18.00\n",
106+
"3 C8g/JRgpCBtrAgCV/58bCw== 51 57.17\n",
107+
"4 C8g0Nhgw9CugAQAOAFUrAA== 30 37.33\n"
108+
]
109+
}
110+
],
111+
"source": [
112+
"import pandas as pd\n",
113+
"\n",
114+
"all_speeds = pd.read_csv('Mumbai.csv.gz', header=None, compression='gzip')\n",
115+
"monday_9_10_speeds = all_speeds.iloc[:, 398:410].mean(axis=1).round(2)\n",
116+
"monday_9_10_nodes_speeds = pd.concat([all_speeds[[0, 1]],monday_9_10_speeds], axis=1)\n",
117+
"monday_9_10_nodes_speeds.columns = ['start_node', 'end_node', 'average']\n",
118+
"print(monday_9_10_nodes_speeds.head())"
119+
]
120+
}
121+
],
122+
"metadata": {
123+
"kernelspec": {
124+
"display_name": "Python 3.10.3 64-bit",
125+
"language": "python",
126+
"name": "python3"
127+
},
128+
"language_info": {
129+
"codemirror_mode": {
130+
"name": "ipython",
131+
"version": 3
132+
},
133+
"file_extension": ".py",
134+
"mimetype": "text/x-python",
135+
"name": "python",
136+
"nbconvert_exporter": "python",
137+
"pygments_lexer": "ipython3",
138+
"version": "3.10.3"
139+
},
140+
"orig_nbformat": 4,
141+
"vscode": {
142+
"interpreter": {
143+
"hash": "52634da84371cba311ea128a5ea7cdc41ff074b781779e754b270ff9f8153cee"
144+
}
145+
}
146+
},
147+
"nbformat": 4,
148+
"nbformat_minor": 2
149+
}

Python/New folder/Mumbai.csv.gz

19.3 MB
Binary file not shown.

0 commit comments

Comments
 (0)