Embed presentation
Download to read offline





![class AnnualTS:
'''La Classe AnnualTS serve ad istanziare un oggetto
per la gestione/descrizione di una serie storica.
'''
def __init__(BASE, START, END, DATA):
BASE.LYEAR = [I for I in range(START,END+1)]
BASE.DATA = DATA
BASE.TS= dict(zip(BASE.LYEAR,BASE.DATA))
def __str__(BASE):
STR=""
for YEAR in BASE.LYEAR:
STR=STR+'Anno {0}: {1} n'.format(
YEAR,BASE.TS[YEAR])
return STR
TS1=AnnualTS(2000, 2005, [22,33,42,34,28,33])
TS1.TS
print(TS1)](https://image.slidesharecdn.com/pythonbase-07-classioggetti-170221163257/75/Python-base-07-classioggetti-6-2048.jpg)
![def mean(BASE):
SUM=0
LNUM=0
for YEAR in BASE.LYEAR:
SUM=SUM+BASE.TS[YEAR]
LNUM +=1
RIS=1.0*SUM/LNUM
return RIS
def max(BASE):
MAX=0
for YEAR in BASE.LYEAR:
if BASE.TS[YEAR]>MAX:
MAX=BASE.TS[YEAR]
return MAX
TS1.mean()
TS1.max()](https://image.slidesharecdn.com/pythonbase-07-classioggetti-170221163257/75/Python-base-07-classioggetti-7-2048.jpg)






The document defines an AnnualTS class to represent a time series object with yearly data. The AnnualTS class initializes with a start and end year, data values, and methods to return the mean, max, and string representation of the time series. An example time series object TS1 is created from 2000 to 2005 with data values and the mean and max values are calculated.





![class AnnualTS:
'''La Classe AnnualTS serve ad istanziare un oggetto
per la gestione/descrizione di una serie storica.
'''
def __init__(BASE, START, END, DATA):
BASE.LYEAR = [I for I in range(START,END+1)]
BASE.DATA = DATA
BASE.TS= dict(zip(BASE.LYEAR,BASE.DATA))
def __str__(BASE):
STR=""
for YEAR in BASE.LYEAR:
STR=STR+'Anno {0}: {1} n'.format(
YEAR,BASE.TS[YEAR])
return STR
TS1=AnnualTS(2000, 2005, [22,33,42,34,28,33])
TS1.TS
print(TS1)](https://image.slidesharecdn.com/pythonbase-07-classioggetti-170221163257/75/Python-base-07-classioggetti-6-2048.jpg)
![def mean(BASE):
SUM=0
LNUM=0
for YEAR in BASE.LYEAR:
SUM=SUM+BASE.TS[YEAR]
LNUM +=1
RIS=1.0*SUM/LNUM
return RIS
def max(BASE):
MAX=0
for YEAR in BASE.LYEAR:
if BASE.TS[YEAR]>MAX:
MAX=BASE.TS[YEAR]
return MAX
TS1.mean()
TS1.max()](https://image.slidesharecdn.com/pythonbase-07-classioggetti-170221163257/75/Python-base-07-classioggetti-7-2048.jpg)




