I would like to add row to a dataframe and assign a index. I try to make myself clear with the following example:
This is my empty dataframe:
dfr = pd.DataFrame(columns=['A','B'])
after that I would like to add some row with an index that depends on a specific day of the week.
Here the code:
for i in range(0,4):
dfr = dfr.append({'A': i,'B': i+10}, index=[day])
dayw = day.strftime('%A')
if dayw == 'Monday':
delta = pd.Timedelta("3 days")
if dayw == 'Wensday':
delta = pd.Timedelta("4 days")
day = day + delta
print(day)
As you can notice, I am not able to deal with the index. Thanks for any kind of help.
dayis not defined, so I can't run your code.