| [ Web Proxy ] |
| Viewing: https://dataframes.bigquery.dev/reference/api/bigframes.pandas.DataFrame.diff.html | [Back] [Original] |
Section Navigation
First discrete difference of element.
Calculates the difference of a DataFrame element compared with another element in the DataFrame (default is element in previous row).
Examples:
>>> df = bpd.DataFrame({"A": [3, 1, 2], "B": [1, 2, 3]})
>>> df
A B
0 3 1
1 1 2
2 2 3
[3 rows x 2 columns]
Calculating difference with default periods=1:
>>> df.diff()
A B
0 <NA> <NA>
1 -2 1
2 1 1
[3 rows x 2 columns]
Calculating difference with periods=-1:
>>> df.diff(periods=-1)
A B
0 2 -1
1 -1 -1
2 <NA> <NA>
[3 rows x 2 columns]
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 |