notebooks/common.py
def calculate_ewm(series, times, halflife):
    """Calculate an exponentially weighted mean for a series."""
    
    # sanity checks
    assert len(series) == len(times)
    assert series.notna().all()
    assert times.notna().all()
    
    return (
        series
        .ewm(halflife=halflife, times=times)
        .mean()
    )
Calculate an exponentially weighted mean for a series.
Calculate an exponentially weighted mean for a series.
Calculate an exponentially weighted mean for a series .
def calculate_ewm(series, times, halflife):
    assert len(series) == len(times)
    assert series.notna().all()
    assert times.notna().all()
    return (
        series
        .ewm(halflife=halflife, times=times)
        .mean()
    )
def calculate_ewm ( series , times , halflife ) : assert len ( series ) == len ( times ) assert series . notna ( ) . all ( ) assert times . notna ( ) . all ( ) return ( series . ewm ( halflife = halflife , times = times ) . mean ( ) )
Calculate an exponentially weighted mean for a series.
Calculate an exponentially weighted mean for a series .
"""Calculate an exponentially weighted mean for a series.""" # sanity checks
series
times
halflife