Skip to content

Commit d1cce7a

Browse files
committed
REF: Format NaN fields as '--' in stats series
1 parent cadcbe2 commit d1cce7a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

backtesting/_stats.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,11 @@ def __repr__(self):
196196
'display.max_colwidth', 20, # Prevent expansion due to _equity and _trades dfs
197197
'display.max_rows', len(self), # Reveal self whole
198198
'display.precision', 5, # Enough for my eyes at least
199-
# 'format.na_rep', '--', # TODO: Enable once it works
200199
):
201-
return super().__repr__()
200+
# XXX: .fillna(nan) to replace None which aren't na_rep'd otherwise (pandas 3.0).
201+
# Replace with proper na_rep option when that becomes available.
202+
# https://github.com/pandas-dev/pandas/issues/66407
203+
return super().fillna(np.nan).to_string(na_rep='--', dtype=True)
202204

203205

204206
def dummy_stats():

0 commit comments

Comments
 (0)