Handling of null values in the polars.Expr.rank #19415
Labels
bug
Something isn't working
needs triage
Awaiting prioritization by a maintainer
python
Related to Python Polars
Checks
Reproducible example
May be kinda related to #18243 in some way.
Updated to 1.11 released today (2024-10-24), not solved.
Actual behavior:
Log output
No response
Issue description
When encountering null values (np.nan, None, etc.), the rank method treats them as the biggest possible value, rather than ignoring them.
This behavior may be problematic in some cases. Say, I am doing quant research and ranking my factors. An NaN means model has no opinion, therefore should not give an idea about trade or not to trade. If rank method determines that NaN is the biggest one, it may mislead to a Long trade.
Suggested Improvement: An arugument like "ignore_na=True/False" may help.
Expected behavior
Ignore the NaN and rank base on valid values:
Installed versions
The text was updated successfully, but these errors were encountered: