-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add examples for DataArrayRolling.reduce()
#2968
Add examples for DataArrayRolling.reduce()
#2968
Conversation
I think you can keep the function signature of Then you change your code in if self.min_periods == 0:
return result btw: If I understand correctly, this does not need to be added for the other functions |
@mathause, thank you, I didn't realize that. I'll make those changes. |
Actually, every window has at least 1 valid value, so this change isn't really needed at all. I'll remove the code changes, and change the added example to show a working example of what I wanted. I will say that Would it be reasonable to deprecate |
* Adds two examples to DataArrayRolling.reduce(); the second example shows the interaction of reduce() and min_periods
4ec82e1
to
a59d6f6
Compare
DataArrayRolling.reduce()
DataArrayRolling.reduce()
Changed to simply add examples to |
@kmsquire thanks. Can you also add some text to https://xarray.pydata.org/en/stable/computation.html#rolling-window-operations (i.e. computation.rst) describing what |
@dcherian added. Let me know if you want any changes. |
* Add a longer description and examples for the `center` and `min_period` parameters to `DataArray.rolling()`
e1199a7
to
0389060
Compare
Thanks @kmsquire . The tests failed but they seem unrelated (the docs build passed). |
When reducing over a rolling window,DataArrayRolling.reduce()
only returns values where the complete rolling window is fully
conatined within the base array; the remaining locations where
the window overlaps the array border are filled with
NaN
However, in some situations, it is desirable to obtain values from the
reducer function for all locations. This commit adds a keyword
argument,
include_border
, toDataArrayRolling.reduce()
andDataSetRolling.reduce()
to allow this behavior.If this seems okay, I have some questions:1. Should this behavior be added to specific reducing functions (sum, mean, etc.)? As an alternative, all of the specialized functions forDataArrayRolling
have corresponding numpynan*
functions, so support could be added for those. (The current PR is still useful for other reducing functions, which is my use case.)2. I don't use dask, so I don't know if this is needed/desired for the dask versions of these functions.As @mathause pointed out, the functionality desired already exists by passing
min_periods=1
toDataArray.rolling()
. So this MR has been updated to simply include some examples forDataArrayRolling.reduce()