May-21-2020, 01:20 PM
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
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