def sum(self, lista): """ Calculate the sum of a list of data :param mylist lista: The lists of lists which will be added. return mylist The new mylist instance with the result of the operation. """ if len(lista) > 1: return mylist.sum(lista) elif len(lista) == 1: r1 = mylist() r1.insert(lista) return r1 else: return '[]'
def media(self, lista, windowsize): """ Calculate the media of a list of data :param mylist lista The mylist instance with the data to be added. :return mylist The media of the data """ if isinstance(windowsize, list) and len(windowsize) == 1: windowsize = int(windowsize[0]) if len(lista) >= windowsize: return self.sum(lista) / len(lista) else: result = mylist() result.data = [] return result