bigframes.pandas.Series.diff#

Series.diff(periods:int=1)Series[source]#

First discrete difference of element.

Calculates the difference of a Series element compared with anotherelement 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       02       13       14       25       3dtype: Int64

Difference with 3rd previous row

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

Difference with following row

>>>s.diff(periods=-1)0       01      -12      -13      -24      -35    <NA>dtype: Int64
Parameters:

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

Returns:

First differences of the Series.

Return type:

bigframes.pandas.Series

On this page

This Page