Spec-Zone.ru › Polars

polars.Series.diff

Series.diff(
    n: int = 1,
    null_behavior: NullBehavior = 'ignore',
) → Series

Вычисляет первую дискретную разность между элементами со сдвигом.

Параметры:
n

Количество позиций для сдвига.

null_behavior{‘ignore’, ‘drop’}

Способ обработки нулевых значений.

Примеры

>>> s = pl.Series("s", values=[20, 10, 30, 25, 35], dtype=pl.Int8)
>>> s.diff()
shape: (5,)
Series: 's' [i8]
[
    null
    -10
    20
    -5
    10
]
>>> s.diff(n=2)
shape: (5,)
Series: 's' [i8]
[
    null
    null
    10
    15
    5
]
>>> s.diff(n=2, null_behavior="drop")
shape: (3,)
Series: 's' [i8]
[
    10
    15
    5
]

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

Spec-Zone.ru

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