![]() |
python resample by day and get weekstart data - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: python resample by day and get weekstart data (/thread-38965.html) |
python resample by day and get weekstart data - JaneTan - Dec-15-2022 I have monthly data. When I apply resampling by day and cubic interpolation, there is a function to find the month end data import pandas as pd df=pd.read_excel(input_file, sheet_name='mthly', usecols='A:D', na_values='ND', index_col=0, header=0) df.index.names = ['Period'] df.index = pd.to_datetime(df.index) q= pd.Series(df[series], index=df.index) d = q.resample('D').interpolate(method='cubic') m=d[d.index.is_month_end]Now I want the data for the start of each week, but I can't find such a function. How do I solve this? INPUT MONTHLY DATA Period Values Jan-22 1 Feb-22 3 Mar-22 7 Apr-22 5 May-22 4 After re-sampling by day and with cubic interpolation Period 2022-01-01 1.000000 2022-01-02 0.884487 2022-01-03 0.785650 2022-01-04 0.703004 2022-01-05 0.636066 2022-01-06 0.584353 2022-01-07 0.547382 2022-01-08 0.524668 2022-01-09 0.515729 2022-01-10 0.520081 2022-01-11 0.537240 2022-01-12 0.566724 2022-01-13 0.608048 and so on Desired output is Monday of each week 2022-01-03 0.785650 2022-01-10 0.520081 and so on Thank you |