there are many posts on this subject. I went through them and I couldn't find the answer to my question:
I am working on a pandas time series DataFrame. The DataFrame data is in Daily time-frame and I am aggregating it to Weekly time-frame, via the pandas library resample() function, such as below.
daily_df = #daily time series dataframe
def aggregate(daily_df, frequency):
weekly_df = daily_df.resample(frequency, on='date').agg({'open':'first','high':'max', 'low':'min','close':'last','volume':'sum'})
df.reset_index(inplace=True)
return weekly_df
weekly_df = aggregate(daily_df, 'W-Fri')
The issue I am running into is, some week's the time-series data only contains data from Monday to Thursday, but I don't know how to tell the resample() function to check for that and if it does, to end the week on the Thursday rather than the Friday; "W-Fri".