Last active
January 15, 2022 21:13
-
-
Save yairst/93b1726b5f6b51ef412a5c76bea16c37 to your computer and use it in GitHub Desktop.
static vs dynamic burn rate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| from matplotlib import pyplot as plt | |
| SLO_PERIOD = 28 | |
| EBP = 2 # percent | |
| ALERTING_WIN = 1 | |
| df = pd.read_csv('sav_2013_2017.csv', parse_dates=['date']) | |
| # aviod divide by zero | |
| df['hits'] += 1 | |
| # add constant column for plotting | |
| df['static burn rate'] = (24 * SLO_PERIOD) / ALERTING_WIN * (EBP / 100) | |
| # calculate dynamic burn rate | |
| df['total_hits_last_28_days']= df.hits.rolling(24 * SLO_PERIOD).sum() | |
| df['dynamic burn rate'] = df['total_hits_last_28_days'] / (df['hits']) * (EBP / 100) | |
| # sample | |
| idx = 36984 | |
| df_sample = df[idx:idx+96] # 96 hours | |
| # plot | |
| fig, ax = plt.subplots(figsize=(16, 5)) | |
| df_sample.plot(x='date',y='hits', ax=ax, logy=True) | |
| df_sample.plot(x='date',y='dynamic burn rate', ax=ax, logy=True) | |
| df_sample.plot(x='date',y='static burn rate', ax=ax, logy=True, linestyle='--') | |
| ax.grid() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment