def test_map_regions_r5_agg(reg_df): columns = reg_df.data.columns obs = reg_df.map_regions('r5_region', agg='sum').data exp = _r5_regions_exp(reg_df) grp = list(columns) grp.remove('value') exp = exp.groupby(grp).sum().reset_index() exp = exp[columns] pd.testing.assert_frame_equal(obs, exp, check_index_type=False)
def test_map_regions_r5_inplace(reg_df): exp = _r5_regions_exp(reg_df) reg_df.map_regions('r5_region', inplace=True) obs = reg_df.data pd.testing.assert_frame_equal(obs, exp, check_index_type=False)
def test_map_regions_r5(reg_df): obs = reg_df.map_regions('r5_region').data exp = _r5_regions_exp(reg_df) pd.testing.assert_frame_equal(obs, exp, check_index_type=False)