0

I have monthly data from 1989/09 to 2020/12 and want to convert it to weekly data (friday to friday) starting 1989/09/29 to 2020/12/25 and just keep the values for the months in the weekly data (e.g. for all weeks in september the value for september for all weeks in october the value for october and so on).

That's how I did it:

df.set_index(pd.DatetimeIndex(df_k["Date"]), inplace=True) #set DatetimeIndex to resample

[![First: Monthly Data ][1]][1] [1]: https://i.stack.imgur.com/9e5DW.png

df.resample("W-FRI",axis = 0).ffill() #upsample to get weekly data

[![Output: Weekly data with correct values but wrong timespan][2]][2] [2]: https://i.stack.imgur.com/QAOMX.png

I get a dataframe with correct values but range 1989/09/01 to 2020/12/04. I want to adjust the range to 1989/09/29 to 2020/12/25 but cant find the correct input in the function.

Max N
  • 21
  • 4
  • 2
    Can you please add reproducible code to the ques which can help others to help you. – Utsav Apr 29 '21 at 15:59
  • I checked the RESAMPLE function with investment data. The object of upsampling is to include the last week of the previous month and up to the next month's data. So if you need data until the end of the month, in your example, you need data until 2021/01/01. – r-beginners Apr 30 '21 at 08:59

0 Answers0