From c03a73c88ac9dcf25c9b204e03a5322e6666f4a4 Mon Sep 17 00:00:00 2001 From: huaiweicheng Date: Fri, 6 Sep 2019 14:37:59 +0800 Subject: [PATCH 1/2] fix some bugs in pandas==0.25.0 --- pyfolio/tests/test_round_trips.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyfolio/tests/test_round_trips.py b/pyfolio/tests/test_round_trips.py index 7ba48f4e..d92be1a7 100644 --- a/pyfolio/tests/test_round_trips.py +++ b/pyfolio/tests/test_round_trips.py @@ -39,7 +39,7 @@ class RoundTripTestCase(TestCase): ], columns=['amount', 'price', 'symbol'], index=dates_intraday[[0, 2]]) - .rename('dt', axis='index') + .rename_axis('dt', axis='index') ), (DataFrame(data=[[2, 10., 'A'], [2, 20., 'A'], @@ -53,7 +53,7 @@ class RoundTripTestCase(TestCase): ], columns=['amount', 'price', 'symbol'], index=dates_intraday[[0, 4]]) - .rename('dt', axis='index') + .rename_axis('dt', axis='index') ), ]) def test_groupby_consecutive(self, transactions, expected): From 03c085ee0d5cb57ebf20cf6c9bdb280262c610f5 Mon Sep 17 00:00:00 2001 From: huaiweicheng Date: Tue, 17 Sep 2019 18:16:55 +0800 Subject: [PATCH 2/2] columns_to_select --- pyfolio/tears.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyfolio/tears.py b/pyfolio/tears.py index 091c000d..e7754460 100644 --- a/pyfolio/tears.py +++ b/pyfolio/tears.py @@ -1354,9 +1354,12 @@ def create_perf_attrib_tear_sheet(returns, for factor_type, partitions in factor_partitions.items(): + columns_to_select = portfolio_exposures.columns.intersection( + partitions + ) + perf_attrib.plot_risk_exposures( - portfolio_exposures[portfolio_exposures.columns - .intersection(partitions)], + portfolio_exposures[columns_to_select], ax=plt.subplot(gs[current_section]), title='Daily {} factor exposures'.format(factor_type) )