Skip to content

Commit

Permalink
BUG: Aggregate by_group after by_date calculation
Browse files Browse the repository at this point in the history
MichaelJMath committed Aug 23, 2018
1 parent c5e9409 commit 4c6d96a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion alphalens/performance.py
Original file line number Diff line number Diff line change
@@ -650,7 +650,10 @@ def mean_return_by_quantile(factor_data,
mean_ret = group_stats.T.xs('mean', level=1).T

if not by_date:
group_stats = mean_ret.groupby(level='factor_quantile')\
grouper = [mean_ret.index.get_level_values('factor_quantile')]
if by_group:
grouper.append(mean_ret.index.get_level_values('group'))
group_stats = mean_ret.groupby(grouper)\
.agg(['mean', 'std', 'count'])
mean_ret = group_stats.T.xs('mean', level=1).T

0 comments on commit 4c6d96a

Please sign in to comment.