import pandas as panda import numpy as np def PANDAS_DONE(): read = panda.read_csv('statek.txt', sep='\t') select = panda.DataFrame(read) # print(select) # print(read) select['data'] = panda.to_datetime(select['data']) funds = 500000 print("Fundusze", funds) czas = (select['data'] <= '2018-12-18') Z = (select['Z/W'] == 'Z') W = (select['Z/W'] == 'W') # ------------------------------------------------------------------------ #kolumna stan_finansów to ....... wyd = select['wydatki'] = select['ile ton'] * select['cena za tone w talarach'] #print(select) #print(select['wydatki'].cumsum()) # Generujemy listę wykorzystując Python Pandas oraz jej zawartość zapisujemy do kolumny 'Result' result = [] y = select['wydatki'][0] if select['Z/W'][0] == 'Z': x = funds - y print(x) result.insert(0, x) elif select['Z/W'][0] == 'W': x = funds + y print(x) result.insert(0,x) #for val in select['wydatki'][1:]: for i in range(1,len(select['wydatki'])): val = select['wydatki'][i] if select['Z/W'][i] == 'Z': result.append(x - val) else: result.append(x + val) select["result"] = result #print(select) #sel = select.loc[(select['data'] == '2018-10-08')] #print(sel) print(select.groupby('data').max('result').sort_values(by='result', ascending=False)) def main(): PANDAS_DONE() if __name__ == '__main__': main()