ezyquant.creator.SETSignalCreator.rank#
- static SETSignalCreator.rank(factor_df: DataFrame, quantity: float | None = None, method: Literal['average', 'min', 'max', 'first', 'dense'] = 'first', ascending: bool = True, pct: bool = False)#
Compute numerical data ranks (1 through quantity) along axis.
- Parameters:
factor_df (pd.DataFrame) – Dataframe of numerical data.
quantity (Optional[float] = None) – Number/Percentile of symbols to filter, filter out symbol will replace with nan. Default is None, which means rank all symbol.
method (str = "first") –
- How to rank the group of records that have the same value (i.e. ties):
average: average rank of the group
min: lowest rank in the group
max: highest rank in the group
first: ranks assigned in order they appear in the array
dense: like ‘min’, but rank always increases by 1 between groups.
ascending (bool = True) – Whether or not the elements should be ranked in ascending order.
pct (bool = False) – Whether or not to display the returned rankings in percentile form.
- Return type:
pd.DataFrame with data ranks as values.
Examples
>>> from ezyquant import SETSignalCreator >>> df = pd.DataFrame( ... [ ... [11.0, 12.0, 13.0], ... [21.0, float("nan"), 23.0], ... [31.0, 31.0, 31.0], ... ] ... ) >>> SETSignalCreator.rank(df) 0 1 2 0 1.0 2.0 3.0 1 1.0 NaN 2.0 2 1.0 1.0 1.0