Skip to content

Commit

Permalink
fix bug with pandas .replace messing up dtype
Browse files Browse the repository at this point in the history
  • Loading branch information
chanshing committed Aug 21, 2019
1 parent 2a36736 commit d80c4aa
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions accelerometer/accClassification.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ def activityClassification(epochFile,
X.loc[~null_rows, 'label'] = hmmPredictions

# perform MET prediction...
#! pandas .replace method has a small bug
#! see https://github.com/pandas-dev/pandas/issues/23305
#! we need to force type
met_vals = np.load(getFileFromTar(activityModel, 'METs.npy'))
met_dict = {}
for l, m in zip(labels, met_vals):
met_dict[l] = m
X.loc[~null_rows, 'MET'] = X.loc[~null_rows, 'label'].replace(met_dict)
met_dict = dict(zip(labels, met_vals))
X.loc[~null_rows, 'MET'] = X.loc[~null_rows, 'label'].replace(met_dict).astype('float')

# apply one-hot encoding
for l in labels:
Expand Down

0 comments on commit d80c4aa

Please sign in to comment.