rozwiazanka

This commit is contained in:
Maksymilian Stachowiak 2023-11-26 09:12:43 +01:00
parent c37b42a4f4
commit 92dca8796c
6 changed files with 2026 additions and 230 deletions

60
zajecia2/customers.csv Normal file
View File

@ -0,0 +1,60 @@
,CustomerId,FirstName,LastName,Company,Address,City,State,Country,PostalCode,Phone,Fax,Email,SupportRepId
0,1,Luís,Gonçalves,Embraer - Empresa Brasileira de Aeronáutica S.A.,"Av. Brigadeiro Faria Lima, 2170",São José dos Campos,SP,Brazil,12227-000,+55 (12) 3923-5555,+55 (12) 3923-5566,luisg@embraer.com.br,3
1,2,Leonie,Köhler,,Theodor-Heuss-Straße 34,Stuttgart,,Germany,70174,+49 0711 2842222,,leonekohler@surfeu.de,5
2,3,François,Tremblay,,1498 rue Bélanger,Montréal,QC,Canada,H2G 1A7,+1 (514) 721-4711,,ftremblay@gmail.com,3
3,4,Bjørn,Hansen,,Ullevålsveien 14,Oslo,,Norway,0171,+47 22 44 22 22,,bjorn.hansen@yahoo.no,4
4,5,František,Wichterlová,JetBrains s.r.o.,Klanova 9/506,Prague,,Czech Republic,14700,+420 2 4172 5555,+420 2 4172 5555,frantisekw@jetbrains.com,4
5,6,Helena,Holý,,Rilská 3174/6,Prague,,Czech Republic,14300,+420 2 4177 0449,,hholy@gmail.com,5
6,7,Astrid,Gruber,,"Rotenturmstraße 4, 1010 Innere Stadt",Vienne,,Austria,1010,+43 01 5134505,,astrid.gruber@apple.at,5
7,8,Daan,Peeters,,Grétrystraat 63,Brussels,,Belgium,1000,+32 02 219 03 03,,daan_peeters@apple.be,4
8,9,Kara,Nielsen,,Sønder Boulevard 51,Copenhagen,,Denmark,1720,+453 3331 9991,,kara.nielsen@jubii.dk,4
9,10,Eduardo,Martins,Woodstock Discos,"Rua Dr. Falcão Filho, 155",São Paulo,SP,Brazil,01007-010,+55 (11) 3033-5446,+55 (11) 3033-4564,eduardo@woodstock.com.br,4
10,11,Alexandre,Rocha,Banco do Brasil S.A.,"Av. Paulista, 2022",São Paulo,SP,Brazil,01310-200,+55 (11) 3055-3278,+55 (11) 3055-8131,alero@uol.com.br,5
11,12,Roberto,Almeida,Riotur,"Praça Pio X, 119",Rio de Janeiro,RJ,Brazil,20040-020,+55 (21) 2271-7000,+55 (21) 2271-7070,roberto.almeida@riotur.gov.br,3
12,13,Fernanda,Ramos,,Qe 7 Bloco G,Brasília,DF,Brazil,71020-677,+55 (61) 3363-5547,+55 (61) 3363-7855,fernadaramos4@uol.com.br,4
13,14,Mark,Philips,Telus,8210 111 ST NW,Edmonton,AB,Canada,T6G 2C7,+1 (780) 434-4554,+1 (780) 434-5565,mphilips12@shaw.ca,5
14,15,Jennifer,Peterson,Rogers Canada,700 W Pender Street,Vancouver,BC,Canada,V6C 1G8,+1 (604) 688-2255,+1 (604) 688-8756,jenniferp@rogers.ca,3
15,16,Frank,Harris,Google Inc.,1600 Amphitheatre Parkway,Mountain View,CA,USA,94043-1351,+1 (650) 253-0000,+1 (650) 253-0000,fharris@google.com,4
16,17,Jack,Smith,Microsoft Corporation,1 Microsoft Way,Redmond,WA,USA,98052-8300,+1 (425) 882-8080,+1 (425) 882-8081,jacksmith@microsoft.com,5
17,18,Michelle,Brooks,,627 Broadway,New York,NY,USA,10012-2612,+1 (212) 221-3546,+1 (212) 221-4679,michelleb@aol.com,3
18,19,Tim,Goyer,Apple Inc.,1 Infinite Loop,Cupertino,CA,USA,95014,+1 (408) 996-1010,+1 (408) 996-1011,tgoyer@apple.com,3
19,20,Dan,Miller,,541 Del Medio Avenue,Mountain View,CA,USA,94040-111,+1 (650) 644-3358,,dmiller@comcast.com,4
20,21,Kathy,Chase,,801 W 4th Street,Reno,NV,USA,89503,+1 (775) 223-7665,,kachase@hotmail.com,5
21,22,Heather,Leacock,,120 S Orange Ave,Orlando,FL,USA,32801,+1 (407) 999-7788,,hleacock@gmail.com,4
22,23,John,Gordon,,69 Salem Street,Boston,MA,USA,2113,+1 (617) 522-1333,,johngordon22@yahoo.com,4
23,24,Frank,Ralston,,162 E Superior Street,Chicago,IL,USA,60611,+1 (312) 332-3232,,fralston@gmail.com,3
24,25,Victor,Stevens,,319 N. Frances Street,Madison,WI,USA,53703,+1 (608) 257-0597,,vstevens@yahoo.com,5
25,26,Richard,Cunningham,,2211 W Berry Street,Fort Worth,TX,USA,76110,+1 (817) 924-7272,,ricunningham@hotmail.com,4
26,27,Patrick,Gray,,1033 N Park Ave,Tucson,AZ,USA,85719,+1 (520) 622-4200,,patrick.gray@aol.com,4
27,28,Julia,Barnett,,302 S 700 E,Salt Lake City,UT,USA,84102,+1 (801) 531-7272,,jubarnett@gmail.com,5
28,29,Robert,Brown,,796 Dundas Street West,Toronto,ON,Canada,M6J 1V1,+1 (416) 363-8888,,robbrown@shaw.ca,3
29,30,Edward,Francis,,230 Elgin Street,Ottawa,ON,Canada,K2P 1L7,+1 (613) 234-3322,,edfrancis@yachoo.ca,3
30,31,Martha,Silk,,194A Chain Lake Drive,Halifax,NS,Canada,B3S 1C5,+1 (902) 450-0450,,marthasilk@gmail.com,5
31,32,Aaron,Mitchell,,696 Osborne Street,Winnipeg,MB,Canada,R3L 2B9,+1 (204) 452-6452,,aaronmitchell@yahoo.ca,4
32,33,Ellie,Sullivan,,5112 48 Street,Yellowknife,NT,Canada,X1A 1N6,+1 (867) 920-2233,,ellie.sullivan@shaw.ca,3
33,34,João,Fernandes,,Rua da Assunção 53,Lisbon,,Portugal,,+351 (213) 466-111,,jfernandes@yahoo.pt,4
34,35,Madalena,Sampaio,,"Rua dos Campeões Europeus de Viena, 4350",Porto,,Portugal,,+351 (225) 022-448,,masampaio@sapo.pt,4
35,36,Hannah,Schneider,,Tauentzienstraße 8,Berlin,,Germany,10789,+49 030 26550280,,hannah.schneider@yahoo.de,5
36,37,Fynn,Zimmermann,,Berger Straße 10,Frankfurt,,Germany,60316,+49 069 40598889,,fzimmermann@yahoo.de,3
37,38,Niklas,Schröder,,Barbarossastraße 19,Berlin,,Germany,10779,+49 030 2141444,,nschroder@surfeu.de,3
38,39,Camille,Bernard,,"4, Rue Milton",Paris,,France,75009,+33 01 49 70 65 65,,camille.bernard@yahoo.fr,4
39,40,Dominique,Lefebvre,,"8, Rue Hanovre",Paris,,France,75002,+33 01 47 42 71 71,,dominiquelefebvre@gmail.com,4
40,41,Marc,Dubois,,"11, Place Bellecour",Lyon,,France,69002,+33 04 78 30 30 30,,marc.dubois@hotmail.com,5
41,42,Wyatt,Girard,,"9, Place Louis Barthou",Bordeaux,,France,33000,+33 05 56 96 96 96,,wyatt.girard@yahoo.fr,3
42,43,Isabelle,Mercier,,"68, Rue Jouvence",Dijon,,France,21000,+33 03 80 73 66 99,,isabelle_mercier@apple.fr,3
43,44,Terhi,Hämäläinen,,Porthaninkatu 9,Helsinki,,Finland,00530,+358 09 870 2000,,terhi.hamalainen@apple.fi,3
44,45,Ladislav,Kovács,,Erzsébet krt. 58.,Budapest,,Hungary,H-1073,,,ladislav_kovacs@apple.hu,3
45,46,Hugh,O'Reilly,,3 Chatham Street,Dublin,Dublin,Ireland,,+353 01 6792424,,hughoreilly@apple.ie,3
46,47,Lucas,Mancini,,"Via Degli Scipioni, 43",Rome,RM,Italy,00192,+39 06 39733434,,lucas.mancini@yahoo.it,5
47,48,Johannes,Van der Berg,,Lijnbaansgracht 120bg,Amsterdam,VV,Netherlands,1016,+31 020 6223130,,johavanderberg@yahoo.nl,5
48,49,Stanisław,Wójcik,,Ordynacka 10,Warsaw,,Poland,00-358,+48 22 828 37 39,,stanisław.wójcik@wp.pl,4
49,50,Enrique,Muñoz,,C/ San Bernardo 85,Madrid,,Spain,28015,+34 914 454 454,,enrique_munoz@yahoo.es,5
50,51,Joakim,Johansson,,Celsiusg. 9,Stockholm,,Sweden,11230,+46 08-651 52 52,,joakim.johansson@yahoo.se,5
51,52,Emma,Jones,,202 Hoxton Street,London,,United Kingdom,N1 5LH,+44 020 7707 0707,,emma_jones@hotmail.com,3
52,53,Phil,Hughes,,113 Lupus St,London,,United Kingdom,SW1V 3EN,+44 020 7976 5722,,phil.hughes@gmail.com,3
53,54,Steve,Murray,,110 Raeburn Pl,Edinburgh ,,United Kingdom,EH4 1HH,+44 0131 315 3300,,steve.murray@yahoo.uk,5
54,55,Mark,Taylor,,421 Bourke Street,Sidney,NSW,Australia,2010,+61 (02) 9332 3633,,mark.taylor@yahoo.au,4
55,56,Diego,Gutiérrez,,307 Macacha Güemes,Buenos Aires,,Argentina,1106,+54 (0)11 4311 4333,,diego.gutierrez@yahoo.ar,4
56,57,Luis,Rojas,,"Calle Lira, 198",Santiago,,Chile,,+56 (0)2 635 4444,,luisrojas@yahoo.cl,5
57,58,Manoj,Pareek,,"12,Community Centre",Delhi,,India,110017,+91 0124 39883988,,manoj.pareek@rediff.com,3
58,59,Puja,Srivastava,,"3,Raj Bhavan Road",Bangalore,,India,560001,+91 080 22289999,,puja_srivastava@yahoo.in,3
1 CustomerId FirstName LastName Company Address City State Country PostalCode Phone Fax Email SupportRepId
2 0 1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 luisg@embraer.com.br 3
3 1 2 Leonie Köhler Theodor-Heuss-Straße 34 Stuttgart Germany 70174 +49 0711 2842222 leonekohler@surfeu.de 5
4 2 3 François Tremblay 1498 rue Bélanger Montréal QC Canada H2G 1A7 +1 (514) 721-4711 ftremblay@gmail.com 3
5 3 4 Bjørn Hansen Ullevålsveien 14 Oslo Norway 0171 +47 22 44 22 22 bjorn.hansen@yahoo.no 4
6 4 5 František Wichterlová JetBrains s.r.o. Klanova 9/506 Prague Czech Republic 14700 +420 2 4172 5555 +420 2 4172 5555 frantisekw@jetbrains.com 4
7 5 6 Helena Holý Rilská 3174/6 Prague Czech Republic 14300 +420 2 4177 0449 hholy@gmail.com 5
8 6 7 Astrid Gruber Rotenturmstraße 4, 1010 Innere Stadt Vienne Austria 1010 +43 01 5134505 astrid.gruber@apple.at 5
9 7 8 Daan Peeters Grétrystraat 63 Brussels Belgium 1000 +32 02 219 03 03 daan_peeters@apple.be 4
10 8 9 Kara Nielsen Sønder Boulevard 51 Copenhagen Denmark 1720 +453 3331 9991 kara.nielsen@jubii.dk 4
11 9 10 Eduardo Martins Woodstock Discos Rua Dr. Falcão Filho, 155 São Paulo SP Brazil 01007-010 +55 (11) 3033-5446 +55 (11) 3033-4564 eduardo@woodstock.com.br 4
12 10 11 Alexandre Rocha Banco do Brasil S.A. Av. Paulista, 2022 São Paulo SP Brazil 01310-200 +55 (11) 3055-3278 +55 (11) 3055-8131 alero@uol.com.br 5
13 11 12 Roberto Almeida Riotur Praça Pio X, 119 Rio de Janeiro RJ Brazil 20040-020 +55 (21) 2271-7000 +55 (21) 2271-7070 roberto.almeida@riotur.gov.br 3
14 12 13 Fernanda Ramos Qe 7 Bloco G Brasília DF Brazil 71020-677 +55 (61) 3363-5547 +55 (61) 3363-7855 fernadaramos4@uol.com.br 4
15 13 14 Mark Philips Telus 8210 111 ST NW Edmonton AB Canada T6G 2C7 +1 (780) 434-4554 +1 (780) 434-5565 mphilips12@shaw.ca 5
16 14 15 Jennifer Peterson Rogers Canada 700 W Pender Street Vancouver BC Canada V6C 1G8 +1 (604) 688-2255 +1 (604) 688-8756 jenniferp@rogers.ca 3
17 15 16 Frank Harris Google Inc. 1600 Amphitheatre Parkway Mountain View CA USA 94043-1351 +1 (650) 253-0000 +1 (650) 253-0000 fharris@google.com 4
18 16 17 Jack Smith Microsoft Corporation 1 Microsoft Way Redmond WA USA 98052-8300 +1 (425) 882-8080 +1 (425) 882-8081 jacksmith@microsoft.com 5
19 17 18 Michelle Brooks 627 Broadway New York NY USA 10012-2612 +1 (212) 221-3546 +1 (212) 221-4679 michelleb@aol.com 3
20 18 19 Tim Goyer Apple Inc. 1 Infinite Loop Cupertino CA USA 95014 +1 (408) 996-1010 +1 (408) 996-1011 tgoyer@apple.com 3
21 19 20 Dan Miller 541 Del Medio Avenue Mountain View CA USA 94040-111 +1 (650) 644-3358 dmiller@comcast.com 4
22 20 21 Kathy Chase 801 W 4th Street Reno NV USA 89503 +1 (775) 223-7665 kachase@hotmail.com 5
23 21 22 Heather Leacock 120 S Orange Ave Orlando FL USA 32801 +1 (407) 999-7788 hleacock@gmail.com 4
24 22 23 John Gordon 69 Salem Street Boston MA USA 2113 +1 (617) 522-1333 johngordon22@yahoo.com 4
25 23 24 Frank Ralston 162 E Superior Street Chicago IL USA 60611 +1 (312) 332-3232 fralston@gmail.com 3
26 24 25 Victor Stevens 319 N. Frances Street Madison WI USA 53703 +1 (608) 257-0597 vstevens@yahoo.com 5
27 25 26 Richard Cunningham 2211 W Berry Street Fort Worth TX USA 76110 +1 (817) 924-7272 ricunningham@hotmail.com 4
28 26 27 Patrick Gray 1033 N Park Ave Tucson AZ USA 85719 +1 (520) 622-4200 patrick.gray@aol.com 4
29 27 28 Julia Barnett 302 S 700 E Salt Lake City UT USA 84102 +1 (801) 531-7272 jubarnett@gmail.com 5
30 28 29 Robert Brown 796 Dundas Street West Toronto ON Canada M6J 1V1 +1 (416) 363-8888 robbrown@shaw.ca 3
31 29 30 Edward Francis 230 Elgin Street Ottawa ON Canada K2P 1L7 +1 (613) 234-3322 edfrancis@yachoo.ca 3
32 30 31 Martha Silk 194A Chain Lake Drive Halifax NS Canada B3S 1C5 +1 (902) 450-0450 marthasilk@gmail.com 5
33 31 32 Aaron Mitchell 696 Osborne Street Winnipeg MB Canada R3L 2B9 +1 (204) 452-6452 aaronmitchell@yahoo.ca 4
34 32 33 Ellie Sullivan 5112 48 Street Yellowknife NT Canada X1A 1N6 +1 (867) 920-2233 ellie.sullivan@shaw.ca 3
35 33 34 João Fernandes Rua da Assunção 53 Lisbon Portugal +351 (213) 466-111 jfernandes@yahoo.pt 4
36 34 35 Madalena Sampaio Rua dos Campeões Europeus de Viena, 4350 Porto Portugal +351 (225) 022-448 masampaio@sapo.pt 4
37 35 36 Hannah Schneider Tauentzienstraße 8 Berlin Germany 10789 +49 030 26550280 hannah.schneider@yahoo.de 5
38 36 37 Fynn Zimmermann Berger Straße 10 Frankfurt Germany 60316 +49 069 40598889 fzimmermann@yahoo.de 3
39 37 38 Niklas Schröder Barbarossastraße 19 Berlin Germany 10779 +49 030 2141444 nschroder@surfeu.de 3
40 38 39 Camille Bernard 4, Rue Milton Paris France 75009 +33 01 49 70 65 65 camille.bernard@yahoo.fr 4
41 39 40 Dominique Lefebvre 8, Rue Hanovre Paris France 75002 +33 01 47 42 71 71 dominiquelefebvre@gmail.com 4
42 40 41 Marc Dubois 11, Place Bellecour Lyon France 69002 +33 04 78 30 30 30 marc.dubois@hotmail.com 5
43 41 42 Wyatt Girard 9, Place Louis Barthou Bordeaux France 33000 +33 05 56 96 96 96 wyatt.girard@yahoo.fr 3
44 42 43 Isabelle Mercier 68, Rue Jouvence Dijon France 21000 +33 03 80 73 66 99 isabelle_mercier@apple.fr 3
45 43 44 Terhi Hämäläinen Porthaninkatu 9 Helsinki Finland 00530 +358 09 870 2000 terhi.hamalainen@apple.fi 3
46 44 45 Ladislav Kovács Erzsébet krt. 58. Budapest Hungary H-1073 ladislav_kovacs@apple.hu 3
47 45 46 Hugh O'Reilly 3 Chatham Street Dublin Dublin Ireland +353 01 6792424 hughoreilly@apple.ie 3
48 46 47 Lucas Mancini Via Degli Scipioni, 43 Rome RM Italy 00192 +39 06 39733434 lucas.mancini@yahoo.it 5
49 47 48 Johannes Van der Berg Lijnbaansgracht 120bg Amsterdam VV Netherlands 1016 +31 020 6223130 johavanderberg@yahoo.nl 5
50 48 49 Stanisław Wójcik Ordynacka 10 Warsaw Poland 00-358 +48 22 828 37 39 stanisław.wójcik@wp.pl 4
51 49 50 Enrique Muñoz C/ San Bernardo 85 Madrid Spain 28015 +34 914 454 454 enrique_munoz@yahoo.es 5
52 50 51 Joakim Johansson Celsiusg. 9 Stockholm Sweden 11230 +46 08-651 52 52 joakim.johansson@yahoo.se 5
53 51 52 Emma Jones 202 Hoxton Street London United Kingdom N1 5LH +44 020 7707 0707 emma_jones@hotmail.com 3
54 52 53 Phil Hughes 113 Lupus St London United Kingdom SW1V 3EN +44 020 7976 5722 phil.hughes@gmail.com 3
55 53 54 Steve Murray 110 Raeburn Pl Edinburgh United Kingdom EH4 1HH +44 0131 315 3300 steve.murray@yahoo.uk 5
56 54 55 Mark Taylor 421 Bourke Street Sidney NSW Australia 2010 +61 (02) 9332 3633 mark.taylor@yahoo.au 4
57 55 56 Diego Gutiérrez 307 Macacha Güemes Buenos Aires Argentina 1106 +54 (0)11 4311 4333 diego.gutierrez@yahoo.ar 4
58 56 57 Luis Rojas Calle Lira, 198 Santiago Chile +56 (0)2 635 4444 luisrojas@yahoo.cl 5
59 57 58 Manoj Pareek 12,Community Centre Delhi India 110017 +91 0124 39883988 manoj.pareek@rediff.com 3
60 58 59 Puja Srivastava 3,Raj Bhavan Road Bangalore India 560001 +91 080 22289999 puja_srivastava@yahoo.in 3

View File

@ -478,14 +478,60 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"source": []
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 0\n",
"1 1\n",
"2 2\n",
"3 3\n",
"4 4\n",
"5 5\n",
"6 6\n",
"7 7\n",
"8 8\n",
"9 9\n",
"10 10\n",
"dtype: int64 0 0\n",
"1 1\n",
"2 4\n",
"3 9\n",
"4 16\n",
"5 25\n",
"6 36\n",
"7 49\n",
"8 64\n",
"9 81\n",
"10 100\n",
"dtype: int64 0 0.0\n",
"1 1.5\n",
"2 4.0\n",
"3 7.5\n",
"4 12.0\n",
"5 17.5\n",
"6 24.0\n",
"7 31.5\n",
"8 40.0\n",
"9 49.5\n",
"10 60.0\n",
"dtype: float64\n"
]
}
],
"source": [
"n = pd.Series(range(0, 11))\n",
"n2 = n * n\n",
"trojkatne = n + n2 / 2\n",
"print(n, n2, trojkatne)"
]
},
{
"cell_type": "markdown",
@ -522,7 +568,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 14,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -581,7 +627,7 @@
"July 779511 194316"
]
},
"execution_count": 9,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
@ -607,7 +653,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 15,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -666,7 +712,7 @@
"2 779511 194316"
]
},
"execution_count": 10,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
@ -696,7 +742,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 16,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -780,7 +826,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 17,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -975,7 +1021,7 @@
"[175 rows x 8 columns]"
]
},
"execution_count": 12,
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
@ -988,7 +1034,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 18,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -1144,7 +1190,7 @@
"5 0 0 373450 8.0500 NaN S "
]
},
"execution_count": 13,
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
@ -1167,7 +1213,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 19,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -1175,103 +1221,27 @@
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>start_date</th>\n",
" <th>start_station_code</th>\n",
" <th>end_date</th>\n",
" <th>end_station_code</th>\n",
" <th>duration_sec</th>\n",
" <th>is_member</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2019-04-14 07:55:22</td>\n",
" <td>6001</td>\n",
" <td>2019-04-14 08:07:16</td>\n",
" <td>6132</td>\n",
" <td>713</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2019-04-14 07:59:31</td>\n",
" <td>6411</td>\n",
" <td>2019-04-14 08:09:18</td>\n",
" <td>6411</td>\n",
" <td>587</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2019-04-14 07:59:55</td>\n",
" <td>6097</td>\n",
" <td>2019-04-14 08:12:11</td>\n",
" <td>6036</td>\n",
" <td>736</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2019-04-14 07:59:57</td>\n",
" <td>6310</td>\n",
" <td>2019-04-14 08:27:58</td>\n",
" <td>6345</td>\n",
" <td>1680</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>2019-04-14 08:00:37</td>\n",
" <td>7029</td>\n",
" <td>2019-04-14 08:14:12</td>\n",
" <td>6250</td>\n",
" <td>814</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" start_date start_station_code end_date \\\n",
"0 2019-04-14 07:55:22 6001 2019-04-14 08:07:16 \n",
"1 2019-04-14 07:59:31 6411 2019-04-14 08:09:18 \n",
"2 2019-04-14 07:59:55 6097 2019-04-14 08:12:11 \n",
"3 2019-04-14 07:59:57 6310 2019-04-14 08:27:58 \n",
"4 2019-04-14 08:00:37 7029 2019-04-14 08:14:12 \n",
"\n",
" end_station_code duration_sec is_member \n",
"0 6132 713 1 \n",
"1 6411 587 1 \n",
"2 6036 736 1 \n",
"3 6345 1680 1 \n",
"4 6250 814 0 "
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
"ename": "ImportError",
"evalue": "Missing optional dependency 'openpyxl'. Use pip or conda to install openpyxl.",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"File \u001b[1;32mc:\\software\\python3\\lib\\site-packages\\pandas\\compat\\_optional.py:142\u001b[0m, in \u001b[0;36mimport_optional_dependency\u001b[1;34m(name, extra, errors, min_version)\u001b[0m\n\u001b[0;32m 141\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m--> 142\u001b[0m module \u001b[39m=\u001b[39m importlib\u001b[39m.\u001b[39;49mimport_module(name)\n\u001b[0;32m 143\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mImportError\u001b[39;00m:\n",
"File \u001b[1;32mc:\\software\\python3\\lib\\importlib\\__init__.py:126\u001b[0m, in \u001b[0;36mimport_module\u001b[1;34m(name, package)\u001b[0m\n\u001b[0;32m 125\u001b[0m level \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m \u001b[39m1\u001b[39m\n\u001b[1;32m--> 126\u001b[0m \u001b[39mreturn\u001b[39;00m _bootstrap\u001b[39m.\u001b[39;49m_gcd_import(name[level:], package, level)\n",
"File \u001b[1;32m<frozen importlib._bootstrap>:1050\u001b[0m, in \u001b[0;36m_gcd_import\u001b[1;34m(name, package, level)\u001b[0m\n",
"File \u001b[1;32m<frozen importlib._bootstrap>:1027\u001b[0m, in \u001b[0;36m_find_and_load\u001b[1;34m(name, import_)\u001b[0m\n",
"File \u001b[1;32m<frozen importlib._bootstrap>:1004\u001b[0m, in \u001b[0;36m_find_and_load_unlocked\u001b[1;34m(name, import_)\u001b[0m\n",
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'openpyxl'",
"\nDuring handling of the above exception, another exception occurred:\n",
"\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32mj:\\Python\\2023-programowanie-w-pythonie\\zajecia2\\data_analysis.ipynb Cell 39\u001b[0m line \u001b[0;36m1\n\u001b[1;32m----> <a href='vscode-notebook-cell:/j%3A/Python/2023-programowanie-w-pythonie/zajecia2/data_analysis.ipynb#X53sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m df \u001b[39m=\u001b[39m pd\u001b[39m.\u001b[39;49mread_excel(\u001b[39m'\u001b[39;49m\u001b[39m./bikes.xlsx\u001b[39;49m\u001b[39m'\u001b[39;49m, engine\u001b[39m=\u001b[39;49m\u001b[39m'\u001b[39;49m\u001b[39mopenpyxl\u001b[39;49m\u001b[39m'\u001b[39;49m, nrows\u001b[39m=\u001b[39;49m\u001b[39m5\u001b[39;49m)\n\u001b[0;32m <a href='vscode-notebook-cell:/j%3A/Python/2023-programowanie-w-pythonie/zajecia2/data_analysis.ipynb#X53sZmlsZQ%3D%3D?line=1'>2</a>\u001b[0m df\n",
"File \u001b[1;32mc:\\software\\python3\\lib\\site-packages\\pandas\\io\\excel\\_base.py:478\u001b[0m, in \u001b[0;36mread_excel\u001b[1;34m(io, sheet_name, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, parse_dates, date_parser, date_format, thousands, decimal, comment, skipfooter, storage_options, dtype_backend)\u001b[0m\n\u001b[0;32m 476\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39misinstance\u001b[39m(io, ExcelFile):\n\u001b[0;32m 477\u001b[0m should_close \u001b[39m=\u001b[39m \u001b[39mTrue\u001b[39;00m\n\u001b[1;32m--> 478\u001b[0m io \u001b[39m=\u001b[39m ExcelFile(io, storage_options\u001b[39m=\u001b[39;49mstorage_options, engine\u001b[39m=\u001b[39;49mengine)\n\u001b[0;32m 479\u001b[0m \u001b[39melif\u001b[39;00m engine \u001b[39mand\u001b[39;00m engine \u001b[39m!=\u001b[39m io\u001b[39m.\u001b[39mengine:\n\u001b[0;32m 480\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mValueError\u001b[39;00m(\n\u001b[0;32m 481\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mEngine should not be specified when passing \u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m 482\u001b[0m \u001b[39m\"\u001b[39m\u001b[39man ExcelFile - ExcelFile already has the engine set\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m 483\u001b[0m )\n",
"File \u001b[1;32mc:\\software\\python3\\lib\\site-packages\\pandas\\io\\excel\\_base.py:1513\u001b[0m, in \u001b[0;36mExcelFile.__init__\u001b[1;34m(self, path_or_buffer, engine, storage_options)\u001b[0m\n\u001b[0;32m 1510\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mengine \u001b[39m=\u001b[39m engine\n\u001b[0;32m 1511\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mstorage_options \u001b[39m=\u001b[39m storage_options\n\u001b[1;32m-> 1513\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_reader \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_engines[engine](\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_io, storage_options\u001b[39m=\u001b[39;49mstorage_options)\n",
"File \u001b[1;32mc:\\software\\python3\\lib\\site-packages\\pandas\\io\\excel\\_openpyxl.py:548\u001b[0m, in \u001b[0;36mOpenpyxlReader.__init__\u001b[1;34m(self, filepath_or_buffer, storage_options)\u001b[0m\n\u001b[0;32m 533\u001b[0m \u001b[39m@doc\u001b[39m(storage_options\u001b[39m=\u001b[39m_shared_docs[\u001b[39m\"\u001b[39m\u001b[39mstorage_options\u001b[39m\u001b[39m\"\u001b[39m])\n\u001b[0;32m 534\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m__init__\u001b[39m(\n\u001b[0;32m 535\u001b[0m \u001b[39mself\u001b[39m,\n\u001b[0;32m 536\u001b[0m filepath_or_buffer: FilePath \u001b[39m|\u001b[39m ReadBuffer[\u001b[39mbytes\u001b[39m],\n\u001b[0;32m 537\u001b[0m storage_options: StorageOptions \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m,\n\u001b[0;32m 538\u001b[0m ) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m \u001b[39mNone\u001b[39;00m:\n\u001b[0;32m 539\u001b[0m \u001b[39m \u001b[39m\u001b[39m\"\"\"\u001b[39;00m\n\u001b[0;32m 540\u001b[0m \u001b[39m Reader using openpyxl engine.\u001b[39;00m\n\u001b[0;32m 541\u001b[0m \n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 546\u001b[0m \u001b[39m {storage_options}\u001b[39;00m\n\u001b[0;32m 547\u001b[0m \u001b[39m \"\"\"\u001b[39;00m\n\u001b[1;32m--> 548\u001b[0m import_optional_dependency(\u001b[39m\"\u001b[39;49m\u001b[39mopenpyxl\u001b[39;49m\u001b[39m\"\u001b[39;49m)\n\u001b[0;32m 549\u001b[0m \u001b[39msuper\u001b[39m()\u001b[39m.\u001b[39m\u001b[39m__init__\u001b[39m(filepath_or_buffer, storage_options\u001b[39m=\u001b[39mstorage_options)\n",
"File \u001b[1;32mc:\\software\\python3\\lib\\site-packages\\pandas\\compat\\_optional.py:145\u001b[0m, in \u001b[0;36mimport_optional_dependency\u001b[1;34m(name, extra, errors, min_version)\u001b[0m\n\u001b[0;32m 143\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mImportError\u001b[39;00m:\n\u001b[0;32m 144\u001b[0m \u001b[39mif\u001b[39;00m errors \u001b[39m==\u001b[39m \u001b[39m\"\u001b[39m\u001b[39mraise\u001b[39m\u001b[39m\"\u001b[39m:\n\u001b[1;32m--> 145\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mImportError\u001b[39;00m(msg)\n\u001b[0;32m 146\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mNone\u001b[39;00m\n\u001b[0;32m 148\u001b[0m \u001b[39m# Handle submodules: if we have submodule, grab parent module from sys.modules\u001b[39;00m\n",
"\u001b[1;31mImportError\u001b[0m: Missing optional dependency 'openpyxl'. Use pip or conda to install openpyxl."
]
}
],
"source": [
@ -1293,7 +1263,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 20,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -1409,7 +1379,7 @@
"[347 rows x 2 columns]"
]
},
"execution_count": 15,
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
@ -1422,23 +1392,13 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 21,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2023-11-17 15:53:28,542 INFO sqlalchemy.engine.base.Engine SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1\n",
"2023-11-17 15:53:28,543 INFO sqlalchemy.engine.base.Engine ()\n",
"2023-11-17 15:53:28,544 INFO sqlalchemy.engine.base.Engine SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1\n",
"2023-11-17 15:53:28,545 INFO sqlalchemy.engine.base.Engine ()\n"
]
},
{
"data": {
"text/html": [
@ -1548,7 +1508,7 @@
"[347 rows x 2 columns]"
]
},
"execution_count": 16,
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
@ -1602,7 +1562,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 22,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -1618,14 +1578,30 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 27,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'openpyxl'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32mj:\\Python\\2023-programowanie-w-pythonie\\zajecia2\\data_analysis.ipynb Cell 47\u001b[0m line \u001b[0;36m4\n\u001b[0;32m <a href='vscode-notebook-cell:/j%3A/Python/2023-programowanie-w-pythonie/zajecia2/data_analysis.ipynb#X64sZmlsZQ%3D%3D?line=1'>2</a>\u001b[0m df\u001b[39m.\u001b[39mto_csv(\u001b[39m'\u001b[39m\u001b[39mtmp.csv\u001b[39m\u001b[39m'\u001b[39m)\n\u001b[0;32m <a href='vscode-notebook-cell:/j%3A/Python/2023-programowanie-w-pythonie/zajecia2/data_analysis.ipynb#X64sZmlsZQ%3D%3D?line=2'>3</a>\u001b[0m \u001b[39m# zapis do arkusza kalkulacyjnego \u001b[39;00m\n\u001b[1;32m----> <a href='vscode-notebook-cell:/j%3A/Python/2023-programowanie-w-pythonie/zajecia2/data_analysis.ipynb#X64sZmlsZQ%3D%3D?line=3'>4</a>\u001b[0m df\u001b[39m.\u001b[39;49mto_excel(\u001b[39m'\u001b[39;49m\u001b[39mtmp.xlsx\u001b[39;49m\u001b[39m'\u001b[39;49m)\n",
"File \u001b[1;32mc:\\software\\python3\\lib\\site-packages\\pandas\\core\\generic.py:2252\u001b[0m, in \u001b[0;36mNDFrame.to_excel\u001b[1;34m(self, excel_writer, sheet_name, na_rep, float_format, columns, header, index, index_label, startrow, startcol, engine, merge_cells, inf_rep, freeze_panes, storage_options)\u001b[0m\n\u001b[0;32m 2239\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mpandas\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mio\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mformats\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mexcel\u001b[39;00m \u001b[39mimport\u001b[39;00m ExcelFormatter\n\u001b[0;32m 2241\u001b[0m formatter \u001b[39m=\u001b[39m ExcelFormatter(\n\u001b[0;32m 2242\u001b[0m df,\n\u001b[0;32m 2243\u001b[0m na_rep\u001b[39m=\u001b[39mna_rep,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 2250\u001b[0m inf_rep\u001b[39m=\u001b[39minf_rep,\n\u001b[0;32m 2251\u001b[0m )\n\u001b[1;32m-> 2252\u001b[0m formatter\u001b[39m.\u001b[39;49mwrite(\n\u001b[0;32m 2253\u001b[0m excel_writer,\n\u001b[0;32m 2254\u001b[0m sheet_name\u001b[39m=\u001b[39;49msheet_name,\n\u001b[0;32m 2255\u001b[0m startrow\u001b[39m=\u001b[39;49mstartrow,\n\u001b[0;32m 2256\u001b[0m startcol\u001b[39m=\u001b[39;49mstartcol,\n\u001b[0;32m 2257\u001b[0m freeze_panes\u001b[39m=\u001b[39;49mfreeze_panes,\n\u001b[0;32m 2258\u001b[0m engine\u001b[39m=\u001b[39;49mengine,\n\u001b[0;32m 2259\u001b[0m storage_options\u001b[39m=\u001b[39;49mstorage_options,\n\u001b[0;32m 2260\u001b[0m )\n",
"File \u001b[1;32mc:\\software\\python3\\lib\\site-packages\\pandas\\io\\formats\\excel.py:934\u001b[0m, in \u001b[0;36mExcelFormatter.write\u001b[1;34m(self, writer, sheet_name, startrow, startcol, freeze_panes, engine, storage_options)\u001b[0m\n\u001b[0;32m 930\u001b[0m need_save \u001b[39m=\u001b[39m \u001b[39mFalse\u001b[39;00m\n\u001b[0;32m 931\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m 932\u001b[0m \u001b[39m# error: Cannot instantiate abstract class 'ExcelWriter' with abstract\u001b[39;00m\n\u001b[0;32m 933\u001b[0m \u001b[39m# attributes 'engine', 'save', 'supported_extensions' and 'write_cells'\u001b[39;00m\n\u001b[1;32m--> 934\u001b[0m writer \u001b[39m=\u001b[39m ExcelWriter( \u001b[39m# type: ignore[abstract]\u001b[39;49;00m\n\u001b[0;32m 935\u001b[0m writer, engine\u001b[39m=\u001b[39;49mengine, storage_options\u001b[39m=\u001b[39;49mstorage_options\n\u001b[0;32m 936\u001b[0m )\n\u001b[0;32m 937\u001b[0m need_save \u001b[39m=\u001b[39m \u001b[39mTrue\u001b[39;00m\n\u001b[0;32m 939\u001b[0m \u001b[39mtry\u001b[39;00m:\n",
"File \u001b[1;32mc:\\software\\python3\\lib\\site-packages\\pandas\\io\\excel\\_openpyxl.py:56\u001b[0m, in \u001b[0;36mOpenpyxlWriter.__init__\u001b[1;34m(self, path, engine, date_format, datetime_format, mode, storage_options, if_sheet_exists, engine_kwargs, **kwargs)\u001b[0m\n\u001b[0;32m 43\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m__init__\u001b[39m(\n\u001b[0;32m 44\u001b[0m \u001b[39mself\u001b[39m,\n\u001b[0;32m 45\u001b[0m path: FilePath \u001b[39m|\u001b[39m WriteExcelBuffer \u001b[39m|\u001b[39m ExcelWriter,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 54\u001b[0m ) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m \u001b[39mNone\u001b[39;00m:\n\u001b[0;32m 55\u001b[0m \u001b[39m# Use the openpyxl module as the Excel writer.\u001b[39;00m\n\u001b[1;32m---> 56\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mopenpyxl\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mworkbook\u001b[39;00m \u001b[39mimport\u001b[39;00m Workbook\n\u001b[0;32m 58\u001b[0m engine_kwargs \u001b[39m=\u001b[39m combine_kwargs(engine_kwargs, kwargs)\n\u001b[0;32m 60\u001b[0m \u001b[39msuper\u001b[39m()\u001b[39m.\u001b[39m\u001b[39m__init__\u001b[39m(\n\u001b[0;32m 61\u001b[0m path,\n\u001b[0;32m 62\u001b[0m mode\u001b[39m=\u001b[39mmode,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 65\u001b[0m engine_kwargs\u001b[39m=\u001b[39mengine_kwargs,\n\u001b[0;32m 66\u001b[0m )\n",
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'openpyxl'"
]
}
],
"source": [
"\n",
"# zapis do formatu CSV\n",
"df.to_csv('tmp.csv')\n",
"# zapis do arkusza kalkulacyjnego \n",
@ -1645,7 +1621,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 28,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -1666,7 +1642,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 29,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -1698,7 +1674,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 30,
"metadata": {
"slideshow": {
"slide_type": "slide"
@ -1739,14 +1715,450 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 38,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"source": []
"outputs": [
{
"data": {
"text/plain": [
"{0: 'Germany',\n",
" 1: 'Norway',\n",
" 2: 'Belgium',\n",
" 3: 'Canada',\n",
" 4: 'USA',\n",
" 5: 'Germany',\n",
" 6: 'Germany',\n",
" 7: 'France',\n",
" 8: 'France',\n",
" 9: 'Ireland',\n",
" 10: 'United Kingdom',\n",
" 11: 'Germany',\n",
" 12: 'USA',\n",
" 13: 'USA',\n",
" 14: 'USA',\n",
" 15: 'USA',\n",
" 16: 'USA',\n",
" 17: 'Canada',\n",
" 18: 'France',\n",
" 19: 'United Kingdom',\n",
" 20: 'Australia',\n",
" 21: 'Chile',\n",
" 22: 'India',\n",
" 23: 'Norway',\n",
" 24: 'Brazil',\n",
" 25: 'USA',\n",
" 26: 'Canada',\n",
" 27: 'Portugal',\n",
" 28: 'Germany',\n",
" 29: 'Germany',\n",
" 30: 'France',\n",
" 31: 'Netherlands',\n",
" 32: 'Chile',\n",
" 33: 'Brazil',\n",
" 34: 'Brazil',\n",
" 35: 'Canada',\n",
" 36: 'USA',\n",
" 37: 'USA',\n",
" 38: 'USA',\n",
" 39: 'Germany',\n",
" 40: 'Spain',\n",
" 41: 'Sweden',\n",
" 42: 'United Kingdom',\n",
" 43: 'Australia',\n",
" 44: 'India',\n",
" 45: 'Czech Republic',\n",
" 46: 'Canada',\n",
" 47: 'Canada',\n",
" 48: 'Canada',\n",
" 49: 'Canada',\n",
" 50: 'Portugal',\n",
" 51: 'Germany',\n",
" 52: 'Finland',\n",
" 53: 'United Kingdom',\n",
" 54: 'Belgium',\n",
" 55: 'Denmark',\n",
" 56: 'Brazil',\n",
" 57: 'Brazil',\n",
" 58: 'USA',\n",
" 59: 'USA',\n",
" 60: 'Canada',\n",
" 61: 'Ireland',\n",
" 62: 'Italy',\n",
" 63: 'Poland',\n",
" 64: 'Sweden',\n",
" 65: 'Australia',\n",
" 66: 'Germany',\n",
" 67: 'Brazil',\n",
" 68: 'USA',\n",
" 69: 'USA',\n",
" 70: 'USA',\n",
" 71: 'Canada',\n",
" 72: 'Portugal',\n",
" 73: 'France',\n",
" 74: 'Poland',\n",
" 75: 'Norway',\n",
" 76: 'Czech Republic',\n",
" 77: 'Austria',\n",
" 78: 'Denmark',\n",
" 79: 'Brazil',\n",
" 80: 'USA',\n",
" 81: 'USA',\n",
" 82: 'France',\n",
" 83: 'France',\n",
" 84: 'Hungary',\n",
" 85: 'Italy',\n",
" 86: 'Sweden',\n",
" 87: 'Chile',\n",
" 88: 'Austria',\n",
" 89: 'USA',\n",
" 90: 'USA',\n",
" 91: 'USA',\n",
" 92: 'USA',\n",
" 93: 'Canada',\n",
" 94: 'Germany',\n",
" 95: 'Hungary',\n",
" 96: 'India',\n",
" 97: 'Brazil',\n",
" 98: 'Canada',\n",
" 99: 'Czech Republic',\n",
" 100: 'Denmark',\n",
" 101: 'Canada',\n",
" 102: 'USA',\n",
" 103: 'Germany',\n",
" 104: 'France',\n",
" 105: 'France',\n",
" 106: 'France',\n",
" 107: 'Italy',\n",
" 108: 'United Kingdom',\n",
" 109: 'Canada',\n",
" 110: 'USA',\n",
" 111: 'USA',\n",
" 112: 'USA',\n",
" 113: 'USA',\n",
" 114: 'USA',\n",
" 115: 'Canada',\n",
" 116: 'France',\n",
" 117: 'Australia',\n",
" 118: 'Argentina',\n",
" 119: 'India',\n",
" 120: 'Brazil',\n",
" 121: 'Czech Republic',\n",
" 122: 'Brazil',\n",
" 123: 'USA',\n",
" 124: 'Portugal',\n",
" 125: 'Portugal',\n",
" 126: 'Germany',\n",
" 127: 'France',\n",
" 128: 'France',\n",
" 129: 'Poland',\n",
" 130: 'India',\n",
" 131: 'Brazil',\n",
" 132: 'Canada',\n",
" 133: 'USA',\n",
" 134: 'USA',\n",
" 135: 'USA',\n",
" 136: 'USA',\n",
" 137: 'Germany',\n",
" 138: 'Sweden',\n",
" 139: 'United Kingdom',\n",
" 140: 'United Kingdom',\n",
" 141: 'Argentina',\n",
" 142: 'Brazil',\n",
" 143: 'Austria',\n",
" 144: 'USA',\n",
" 145: 'Canada',\n",
" 146: 'Canada',\n",
" 147: 'Canada',\n",
" 148: 'Portugal',\n",
" 149: 'France',\n",
" 150: 'Hungary',\n",
" 151: 'United Kingdom',\n",
" 152: 'Denmark',\n",
" 153: 'Brazil',\n",
" 154: 'Brazil',\n",
" 155: 'Canada',\n",
" 156: 'USA',\n",
" 157: 'USA',\n",
" 158: 'Canada',\n",
" 159: 'Italy',\n",
" 160: 'Netherlands',\n",
" 161: 'Spain',\n",
" 162: 'United Kingdom',\n",
" 163: 'Argentina',\n",
" 164: 'Canada',\n",
" 165: 'Brazil',\n",
" 166: 'USA',\n",
" 167: 'USA',\n",
" 168: 'Canada',\n",
" 169: 'Canada',\n",
" 170: 'Portugal',\n",
" 171: 'France',\n",
" 172: 'Spain',\n",
" 173: 'Czech Republic',\n",
" 174: 'Czech Republic',\n",
" 175: 'Belgium',\n",
" 176: 'Brazil',\n",
" 177: 'Canada',\n",
" 178: 'USA',\n",
" 179: 'Canada',\n",
" 180: 'France',\n",
" 181: 'Finland',\n",
" 182: 'Ireland',\n",
" 183: 'Netherlands',\n",
" 184: 'United Kingdom',\n",
" 185: 'India',\n",
" 186: 'Belgium',\n",
" 187: 'USA',\n",
" 188: 'USA',\n",
" 189: 'USA',\n",
" 190: 'USA',\n",
" 191: 'Canada',\n",
" 192: 'Germany',\n",
" 193: 'Ireland',\n",
" 194: 'Brazil',\n",
" 195: 'Germany',\n",
" 196: 'Norway',\n",
" 197: 'Czech Republic',\n",
" 198: 'Brazil',\n",
" 199: 'USA',\n",
" 200: 'USA',\n",
" 201: 'France',\n",
" 202: 'France',\n",
" 203: 'France',\n",
" 204: 'Finland',\n",
" 205: 'Netherlands',\n",
" 206: 'United Kingdom',\n",
" 207: 'Norway',\n",
" 208: 'USA',\n",
" 209: 'USA',\n",
" 210: 'USA',\n",
" 211: 'USA',\n",
" 212: 'USA',\n",
" 213: 'Canada',\n",
" 214: 'France',\n",
" 215: 'Argentina',\n",
" 216: 'Chile',\n",
" 217: 'India',\n",
" 218: 'Germany',\n",
" 219: 'Czech Republic',\n",
" 220: 'Brazil',\n",
" 221: 'USA',\n",
" 222: 'Portugal',\n",
" 223: 'Germany',\n",
" 224: 'Germany',\n",
" 225: 'France',\n",
" 226: 'Finland',\n",
" 227: 'Spain',\n",
" 228: 'India',\n",
" 229: 'Canada',\n",
" 230: 'Canada',\n",
" 231: 'USA',\n",
" 232: 'USA',\n",
" 233: 'USA',\n",
" 234: 'Canada',\n",
" 235: 'Germany',\n",
" 236: 'United Kingdom',\n",
" 237: 'United Kingdom',\n",
" 238: 'Australia',\n",
" 239: 'Chile',\n",
" 240: 'Germany',\n",
" 241: 'Belgium',\n",
" 242: 'USA',\n",
" 243: 'Canada',\n",
" 244: 'Canada',\n",
" 245: 'Portugal',\n",
" 246: 'Germany',\n",
" 247: 'France',\n",
" 248: 'Ireland',\n",
" 249: 'Australia',\n",
" 250: 'Brazil',\n",
" 251: 'Brazil',\n",
" 252: 'Brazil',\n",
" 253: 'Canada',\n",
" 254: 'USA',\n",
" 255: 'USA',\n",
" 256: 'Portugal',\n",
" 257: 'Netherlands',\n",
" 258: 'Poland',\n",
" 259: 'Sweden',\n",
" 260: 'United Kingdom',\n",
" 261: 'Chile',\n",
" 262: 'Norway',\n",
" 263: 'Brazil',\n",
" 264: 'USA',\n",
" 265: 'USA',\n",
" 266: 'Canada',\n",
" 267: 'Canada',\n",
" 268: 'Germany',\n",
" 269: 'France',\n",
" 270: 'Sweden',\n",
" 271: 'Czech Republic',\n",
" 272: 'Austria',\n",
" 273: 'Denmark',\n",
" 274: 'Brazil',\n",
" 275: 'Canada',\n",
" 276: 'USA',\n",
" 277: 'Canada',\n",
" 278: 'Finland',\n",
" 279: 'Hungary',\n",
" 280: 'Italy',\n",
" 281: 'Poland',\n",
" 282: 'United Kingdom',\n",
" 283: 'India',\n",
" 284: 'Denmark',\n",
" 285: 'USA',\n",
" 286: 'USA',\n",
" 287: 'USA',\n",
" 288: 'USA',\n",
" 289: 'Canada',\n",
" 290: 'Germany',\n",
" 291: 'Italy',\n",
" 292: 'Germany',\n",
" 293: 'Canada',\n",
" 294: 'Czech Republic',\n",
" 295: 'Austria',\n",
" 296: 'Brazil',\n",
" 297: 'USA',\n",
" 298: 'USA',\n",
" 299: 'France',\n",
" 300: 'France',\n",
" 301: 'France',\n",
" 302: 'Hungary',\n",
" 303: 'Poland',\n",
" 304: 'Australia',\n",
" 305: 'Czech Republic',\n",
" 306: 'USA',\n",
" 307: 'USA',\n",
" 308: 'USA',\n",
" 309: 'USA',\n",
" 310: 'USA',\n",
" 311: 'Portugal',\n",
" 312: 'France',\n",
" 313: 'Chile',\n",
" 314: 'India',\n",
" 315: 'Brazil',\n",
" 316: 'Canada',\n",
" 317: 'Austria',\n",
" 318: 'Brazil',\n",
" 319: 'USA',\n",
" 320: 'Germany',\n",
" 321: 'Germany',\n",
" 322: 'France',\n",
" 323: 'France',\n",
" 324: 'Hungary',\n",
" 325: 'Sweden',\n",
" 326: 'Brazil',\n",
" 327: 'Canada',\n",
" 328: 'USA',\n",
" 329: 'USA',\n",
" 330: 'USA',\n",
" 331: 'USA',\n",
" 332: 'Canada',\n",
" 333: 'France',\n",
" 334: 'United Kingdom',\n",
" 335: 'United Kingdom',\n",
" 336: 'Argentina',\n",
" 337: 'India',\n",
" 338: 'Canada',\n",
" 339: 'Denmark',\n",
" 340: 'USA',\n",
" 341: 'Canada',\n",
" 342: 'Canada',\n",
" 343: 'Portugal',\n",
" 344: 'Germany',\n",
" 345: 'France',\n",
" 346: 'Italy',\n",
" 347: 'Argentina',\n",
" 348: 'Brazil',\n",
" 349: 'Brazil',\n",
" 350: 'Canada',\n",
" 351: 'USA',\n",
" 352: 'USA',\n",
" 353: 'USA',\n",
" 354: 'Portugal',\n",
" 355: 'Poland',\n",
" 356: 'Spain',\n",
" 357: 'United Kingdom',\n",
" 358: 'United Kingdom',\n",
" 359: 'India',\n",
" 360: 'Czech Republic',\n",
" 361: 'Canada',\n",
" 362: 'USA',\n",
" 363: 'Canada',\n",
" 364: 'Canada',\n",
" 365: 'Canada',\n",
" 366: 'Germany',\n",
" 367: 'France',\n",
" 368: 'United Kingdom',\n",
" 369: 'Austria',\n",
" 370: 'Belgium',\n",
" 371: 'Brazil',\n",
" 372: 'Brazil',\n",
" 373: 'USA',\n",
" 374: 'USA',\n",
" 375: 'Canada',\n",
" 376: 'Hungary',\n",
" 377: 'Ireland',\n",
" 378: 'Netherlands',\n",
" 379: 'Spain',\n",
" 380: 'United Kingdom',\n",
" 381: 'Brazil',\n",
" 382: 'Brazil',\n",
" 383: 'USA',\n",
" 384: 'USA',\n",
" 385: 'USA',\n",
" 386: 'Canada',\n",
" 387: 'Canada',\n",
" 388: 'France',\n",
" 389: 'Netherlands',\n",
" 390: 'Canada',\n",
" 391: 'Norway',\n",
" 392: 'Czech Republic',\n",
" 393: 'Belgium',\n",
" 394: 'Brazil',\n",
" 395: 'USA',\n",
" 396: 'USA',\n",
" 397: 'France',\n",
" 398: 'France',\n",
" 399: 'Finland',\n",
" 400: 'Ireland',\n",
" 401: 'Spain',\n",
" 402: 'Argentina',\n",
" 403: 'Czech Republic',\n",
" 404: 'USA',\n",
" 405: 'USA',\n",
" 406: 'USA',\n",
" 407: 'USA',\n",
" 408: 'Canada',\n",
" 409: 'Portugal',\n",
" 410: 'Finland',\n",
" 411: 'India'}"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import sqlalchemy\n",
"\n",
"engine = sqlalchemy.create_engine('sqlite:///Chinook.sqlite', echo=True)\n",
"connection = engine.raw_connection()\n",
"\n",
"df = pd.read_sql('SELECT * FROM Customer', con='sqlite:///Chinook.sqlite')\n",
"df.to_csv('customers.csv')\n",
"\n",
"df = pd.read_sql('SELECT * FROM Employee', con='sqlite:///Chinook.sqlite')\n",
"# df['City'].drop_duplicates()\n",
"\n",
"df = pd.read_sql('SELECT * FROM Invoice', con='sqlite:///Chinook.sqlite')\n",
"df['BillingCountry'].drop_duplicates().to_dict()\n"
]
},
{
"cell_type": "markdown",
@ -8095,7 +8507,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.10.11"
}
},
"nbformat": 4,

View File

@ -1,4 +1,4 @@
,members,occasionals
May,682758,147898
June,737011,171494
July,779511,194316
,members,occasionals
May,682758,147898
June,737011,171494
July,779511,194316

1 members occasionals
2 May 682758 147898
3 June 737011 171494
4 July 779511 194316

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -39,6 +39,7 @@
"source": [
"Istnieje wieje miar (metryk), na podstawie których możemy ocenić jakość modelu. Podobnie jak w przypadku regresji liniowej potrzebne są dwie listy: lista poprawnych klas i lista predykcji z modelu. Najpopularniejszą z metryk jest trafność, którą definiuje się w następujący sposób:\n",
" $$ACC = \\frac{k}{N}$$ \n",
" $$SUM = \\sum_{x}^{y}{k}{n}{i}$$\n",
" \n",
" gdzie: \n",
" * $k$ to liczba poprawnie zaklasyfikowanych przypadków,\n",
@ -54,12 +55,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ACC: 0.4\n"
]
}
],
"source": [
"def accuracy_measure(true, predicted):\n",
" pass\n",
" if len(true_label) != len(predicted):\n",
" raise ValueError(\"Input lists can't have different sizes.\")\n",
" \n",
" correct_values = 0\n",
" for i in range(len(true_label)):\n",
" if true_label[i] == predicted[i]:\n",
" correct_values += 1\n",
"\n",
" return correct_values / len(predicted)\n",
"\n",
"true_label = [1, 1, 1, 0, 0]\n",
"predicted = [0, 1, 0, 1, 0]\n",
@ -125,10 +142,164 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Sepal length</th>\n",
" <th>Sepal width</th>\n",
" <th>Petal length</th>\n",
" <th>Petal width</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Class</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Iris-setosa</th>\n",
" <td>5.1</td>\n",
" <td>3.5</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Iris-setosa</th>\n",
" <td>4.9</td>\n",
" <td>3.0</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Iris-setosa</th>\n",
" <td>4.7</td>\n",
" <td>3.2</td>\n",
" <td>1.3</td>\n",
" <td>0.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Iris-setosa</th>\n",
" <td>4.6</td>\n",
" <td>3.1</td>\n",
" <td>1.5</td>\n",
" <td>0.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Iris-setosa</th>\n",
" <td>5.0</td>\n",
" <td>3.6</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Iris-virginica</th>\n",
" <td>6.7</td>\n",
" <td>3.0</td>\n",
" <td>5.2</td>\n",
" <td>2.3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Iris-virginica</th>\n",
" <td>6.3</td>\n",
" <td>2.5</td>\n",
" <td>5.0</td>\n",
" <td>1.9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Iris-virginica</th>\n",
" <td>6.5</td>\n",
" <td>3.0</td>\n",
" <td>5.2</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Iris-virginica</th>\n",
" <td>6.2</td>\n",
" <td>3.4</td>\n",
" <td>5.4</td>\n",
" <td>2.3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Iris-virginica</th>\n",
" <td>5.9</td>\n",
" <td>3.0</td>\n",
" <td>5.1</td>\n",
" <td>1.8</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>150 rows × 4 columns</p>\n",
"</div>"
],
"text/plain": [
" Sepal length Sepal width Petal length Petal width\n",
"Class \n",
"Iris-setosa 5.1 3.5 1.4 0.2\n",
"Iris-setosa 4.9 3.0 1.4 0.2\n",
"Iris-setosa 4.7 3.2 1.3 0.2\n",
"Iris-setosa 4.6 3.1 1.5 0.2\n",
"Iris-setosa 5.0 3.6 1.4 0.2\n",
"... ... ... ... ...\n",
"Iris-virginica 6.7 3.0 5.2 2.3\n",
"Iris-virginica 6.3 2.5 5.0 1.9\n",
"Iris-virginica 6.5 3.0 5.2 2.0\n",
"Iris-virginica 6.2 3.4 5.4 2.3\n",
"Iris-virginica 5.9 3.0 5.1 1.8\n",
"\n",
"[150 rows x 4 columns]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"\n",
"df = pd.read_csv(\n",
" './iris.data', \n",
" index_col=4, \n",
" names=[\n",
" 'Sepal length', \n",
" 'Sepal width', \n",
" 'Petal length', \n",
" 'Petal width',\n",
" 'Class'\n",
" ])\n",
"df"
]
},
{
"cell_type": "markdown",
@ -560,7 +731,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.10.11"
}
},
"nbformat": 4,