From d35444ec5062e496c1892ef484e33aff91bafecf Mon Sep 17 00:00:00 2001 From: Daniel Huppmann Date: Mon, 25 Jun 2018 15:28:20 +0200 Subject: [PATCH] bugfix for `interpolate()` --- pyam/core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyam/core.py b/pyam/core.py index 0755fcb2e..b6404a331 100644 --- a/pyam/core.py +++ b/pyam/core.py @@ -215,12 +215,15 @@ def interpolate(self, year): """ df = self.pivot_table(index=IAMC_IDX, columns=['year'], values='value', aggfunc=np.sum) + # drop year-rows where values are already defined + if year in df.columns: + df = df[np.isnan(df[year])] fill_values = df.apply(fill_series, raw=False, axis=1, year=year) fill_values = fill_values.dropna().reset_index() fill_values = fill_values.rename(columns={0: "value"}) fill_values['year'] = year - self.data = self.data.append(fill_values) + self.data = self.data.append(fill_values, ignore_index=True) def as_pandas(self, with_metadata=False): """Return this as a pd.DataFrame