I want to add new rows in DataFrame pandas each time I run the program I create. I don't know the data in advance, the functions are supposed to put the data in a variable and I want to add these variables in a row. For now I just success to add one row, but when I run the program each time this row is replace by the next one. I don't want the row to be replaced but added in the next row.
net_index = mylist.index('NET PAYE EN EUROS ')
net= mylist[net_index+2]
total_index= mylist.index('CONGES ')
total = (mylist[total_index-1])
df = pd.DataFrame(columns=['Mois','Nom','Adresse','Net_payé','Total_versé'])
new = {'Mois': mois, 'Nom': nom, 'Adresse': adresse,'Net_payé':net, 'Total_versé':total}
df= df.append(new, ignore_index=True)
This is a part of my code. First I create an empty Dataframe with name of columns, and then a dict with variables which are supposed to change for each run.
This is the result I have, but each time I run, the rows is replace by the next one, and not add
I suppose I have to do a loop, but it never works well, I search everywhere for a solution but don't find one.
So do you know what can I do ? Thank you so much