Skip to content

Commit

Permalink
bugfix for interpolate()
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuppmann committed Jun 25, 2018
1 parent b87cea5 commit d35444e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pyam/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d35444e

Please sign in to comment.