def test_timeseries(test_df): dct = {'model': ['a_model'] * 2, 'scenario': ['a_scenario'] * 2, 'years': [2005, 2010], 'value': [1, 6]} exp = pd.DataFrame(dct).pivot_table(index=['model', 'scenario'], columns=['years'], values='value') obs = test_df.filter(variable='Primary Energy').timeseries() npt.assert_array_equal(obs, exp)
def test_variable_depth_1_plus(test_df): obs = list(test_df.filter(level='1+')['variable'].unique()) exp = ['Primary Energy|Coal'] assert obs == exp
def test_variable_depth_0_minus(test_df): obs = list(test_df.filter(level='0-')['variable'].unique()) exp = ['Primary Energy'] assert obs == exp
def test_variable_depth_0_keep_false(test_df): obs = list(test_df.filter(level=0, keep=False)['variable'].unique()) exp = ['Primary Energy|Coal'] assert obs == exp