Spec-Zone.ru › Polars

polars.Series.sign

Series.sign() → Series

Compute the element-wise sign function on numeric types.

The returned value is computed as follows:

  • -1 if x < 0.
  • 1 if x > 0.
  • x otherwise (typically 0, but could be NaN if the input is).

Null values are preserved as-is, and the dtype of the input is preserved.

Examples

>>> s = pl.Series("a", [-9.0, -0.0, 0.0, 4.0, float("nan"), None])
>>> s.sign()
shape: (6,)
Series: 'a' [f64]
[
    -1.0
    -0.0
    0.0
    1.0
    NaN
    null
]

© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/series/api/polars.Series.sign.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API