def test_reshape_monthly_multiannual(): ind = pd.DatetimeIndex( pd.date_range(start='Jan-1990', end='Jan-2017', freq='m')) a = pd.DataFrame(np.random.rand(324), index=ind) b = reshape_timeseries(a, x='month', y='year', aggfunc='sum') assert b.shape == (27, 12) # 27 years, 12 months assert np.isclose(b.sum().sum(), a.sum())
def test_reshape_timeseries(): a = np.random.rand(8760) b = reshape_timeseries(a, x='dayofyear', y='hour') assert b.shape == (24,365) assert np.isclose(b.sum().sum(), a.sum())
def test_reshape_multiannual_dataframe(): a = np.random.rand(8760*2) a = pd.DataFrame(make_timeseries(a, year=2019, freq='h')) b = reshape_timeseries(a, x='dayofyear', y='hour', aggfunc='sum') assert b.shape == (24,365) assert np.isclose(b.sum().sum(), a.sum())
def test_reshape_multiannual(): a = np.random.rand(8760 * 2) a = make_timeseries(a, freq='h') b = reshape_timeseries(a, x='dayofyear', y='hour', aggfunc='sum') assert b.shape == (24, 365) assert np.isclose(b.sum().sum(), a.sum())