| [ Web Proxy ] |
| Viewing: https://dataframes.bigquery.dev/reference/api/bigframes.pandas.Series.diff.html | [Back] [Original] |
Section Navigation
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
periods (int, default 1) Periods to shift for calculating difference, accepts negative values.
First differences of the Series.
Copyright 2019, Google.
Created using Sphinx 8.1.3.
Built with the PyData Sphinx Theme 0.19.0.
| Web Proxy Viewer | New URL | Original Page |