Skip to content

Instantly share code, notes, and snippets.

@yairst
Last active January 15, 2022 21:13
Show Gist options
  • Save yairst/93b1726b5f6b51ef412a5c76bea16c37 to your computer and use it in GitHub Desktop.
Save yairst/93b1726b5f6b51ef412a5c76bea16c37 to your computer and use it in GitHub Desktop.

Revisions

  1. yairst revised this gist Jan 15, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion static_vs_dynamic_burn_rate.py
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    EBP = 2 # percent
    ALERTING_WIN = 1

    df = pd.read_csv('sav_2013_2017.csv')
    df = pd.read_csv('sav_2013_2017.csv', parse_dates=['date'])

    # aviod divide by zero
    df['hits'] += 1
  2. yairst created this gist Jan 14, 2022.
    29 changes: 29 additions & 0 deletions static_vs_dynamic_burn_rate.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    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')

    # 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()