I have a dataframe (called df) that looks like this:
I'm trying to take all weekend 'Volume' values (the ones where column 'WEEKDAY'=5 (saturday) or 6(sunday)) and sum them to the subsequent monday(WEEKDAY=0).
I tried a few things but nothing really worked, taking an example from the last three rows:
What I'm expecting is this:
To reproduce the problem:
!wget https://raw.githubusercontent.com/brunodifranco/TCC/main/volume_por_dia.csv
df = pd.read_csv('volume_por_dia.csv').sort_values('Datas',ascending=True)
df['Datas'] = pd.to_datetime(df['Datas'])
df = df_volume_noticias.set_index('Datas')
df['WEEKDAY'] = df.index.dayofweek
df
source https://stackoverflow.com/questions/71576071/python-push-forward-weekend-values-to-monday
Comments
Post a Comment