Skip to content

Commit

Permalink
REF: pandas 2.1.0 FutureWarning removal (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
attack68 authored Nov 12, 2023
1 parent 06205ef commit 52e8c4e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions rateslib/instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,14 +690,15 @@ def cashflows(
self.curves, solver, curves, fx, base, self.leg1.currency
)

dfs = [
self.leg1.cashflows(curves[0], curves[1], fx_, base_),
self.leg2.cashflows(curves[2], curves[3], fx_, base_),
]
_ = concat(
[_ for _ in dfs if not (_.empty or isna(_).all(axis=None))], # filter empty or na
keys=["leg1", "leg2"],
)
df1 = self.leg1.cashflows(curves[0], curves[1], fx_, base_)
df2 = self.leg2.cashflows(curves[2], curves[3], fx_, base_)
# filter empty or all NaN
dfs_filtered = [_ for _ in [df1, df2] if not (_.empty or isna(_).all(axis=None))]

with warnings.catch_warnings():
# TODO: pandas 2.1.0 has a FutureWarning for concatenating DataFrames with Null entries
warnings.filterwarnings("ignore", category=FutureWarning)
_ = concat(dfs_filtered, keys=["leg1", "leg2"])
return _

@abc.abstractmethod
Expand Down

0 comments on commit 52e8c4e

Please sign in to comment.