Detecting biggest increases/decreases in time series data

46 views Asked by At

I am currently performing a time series analysis (only EDA, no prediction). I want to calculate the biggest increases/decreases of one feature by looking at the complete time horizon. I can do this on a monthly basis by using pd.diff(), but also want to check if there are trends that are on a larger basis than one month. Therefore, I tried libraries such as ruptures to detect change points in my data but am not sure if they're the same points as my biggest decreases/increases.

1

There are 1 answers

0
mrk On

Assuming a lot since as mentioned in the comments a little more detail would be required.

I assume one of your features looks somewhat like this and has a value per month (sample rate):

time_series = [100, 110, 90, 120, 80, 130]

To me the rest sounds like a resample problem where you need to decide on how many months you want to aggregate into a single value (e.g. 12 for a yearly basis).

Then you go ahead and resample and approximate missing values from neighbors (if necessary).

 # Resample based on the specified months per value
 resampled_df = df.resample(f'{months_per_value}').mean()

 # Interpolate missing values to approximate the time series
 resampled_df.interpolate(inplace=True)

 return resampled_df['value'].tolist()

The resampled_df can then be used in your function as you are used to with your current time series data.