Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.3 kB
1
Indexable
Never
# YOUR ANSWER HERE
lis=fields['tech'].tolist()
lista=[]
for i in range(len(lis)-1):
    x=lis[i+1]-lis[i]
    lista.append(x)

spike= None

for num in lista:
    if (spike is None or num > spike):
        spike= num

#-------------------------------------------------------------------------------

def calculate_media(list: list) -> float:
    return_value: int = 0
    for valor in list:
        return_value += valor
    return return_value / len(list)

def calculate_5yr(value_list: list, offset: int) -> list[int]:
    return_list: list = []
    for i in range(len(value_list) - offset): 
        np.append(return_list, calculate_media(value_list[i: i + offset]))
    return return_list

offset: int = 5
lista_iter: list = fields['tech'].tolist()[offset: -1]
lista_med: list = calculate_5yr(value_list = fields['tech'].tolist(), offset = offset)
difflist: tuple = (0,0)
counter: int = 0

for iter, med in zip(lista_iter, lista_med):
    if iter -  med > difflist:
        difflist = (iter - med, counter)
    counter += 1

idx_5y_arg: dt.datetime = difflist[1] + 1990


class idx():
    def __init__(self, idx_5y_arg: int) -> None:
        self.year = idx_5y_arg

idx_5y = idx(idx_5y_arg = idx_5y_arg)

print(spike,'\nEl año con mayor spike es', idx_5y_arg)