Skip to content

Commit

Permalink
Fix for pandas FutureWarning .loc[] changes
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewgilbert committed Aug 16, 2018
1 parent 8f84cbc commit 0245b23
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mapping/mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,12 @@ def to_generics(instruments, weights):
# may not always have instrument holdings for a set of weights so allow
# weights to be a superset of instruments, drop values where no
# holdings
winstrs = instruments.loc[w.index].dropna()
winstrs = instruments.reindex(w.index).dropna()
w = w.loc[winstrs.index]
# drop generics where all weights for instruments on the genric are 0.
# This avoids numerical rounding issues where solution has epsilon
# weight on a generic
w = w.loc[:, ~(w == 0).all()]
w = w.loc[:, ~(w == 0).all(axis=0)]

unmapped_instr = unmapped_instr.difference(winstrs.index)

Expand Down

0 comments on commit 0245b23

Please sign in to comment.