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) ) 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):