Skip to content

Commit 9ffb4d9

Browse files
committed
added juypter notebook formatter
1 parent d6372d7 commit 9ffb4d9

File tree

4 files changed

+102
-33
lines changed

4 files changed

+102
-33
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test:
66
python -m pytest -vv *.py
77

88
format:
9-
black *.py
9+
black *.py *.ipynb
1010

1111
lint:
1212
pylint --disable=R,C --ignore-patterns=test_.*?py *.py

create_sqlite3.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
cursor = db.cursor()
1111

1212
# Create a table
13-
cursor.execute("CREATE TABLE games (Game_Date,Game_Day,Distance,Game_Number,Game_Number1,FULL_GAME,Distance_From_Home,Time,Game_Type,Level,Competition_System,Stage,Site,Team_Home_vs_Away,Poisition,Other_Officials,Color_Home_vs_Away,Score,Score_Time_Home ,Score_Time_Away,Kick_off,Attack_Direction,Duration,Ball_Size,Number_of_Players,Weather,Temperature_Celsius,Report,YC_Count,YCs_Count,RC_Count);")
13+
cursor.execute(
14+
"CREATE TABLE games (Game_Date,Game_Day,Distance,Game_Number,Game_Number1,FULL_GAME,Distance_From_Home,Time,Game_Type,Level,Competition_System,Stage,Site,Team_Home_vs_Away,Poisition,Other_Officials,Color_Home_vs_Away,Score,Score_Time_Home ,Score_Time_Away,Kick_off,Attack_Direction,Duration,Ball_Size,Number_of_Players,Weather,Temperature_Celsius,Report,YC_Count,YCs_Count,RC_Count);"
15+
)
1416

1517
# Read the CSV file
1618
with open("Game Report.csv", "r") as f:

demo.ipynb

Lines changed: 96 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": 2,
66
"metadata": {},
77
"outputs": [],
88
"source": [
@@ -13,17 +13,17 @@
1313
},
1414
{
1515
"cell_type": "code",
16-
"execution_count": 2,
16+
"execution_count": 3,
1717
"metadata": {},
1818
"outputs": [],
1919
"source": [
2020
"# create a connection to a database\n",
21-
"db = sqlite3.connect('games.db')"
21+
"db = sqlite3.connect(\"games.db\")"
2222
]
2323
},
2424
{
2525
"cell_type": "code",
26-
"execution_count": 3,
26+
"execution_count": 4,
2727
"metadata": {},
2828
"outputs": [],
2929
"source": [
@@ -33,16 +33,16 @@
3333
},
3434
{
3535
"cell_type": "code",
36-
"execution_count": 4,
36+
"execution_count": 5,
3737
"metadata": {},
3838
"outputs": [
3939
{
4040
"data": {
4141
"text/plain": [
42-
"<sqlite3.Cursor at 0x7fe2e60417c0>"
42+
"<sqlite3.Cursor at 0x7f10fa1712c0>"
4343
]
4444
},
45-
"execution_count": 4,
45+
"execution_count": 5,
4646
"metadata": {},
4747
"output_type": "execute_result"
4848
}
@@ -54,7 +54,7 @@
5454
},
5555
{
5656
"cell_type": "code",
57-
"execution_count": 5,
57+
"execution_count": 6,
5858
"metadata": {},
5959
"outputs": [
6060
{
@@ -93,7 +93,7 @@
9393
" '1')"
9494
]
9595
},
96-
"execution_count": 5,
96+
"execution_count": 6,
9797
"metadata": {},
9898
"output_type": "execute_result"
9999
}
@@ -105,16 +105,16 @@
105105
},
106106
{
107107
"cell_type": "code",
108-
"execution_count": 6,
108+
"execution_count": 7,
109109
"metadata": {},
110110
"outputs": [
111111
{
112112
"data": {
113113
"text/plain": [
114-
"<sqlite3.Cursor at 0x7fe2e60417c0>"
114+
"<sqlite3.Cursor at 0x7f10fa1712c0>"
115115
]
116116
},
117-
"execution_count": 6,
117+
"execution_count": 7,
118118
"metadata": {},
119119
"output_type": "execute_result"
120120
}
@@ -126,7 +126,7 @@
126126
},
127127
{
128128
"cell_type": "code",
129-
"execution_count": 7,
129+
"execution_count": 8,
130130
"metadata": {},
131131
"outputs": [
132132
{
@@ -165,7 +165,7 @@
165165
" (30, 'RC_Count', '', 0, None, 0)]"
166166
]
167167
},
168-
"execution_count": 7,
168+
"execution_count": 8,
169169
"metadata": {},
170170
"output_type": "execute_result"
171171
}
@@ -177,7 +177,7 @@
177177
},
178178
{
179179
"cell_type": "code",
180-
"execution_count": 8,
180+
"execution_count": 9,
181181
"metadata": {},
182182
"outputs": [
183183
{
@@ -192,12 +192,14 @@
192192
"# select the game played as 11 vs 11\n",
193193
"cursor.execute(\"select * from games where Number_of_Players == '11';\")\n",
194194
"game11v11 = cursor.fetchall()\n",
195-
"print(f\"I have officiated {len(game11v11)} 11 vs 11 games from January 2021 to July 2022.\")"
195+
"print(\n",
196+
" f\"I have officiated {len(game11v11)} 11 vs 11 games from January 2021 to July 2022.\"\n",
197+
")"
196198
]
197199
},
198200
{
199201
"cell_type": "code",
200-
"execution_count": 9,
202+
"execution_count": 10,
201203
"metadata": {},
202204
"outputs": [
203205
{
@@ -217,7 +219,7 @@
217219
},
218220
{
219221
"cell_type": "code",
220-
"execution_count": 10,
222+
"execution_count": 11,
221223
"metadata": {},
222224
"outputs": [
223225
{
@@ -237,7 +239,7 @@
237239
},
238240
{
239241
"cell_type": "code",
240-
"execution_count": 11,
242+
"execution_count": 12,
241243
"metadata": {},
242244
"outputs": [
243245
{
@@ -252,12 +254,14 @@
252254
"# select the game officiated as assistant referee\n",
253255
"cursor.execute(\"select * from games where Poisition like 'AR%';\")\n",
254256
"AR = cursor.fetchall()\n",
255-
"print(f\"I have officiated {len(AR)} games as assistant referee from January 2021 to July 2022.\")"
257+
"print(\n",
258+
" f\"I have officiated {len(AR)} games as assistant referee from January 2021 to July 2022.\"\n",
259+
")"
256260
]
257261
},
258262
{
259263
"cell_type": "code",
260-
"execution_count": 12,
264+
"execution_count": 13,
261265
"metadata": {},
262266
"outputs": [
263267
{
@@ -272,12 +276,14 @@
272276
"# select the game officiated as 4th official\n",
273277
"cursor.execute(\"select * from games where Poisition == '4th O';\")\n",
274278
"fourthO = cursor.fetchall()\n",
275-
"print(f\"I have officiated {len(fourthO)} games as 4th official from January 2021 to July 2022.\")"
279+
"print(\n",
280+
" f\"I have officiated {len(fourthO)} games as 4th official from January 2021 to July 2022.\"\n",
281+
")"
276282
]
277283
},
278284
{
279285
"cell_type": "code",
280-
"execution_count": 24,
286+
"execution_count": 14,
281287
"metadata": {},
282288
"outputs": [
283289
{
@@ -292,12 +298,14 @@
292298
"# How many Yellow Cards have I given as a referee?\n",
293299
"cursor.execute(\"select sum(YC_Count) from games where Poisition == 'RR';\")\n",
294300
"YC = cursor.fetchall()\n",
295-
"print(f\"I have given {YC[0][0]:.0f} Yellow Cards as a referee from January 2021 to July 2022.\")"
301+
"print(\n",
302+
" f\"I have given {YC[0][0]:.0f} Yellow Cards as a referee from January 2021 to July 2022.\"\n",
303+
")"
296304
]
297305
},
298306
{
299307
"cell_type": "code",
300-
"execution_count": 25,
308+
"execution_count": 15,
301309
"metadata": {},
302310
"outputs": [
303311
{
@@ -312,12 +320,14 @@
312320
"# How many Red Cards have I given as a referee?\n",
313321
"cursor.execute(\"select sum(RC_Count) from games where Poisition == 'RR';\")\n",
314322
"RC = cursor.fetchall()\n",
315-
"print(f\"I have given {RC[0][0]:.0f} Red Cards as a referee from January 2021 to July 2022.\")"
323+
"print(\n",
324+
" f\"I have given {RC[0][0]:.0f} Red Cards as a referee from January 2021 to July 2022.\"\n",
325+
")"
316326
]
317327
},
318328
{
319329
"cell_type": "code",
320-
"execution_count": 22,
330+
"execution_count": 16,
321331
"metadata": {},
322332
"outputs": [
323333
{
@@ -332,12 +342,14 @@
332342
"# How many Yellow Cards per game as a referee?\n",
333343
"cursor.execute(\"select avg(YC_Count) from games where Poisition == 'RR';\")\n",
334344
"YC_per_game = cursor.fetchall()\n",
335-
"print(f\"I have given {YC_per_game[0][0]:.2f} Yellow Cards per game as a referee from January 2021 to July 2022.\")"
345+
"print(\n",
346+
" f\"I have given {YC_per_game[0][0]:.2f} Yellow Cards per game as a referee from January 2021 to July 2022.\"\n",
347+
")"
336348
]
337349
},
338350
{
339351
"cell_type": "code",
340-
"execution_count": 23,
352+
"execution_count": 17,
341353
"metadata": {},
342354
"outputs": [
343355
{
@@ -352,7 +364,61 @@
352364
"# How many Red Cards per game as a referee?\n",
353365
"cursor.execute(\"select avg(RC_Count) from games where Poisition == 'RR';\")\n",
354366
"RC_per_game = cursor.fetchall()\n",
355-
"print(f\"I have given {RC_per_game[0][0]:.2f} Red Cards per game as a referee from January 2021 to July 2022.\")"
367+
"print(\n",
368+
" f\"I have given {RC_per_game[0][0]:.2f} Red Cards per game as a referee from January 2021 to July 2022.\"\n",
369+
")"
370+
]
371+
},
372+
{
373+
"cell_type": "code",
374+
"execution_count": 33,
375+
"metadata": {},
376+
"outputs": [
377+
{
378+
"name": "stdout",
379+
"output_type": "stream",
380+
"text": [
381+
"The most cards shown in a game as a referee was 11, (YC: 9, 2nd YC: 2, and RC: 2), 成都龙耀 v 德驰娱乐 (Score:1:2, 成甲总Semi-Final) on 1/16/22 at 锦江仁德 A4.\n",
382+
"My running distance was 8.13 kilometers. Other officials were: 秦立港、李阳、李飞.\n"
383+
]
384+
}
385+
],
386+
"source": [
387+
"# The most cards shown in a game as a referee\n",
388+
"cursor.execute(\n",
389+
" \"select Game_Date, YC_Count, YCs_Count, RC_Count, max(YC_Count + RC_Count) as Cards_Max, Team_Home_vs_Away, Game_Type, Stage, Site, Score, Distance, Other_Officials from games where Poisition == 'RR';\"\n",
390+
")\n",
391+
"Cards_Max = cursor.fetchall()\n",
392+
"print(\n",
393+
" f\"The most cards shown in a game as a referee was {Cards_Max[0][4]:.0f}, (YC: {Cards_Max[0][1]}, 2nd YC: {Cards_Max[0][2]}, and RC: {Cards_Max[0][3]}), {Cards_Max[0][5]} (Score:{Cards_Max[0][9]}, {Cards_Max[0][6]}{Cards_Max[0][7]}) on {Cards_Max[0][0]} at {Cards_Max[0][8]}.\"\n",
394+
")\n",
395+
"print(\n",
396+
" f\"My running distance was {Cards_Max[0][10]} kilometers. Other officials were: {Cards_Max[0][11]}.\"\n",
397+
")"
398+
]
399+
},
400+
{
401+
"cell_type": "code",
402+
"execution_count": 36,
403+
"metadata": {},
404+
"outputs": [
405+
{
406+
"name": "stdout",
407+
"output_type": "stream",
408+
"text": [
409+
"The most distance covered in a game as a referee was 9.90 kilometers, 成都之己 v 成都大学 (Score:2:2, 成超 22 Season YC: 2, 2nd YC: 0, and RC: 0) on 7/3/22 at 城东体育公园.\n"
410+
]
411+
}
412+
],
413+
"source": [
414+
"# The most distanced covered in a game as a referee\n",
415+
"cursor.execute(\n",
416+
" \"select Game_Date, YC_Count, YCs_Count, RC_Count, max(Distance) as Distance_Max, Team_Home_vs_Away, Game_Type, Stage, Site, Score, Other_Officials from games where Poisition == 'RR';\"\n",
417+
")\n",
418+
"Distance_Max = cursor.fetchall()\n",
419+
"print(\n",
420+
" f\"The most distance covered in a game as a referee was {Distance_Max[0][4]} kilometers, {Distance_Max[0][5]} (Score:{Distance_Max[0][9]}, {Distance_Max[0][6]} 22 {Distance_Max[0][7]} YC: {Distance_Max[0][1]}, 2nd YC: {Distance_Max[0][2]}, and RC: {Distance_Max[0][3]}) on {Distance_Max[0][0]} at {Distance_Max[0][8]}.\"\n",
421+
")"
356422
]
357423
}
358424
],

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pytest
22
pylint
33
click
4-
pandas
4+
pandas
5+
black[jupyter]

0 commit comments

Comments
 (0)