Skip to content

Commit

Permalink
Added a method for loading json files
Browse files Browse the repository at this point in the history
  • Loading branch information
ecmjohnson committed Aug 8, 2016
1 parent 4907f15 commit 2471042
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions dsdtools/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,28 @@ def import_mat(self, filename):
)
self.append(s)

def import_json(self, filename):
with open(filename, 'r') as f:
df = pd.read_json(f.read())
# play with it a bit to get the columns and rows in the right order
df = df.sort_index(ascending=True)
base_cols = [
'track_id',
'track_name',
'target_name',
'estimate_dir',
'SDR',
'ISR',
'SIR',
'SAR',
'sample',
'subset'
]
new_cols = set(df.columns.tolist()).difference(set(base_cols))
cols = base_cols + list(new_cols)
df = df[cols]
self.df = pd.concat([self.df, df], ignore_index=True)


class BSSeval(object):
def __init__(
Expand Down

0 comments on commit 2471042

Please sign in to comment.