Download - Python base lezione 3
![Page 1: Python base lezione 3](https://reader035.vdocuments.pub/reader035/viewer/2022081810/588107291a28ab22368b5541/html5/thumbnails/1.jpg)
PYTHON BASE
Strutture dati di base: liste e dizionari; introduzione numpy e pandas.
![Page 2: Python base lezione 3](https://reader035.vdocuments.pub/reader035/viewer/2022081810/588107291a28ab22368b5541/html5/thumbnails/2.jpg)
COME ORGANIZ-ZARE I DATI
100 324.3 ‘Italia’ 533 ‘FRA’ ‘Oggi è
una bella giornata’ 54.5 True 57 987
False ‘DEU’ ‘config.py’
![Page 3: Python base lezione 3](https://reader035.vdocuments.pub/reader035/viewer/2022081810/588107291a28ab22368b5541/html5/thumbnails/3.jpg)
CONSIDERIAMO UNA SERIE STORICA MENSILE
maggio 2015 125.6
giugno 2015 128.3
luglio 2015 132.9
agosto 2015 133.1
settembre 2015 135.5
ottobre 2015 135.2
novembre 2015 138.6
![Page 4: Python base lezione 3](https://reader035.vdocuments.pub/reader035/viewer/2022081810/588107291a28ab22368b5541/html5/thumbnails/4.jpg)
[ 125.6, 128.3, 132.9, 133.1, 135.5, 135.2, 138.6
]
DIZIONARIO {’201501’ : 125.6, ‘201506’ : 128.3, ‘201507’ : 132.9, ‘201508’ : 133.1 , ‘201509’ : 135.5, ‘201510’ : 135.2, ‘201511’ : 138.6
}
LISTA
![Page 5: Python base lezione 3](https://reader035.vdocuments.pub/reader035/viewer/2022081810/588107291a28ab22368b5541/html5/thumbnails/5.jpg)
[ 125.6, 128.3, 132.9, 133.1, 135.5, 135.2, 138.6
]
DIZIONARIO {’201501’ : 125.6, ‘201506’ : 128.3, ‘201507’ : 132.9, ‘201508’ : 133.1 , ‘201509’ : 135.5, ‘201510’ : 135.2, ‘201511’ : 138.6
}
LISTA
posizione 0posizione 1posizione 2posizione 3posizione 4posizione 5posizione 6
chiavechiavechiavechiavechiavechiavechiave
![Page 6: Python base lezione 3](https://reader035.vdocuments.pub/reader035/viewer/2022081810/588107291a28ab22368b5541/html5/thumbnails/6.jpg)
Assegnazione
LIS1 = [ 125.6, 128.3,
132.9, 133.1, 135.5,
135.2, 138.6 ]
DIZIONARIO Assegnazione
DIZ1 = {’201501’ : 125.6, ‘201506’ : 128.3, ‘201507’ : 132.9, ‘201508’ : 133.1 , ‘201509’ : 135.5, ‘201510’ : 135.2, ‘201511’ : 138.6
}
LISTA
![Page 7: Python base lezione 3](https://reader035.vdocuments.pub/reader035/viewer/2022081810/588107291a28ab22368b5541/html5/thumbnails/7.jpg)
Estrazione
LIS1 [3]
LIS1 [1:3]
LIS1 [:3]
DIZIONARIO
Estrazione
DIZ1 [‘201508’]
LISTA
![Page 8: Python base lezione 3](https://reader035.vdocuments.pub/reader035/viewer/2022081810/588107291a28ab22368b5541/html5/thumbnails/8.jpg)
LEZIONE 1..www.fordatascientist.org
B00-PyBaseB31-Data-Structures-Builtin
![Page 9: Python base lezione 3](https://reader035.vdocuments.pub/reader035/viewer/2022081810/588107291a28ab22368b5541/html5/thumbnails/9.jpg)
LEZIONE 1..www.fordatascientist.org
B00-PyBaseB32-Data-Structures-Other
![Page 10: Python base lezione 3](https://reader035.vdocuments.pub/reader035/viewer/2022081810/588107291a28ab22368b5541/html5/thumbnails/10.jpg)
LEZIONE 1..www.fordatascientist.org
B00-PyBaseB36-Slicing-Iterable.ipynb
![Page 11: Python base lezione 3](https://reader035.vdocuments.pub/reader035/viewer/2022081810/588107291a28ab22368b5541/html5/thumbnails/11.jpg)
A cosa servono le tuple
A= { (‘FRA’,’DEU’,’2015’): 765, (‘FRA’,’ITA’,’2015’): 234, (‘FRA’,’USA’,’2015’): 122, (‘DEU’,’FRA’,’2016’): 975, (‘DEU’,’ITA’,’2016’): 744, (‘DEU’,’USA’,’2016’): 865 }
A= {‘FRA’:{’DEU’:{’2015’: 765}, ’ITA’:{’2015’: 234}, ’USA’:{’2015’: 122} }, ‘DEU’:{’FRA’:{’2016’: 975}, ’ITA’:{’2016’: 744}, ‘USA’:{‘2016’: 865} } }
Nel 2015, la Francia ha esportato verso la Germania 875 milioni di euro; verso l’Italia 234 mln di euro; verso gli Stati Uniti 122 mln di euro;Nel 2016, la Germania ha esportato verso la Francia 975 milioni di euro; verso l’Italia 744; verso gli Stati Uniti 865
A['FRA']['ITA']['2015'] A [ ('FRA','ITA','2015') ]
COSTRUZIONE
ESTRAZIONE
![Page 13: Python base lezione 3](https://reader035.vdocuments.pub/reader035/viewer/2022081810/588107291a28ab22368b5541/html5/thumbnails/13.jpg)
Riepilogo lezione precedente
interi, floating point, decimal
ATTRIBUTI
METODIOGGETTO
CLASSE
funzioni built-in
stringhe
ITERABLE
len
int floatstr
list set
.replace
.upper
.count
if elif else for .. in .. :
![Page 14: Python base lezione 3](https://reader035.vdocuments.pub/reader035/viewer/2022081810/588107291a28ab22368b5541/html5/thumbnails/14.jpg)
[ ]
{ } ( )
Data Built-in Data Modulenumpy
pandas.Array
.Series.max().mean()
.Ndarray.std()
.mean(axis=1)
.DataFrame
.index
.index
.columns.index().count()
.count()
.keys
.sort()
.append()
.remove()
![Page 15: Python base lezione 3](https://reader035.vdocuments.pub/reader035/viewer/2022081810/588107291a28ab22368b5541/html5/thumbnails/15.jpg)
[ ]ESTRATTOREtupla lista Array
Ndarray
SeriesDataFrame
iloc()