qis.LegendStats

class qis.LegendStats(*values)[source]

Bases: Enum

which summary statistics the legend prints beside each series name.

The members are compositional and the name reads left to right in the order the statistics appear in the legend, so AVG_STD_LAST prints the mean, the standard deviation and the final value in that order. Rather than restate twenty-nine names, the vocabulary:

AVG mean, STD standard deviation with ddof=1, MEDIAN median, MAD median absolute deviation scaled to be comparable with a standard deviation, SKEW the biased standardized third moment, KURT biased excess kurtosis, TSTAT mean over standard error, TOTAL the sum, FIRST and LAST the endpoints, MIN and MAX the extremes. After any modifier’s sample selection, STD is undefined when fewer than two observations remain; SKEW and KURT are undefined for an exact finite constant. Finite samples are translated before sample standard deviation is evaluated, and eligible finite varying samples are translated before standardized moments are evaluated, preserving their results when the spread is very small relative to the level.

Endpoint selection is mode-specific. The direct endpoint modes LAST, AVG_LAST, and AVG_STD_LAST use the value at the final index. Explicit NONNAN modes use the final observed value. Other composite FIRST/LAST modes first drop missing observations and select both endpoints from that same sample, so FIRST means the first selected observation. NONZERO composites additionally remove exact zeros before selecting their endpoints.

Five modifiers change what the statistics are computed on or displayed beside them:

NONNAN names final-observed selection explicitly. NONZERO excludes zeros, for a series where zero means “no position” rather than “a return of zero”; its statistics are undefined when no observations remain. MISSING reports the percentage of NaN observations after the first observed value, while ZERO reports the percentage whose absolute value is below the near-zero cutoff over the same window. An all-missing history has 100% missing coverage and an undefined zero percentage. SCORE appends the percentile rank of the last value within its own selected history.

NONE prints the column name alone. Data-valued summaries such as the mean and standard deviation follow the plotting function’s var_format; when it is None, these summaries use their native scalar text. T-statistics, skewness and kurtosis keep separate two-decimal formats, while scores and missing/zero ratios keep percentage formats. A percentage-formatted mean therefore does not turn its dimensionless t-statistic into a percentage. A missing indexed endpoint uses the configured numeric missing display regardless of whether the input stores it as np.nan or pd.NA. The enum selects the statistics together with their mode-specific display conventions.

A member documented here is computed in get_legend_lines, which is the single place the legend text is built for every plot in the package.

__init__(*args, **kwds)

Attributes

NONE = 1
LAST = 2
AVG = 3
AVG_LAST = 4
AVG_STD = 5
AVG_STD_SKEW_KURT = 6
AVG_STD_LAST = 7
AVG_NONNAN_LAST = 8
NONZERO_AVG_LAST = 81
NONZERO_AVG_STD_LAST = 82
MEDIAN_NONNAN_LAST = 9
AVG_MEDIAN_STD_NONNAN_LAST = 10
AVG_LAST_SCORE = 11
AVG_STD_LAST_SCORE = 12
FIRST_LAST = 13
FIRST_LAST_NON_ZERO = 14
FIRST_AVG_LAST = 15
FIRST_MEDIAN_LAST = 16
FIRST_AVG_LAST_SHORT = 17
AVG_STD_MISSING_ZERO = 18
MISSING_AVG_LAST = 19
TOTAL = 20
MEDIAN = 21
MEDIAN_MAD = 22
TSTAT = 23
AVG_STD_TSTAT = 24
LAST_NONNAN = 25
AVG_MIN_MAX_LAST = 26
FIRST_MIN_MAX_LAST = 27