quantlab.utils.symbol_axis.on_roster#

quantlab.utils.symbol_axis.on_roster(axis, roster)[source]#

Return the labels of axis that are on roster, in axis order.

A roster is an undated list of symbols, often read from another store whose axis has another label type (a text roster against an integer permaticker axis). The roster is cast to axis’s type first: to text for a text axis; for a numeric axis, a roster label that is no number of that type ("CASH" against permatickers) cannot be on it and is left out. Roster labels axis lacks are left out too; the caller decides whether to report them (len(set(roster)) - len(result)).

Parameters:
axispd.Index

The symbol axis of the panel read.

rosteriterable

The roster’s labels, of any type.

Returns:
list

The kept labels of axis, in its order and type.

Examples

>>> on_roster(pd.Index([1, 2, 3, 4]), ["2", "4", "CASH"])
[2, 4]
>>> on_roster(pd.Index(["1", "2", "3"]), [3, 1])
['1', '3']