Skip to content

Subtract Series

Source code

Description

Method equivalent of subtraction operator series - other.

Usage

<Series>$sub(other)

Arguments

other Series like object of numeric. Converted to Series by as_polars_series() in this method.

Value

Series

See Also

  • Arithmetic operators

Examples

library("polars")

as_polars_series(1:3)$sub(11:13)
#> polars Series: shape: (3,)
#> Series: '' [i32]
#> [
#>  -10
#>  -10
#>  -10
#> ]
as_polars_series(1:3)$sub(as_polars_series(11:13))
#> polars Series: shape: (3,)
#> Series: '' [i32]
#> [
#>  -10
#>  -10
#>  -10
#> ]
as_polars_series(1:3)$sub(1L)
#> polars Series: shape: (3,)
#> Series: '' [i32]
#> [
#>  0
#>  1
#>  2
#> ]
1L - as_polars_series(1:3)
#> polars Series: shape: (3,)
#> Series: '' [i32]
#> [
#>  0
#>  -1
#>  -2
#> ]
as_polars_series(1:3) - 1L
#> polars Series: shape: (3,)
#> Series: '' [i32]
#> [
#>  0
#>  1
#>  2
#> ]