bigframes.geopandas.GeoSeries.diff#

GeoSeries.diff(periods: int = 1) Series#

First discrete difference of element.

Calculates the difference of a Series element compared with another element in the Series (default is element in previous row).

Examples:

Difference with previous row

>>> s = bpd.Series([1, 1, 2, 3, 5, 8])
>>> s.diff()
0    <NA>
1       0
2       1
3       1
4       2
5       3
dtype: Int64

Difference with 3rd previous row

>>> s.diff(periods=3)
0    <NA>
1    <NA>
2    <NA>
3       2
4       4
5       6
dtype: Int64

Difference with following row

>>> s.diff(periods=-1)
0       0
1      -1
2      -1
3      -2
4      -3
5    <NA>
dtype: Int64
Parameters:

periods (int, default 1) – Periods to shift for calculating difference, accepts negative values.

Returns:

First differences of the Series.

Return type:

bigframes.pandas.Series