Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8ed4186

Browse files
committedDec 22, 2015
STY Replace appending of Series with dict comprehension.
1 parent 596dd86 commit 8ed4186

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed
 

‎pyfolio/timeseries.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -739,17 +739,11 @@ def perf_stats(returns, factor_returns=None):
739739
740740
"""
741741

742-
stats = pd.Series()
743-
744-
for stat_func in SIMPLE_STAT_FUNCS:
745-
stats[stat_func.__name__] = stat_func(returns)
746-
747-
if factor_returns is not None:
748-
for stat_func in FACTOR_STAT_FUNCS:
749-
stats[stat_func.__name__] = stat_func(returns,
750-
factor_returns)
751-
752-
return stats
742+
return pd.Series(OrderedDict(
743+
(stats_func.__name__, stats_func(returns)
744+
for stats_func in SIMPLE_STATS_FUNCS +
745+
(FACTOR_STAT_FUNCS if factor_returns else [])
746+
))
753747

754748

755749
def get_max_drawdown_underwater(underwater):

0 commit comments

Comments
 (0)
Please sign in to comment.