Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions sdg/inputs/InputBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,19 @@ def fix_dataframe_columns(self, df):
The same dataframe with rearranged columns
"""

cols = df.columns.tolist()
cols.pop(cols.index('Year'))
cols.pop(cols.index('Value'))
for col in cols:
df[col] = df[col].map(str, na_action='ignore')
cols = ['Year'] + cols + ['Value']
return df[cols]
try:
cols = df.columns.tolist()
cols.pop(cols.index('Year'))
cols.pop(cols.index('Value'))
for col in cols:
df[col] = df[col].map(str, na_action='ignore')
cols = ['Year'] + cols + ['Value']
return df[cols]
except Exception as e:
self.warn('Unable to fix Year/Value columns. Exception below:')
self.warn(str(e))
return df


def fix_empty_values(self, df):
"""Ensure that empty values are np.NaN rather than None or "".
Expand Down