Skip to content

Commit fa38e8f

Browse files
New notebooks
1 parent afd3680 commit fa38e8f

File tree

4 files changed

+195
-2
lines changed

4 files changed

+195
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ lab*.ipynb
99
# virtual environments
1010
.venv/
1111
myenv/
12-
2017.csv
12+
2017.csv
13+
airlines.csv

Project_1.ipynb

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "b4a01b39",
6+
"metadata": {},
7+
"source": [
8+
"# Project 1"
9+
]
10+
},
11+
{
12+
"cell_type": "markdown",
13+
"id": "1cc24e93",
14+
"metadata": {},
15+
"source": [
16+
"For this project, we will be looking at F1 team data. More specifically, team data. \n",
17+
"\n",
18+
"We will be looking at the mode, median and average age number of laps done during the qualifying sessions. \n",
19+
"\n",
20+
"We will looking at a solidifed dataset including qualifying session from 2022 to 2025"
21+
]
22+
},
23+
{
24+
"cell_type": "markdown",
25+
"id": "ed9d198c",
26+
"metadata": {},
27+
"source": [
28+
"# Let me merge the 4 years of data to have a big enough dataset"
29+
]
30+
},
31+
{
32+
"cell_type": "code",
33+
"execution_count": 1,
34+
"id": "2f86d349",
35+
"metadata": {},
36+
"outputs": [],
37+
"source": [
38+
"#step 1\n",
39+
"\n",
40+
"import pandas as pd\n",
41+
"years = [2022, 2023, 2024, 2025]\n",
42+
"qual = pd.concat((pd.read_csv(f\"{y}.csv\").assign(season=y) for y in years), ignore_index=True)\n",
43+
"qual.to_csv(\"f1_qualifying_2022_2025.csv\", index=False)\n"
44+
]
45+
},
46+
{
47+
"cell_type": "markdown",
48+
"id": "d858a645",
49+
"metadata": {},
50+
"source": [
51+
"# Average of laps done in qualifying across all seasons"
52+
]
53+
},
54+
{
55+
"cell_type": "code",
56+
"execution_count": 2,
57+
"id": "c8485d2d",
58+
"metadata": {},
59+
"outputs": [
60+
{
61+
"name": "stdout",
62+
"output_type": "stream",
63+
"text": [
64+
"15.943181818181818\n"
65+
]
66+
}
67+
],
68+
"source": [
69+
"# step 2\n",
70+
"import pandas as pd\n",
71+
"\n",
72+
"df = pd.read_csv(\"f1_qualifying_2022_2025.csv\")\n",
73+
"avg_laps = df[\"Laps\"].mean()\n",
74+
"print(avg_laps)"
75+
]
76+
},
77+
{
78+
"cell_type": "markdown",
79+
"id": "4ac17b31",
80+
"metadata": {},
81+
"source": [
82+
"# The median now"
83+
]
84+
},
85+
{
86+
"cell_type": "code",
87+
"execution_count": 3,
88+
"id": "61d744bd",
89+
"metadata": {},
90+
"outputs": [
91+
{
92+
"name": "stdout",
93+
"output_type": "stream",
94+
"text": [
95+
"15.943181818181818\n"
96+
]
97+
}
98+
],
99+
"source": [
100+
"# step 3\n",
101+
"import pandas as pd\n",
102+
"\n",
103+
"df = pd.read_csv(\"f1_qualifying_2022_2025.csv\")\n",
104+
"median_laps = df[\"Laps\"].mean()\n",
105+
"print(median_laps)\n",
106+
"\n",
107+
"# I think all entries in Laps are number. If not, to be sure, I could use \n",
108+
"\n",
109+
"#import pandas as pd\n",
110+
"\n",
111+
"#df = pd.read_csv(\"f1_qualifying_2022_2025.csv\")\n",
112+
"#median_laps = pd.to_numeric(df[\"Laps\"], errors=\"coerce\").median()\n",
113+
"#print(f\"Median laps (2022–2025): {median_laps}\")"
114+
]
115+
},
116+
{
117+
"cell_type": "markdown",
118+
"id": "15a68fe0",
119+
"metadata": {},
120+
"source": [
121+
"# Mode"
122+
]
123+
},
124+
{
125+
"cell_type": "code",
126+
"execution_count": 4,
127+
"id": "51205acc",
128+
"metadata": {},
129+
"outputs": [
130+
{
131+
"name": "stdout",
132+
"output_type": "stream",
133+
"text": [
134+
"0 15.0\n",
135+
"Name: Laps, dtype: float64\n"
136+
]
137+
}
138+
],
139+
"source": [
140+
"# step 4\n",
141+
"import pandas as pd\n",
142+
"\n",
143+
"df = pd.read_csv(\"f1_qualifying_2022_2025.csv\")\n",
144+
"mode_laps = df[\"Laps\"].mode()\n",
145+
"print(mode_laps)"
146+
]
147+
},
148+
{
149+
"cell_type": "markdown",
150+
"id": "87e45682",
151+
"metadata": {},
152+
"source": [
153+
"# Now the hardway: average, median, mode"
154+
]
155+
},
156+
{
157+
"cell_type": "code",
158+
"execution_count": null,
159+
"id": "08ee701f",
160+
"metadata": {},
161+
"outputs": [],
162+
"source": [
163+
"import csv\n",
164+
"\n",
165+
"with open(\"f1_qualifying_2022_2025.csv\", \"r\") as f1:\n"
166+
]
167+
}
168+
],
169+
"metadata": {
170+
"kernelspec": {
171+
"display_name": ".venv",
172+
"language": "python",
173+
"name": "python3"
174+
},
175+
"language_info": {
176+
"codemirror_mode": {
177+
"name": "ipython",
178+
"version": 3
179+
},
180+
"file_extension": ".py",
181+
"mimetype": "text/x-python",
182+
"name": "python",
183+
"nbconvert_exporter": "python",
184+
"pygments_lexer": "ipython3",
185+
"version": "3.13.7"
186+
}
187+
},
188+
"nbformat": 4,
189+
"nbformat_minor": 5
190+
}

Project_2.ipynb

Whitespace-only changes.

_toc.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
format: jb-book
22
root: index
33
chapters:
4-
- file: lecture_16_example
4+
- file: lecture_16_example
5+
- file: Project_1
6+
- file: Project_2

0 commit comments

Comments
 (0)