Python Forum
Convert quarterly time series to monthly time series - 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: Convert quarterly time series to monthly time series (/thread-26987.html)



Convert quarterly time series to monthly time series - donnertrud - May-21-2020

Hi,

in order to bring all my data sets in the same shape, I need to convert a data set consisting of quartlery dates into a data set consisting of monthly dates. Here is a sample :

Date Feature
2000/03 1.1
2000/06 0.9
2000/09 0.5
2000/12 0.6

What I would like to have is:

Date Feature
2000/01 1.1
2000/02 1.1
2000/03 1.1
2000/04 0.9
2000/05 0.9
2000/06 0.9

Moreover, in order to get more accurate values for each month, I need the data to be interpolated. Any hint how I could do that? thanks in advance!

Edit : Sorry i could not figure out proper formatting, and thus it looks a little bit ugly

If anyone encounters the same problem, here is the solution :

For resampling :
dataframe = dataframe.resample('1M').mean()

1M can changed to D ( Days ) aswell, mean() fills the "empty" values with the mean

For interpolation :
dataframe['Column'] = dataframe[['Column')].interpolate(method="linear")

other interpolation methods exist, like polynomial and so on


RE: Convert quarterly time series to monthly time series - pyzyx3qwerty - May-22-2020

Please use proper code tags while posting a thread. See BBCode