polars.Series.sign#

Series.sign() Series[source]#

Compute the element-wise indication of the sign.

The returned values can be -1, 0, or 1:

  • -1 if x < 0.

  • 0 if x == 0.

  • 1 if x > 0.

(null values are preserved as-is).

Examples

>>> s = pl.Series("a", [-9.0, -0.0, 0.0, 4.0, None])
>>> s.sign()
shape: (5,)
Series: 'a' [i64]
[
        -1
        0
        0
        1
        null
]