def get_esd(ts: pd.core.series.Series, fs: float) -> tuple:

    T = 1 / fs
    N = len(ts)
    F = 1 / (N * T)
    b = (np.abs(T * np.fft.fft(ts))) ** 2
    c = b[0:N//2+1]
    esd = c * 2
    f = np.array(range(int(N/2+1)))
    f = f * F
    return (esd, f) 
    timeseries_2 = timeseries - timeseries.mean()
    esd_2, f = get_esd(timeseries_2, 1.0)
    plt.figure(3)
    plt.plot(f, esd_2)
    plt.title('Energy Spectral Density')
    plt.xlabel('Frequency (1/month)')
    plt.ylabel('ESD (sales**2 * month / (1/month))')
    plt.grid()