From c55f0217de0629b86a81e3c9d299edd134feb983 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Tue, 3 Mar 2020 20:22:45 -0500 Subject: [PATCH 1/2] note that n != periods in diff docstring --- xarray/core/dataarray.py | 6 ++++++ xarray/core/dataset.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index b1da0ca1448..5be67c8a707 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -2692,6 +2692,12 @@ def diff(self, dim: Hashable, n: int = 1, label: Hashable = "upper") -> "DataArr difference : same type as caller The n-th order finite difference of this object. + .. note:: + + `n` matches numpy's behavior and is different from pandas' similarly + located `periods` argument + + Examples -------- >>> arr = xr.DataArray([5, 5, 6, 6], [[1, 2, 3, 4]], ['x']) diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 7252dd2f3df..5936525f9f2 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -4879,6 +4879,11 @@ def diff(self, dim, n=1, label="upper"): difference : same type as caller The n-th order finite difference of this object. + .. note:: + + `n` matches numpy's behavior and is different from pandas' similarly + located `periods` argument + Examples -------- >>> ds = xr.Dataset({'foo': ('x', [5, 5, 6, 6])}) From 69e4bf52d4820e3e90790780a935a893f8c58dda Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Tue, 3 Mar 2020 21:23:38 -0500 Subject: [PATCH 2/2] better wording based on feedback --- xarray/core/dataarray.py | 4 ++-- xarray/core/dataset.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index 5be67c8a707..4e80ef222c2 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -2694,8 +2694,8 @@ def diff(self, dim: Hashable, n: int = 1, label: Hashable = "upper") -> "DataArr .. note:: - `n` matches numpy's behavior and is different from pandas' similarly - located `periods` argument + `n` matches numpy's behavior and is different from pandas' first + argument named `periods`. Examples diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 5936525f9f2..52940e98b27 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -4881,8 +4881,8 @@ def diff(self, dim, n=1, label="upper"): .. note:: - `n` matches numpy's behavior and is different from pandas' similarly - located `periods` argument + `n` matches numpy's behavior and is different from pandas' first + argument named `periods`. Examples --------