id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 462424005,MDU6SXNzdWU0NjI0MjQwMDU=,3066,xarray rolling does not match pandas when using min_periods and reduce,4903456,open,0,,,2,2019-06-30T16:44:09Z,2021-02-18T21:41:57Z,,NONE,,,,"#### MCVE Code Sample **MCVE** ```python import numpy as np import pandas as pd import xarray def custom(x, axis=0): return np.mean(x, axis) d = pd.DataFrame(np.random.rand(100,3)) r = d.rolling(10, min_periods=5).apply(custom) print(r.iloc[0:10,:]) xd = d.to_xarray().to_array() r = xd.rolling(index=10, min_periods=5).reduce(custom) print(r[:,0:10]) r = xd.rolling(index=10, min_periods=1).reduce(custom) print(r[:,0:10]) ``` #### Problem Description I am applying a custom function on rolling windows with specific `min_periods`. The output of `pandas..rolling.apply` matches what I expect; however, the output of `xarray..rolling.reduce` doesn't seem to take `min_periods` into account. #### Expected Output and Actual Output ``` 0 1 2 0 NaN NaN NaN 1 NaN NaN NaN 2 NaN NaN NaN 3 NaN NaN NaN 4 0.632168 0.523669 0.543643 5 0.558694 0.565781 0.481204 6 0.559343 0.541787 0.415490 7 0.613457 0.554888 0.398999 8 0.579552 0.496799 0.397681 9 0.562591 0.525096 0.416461 array([[ nan, nan, nan, nan, nan, nan, nan, nan, nan, 0.562591], [ nan, nan, nan, nan, nan, nan, nan, nan, nan, 0.525096], [ nan, nan, nan, nan, nan, nan, nan, nan, nan, 0.416461]]) Coordinates: * index (index) int64 0 1 2 3 4 5 6 7 8 9 * variable (variable) int64 0 1 2 array([[ nan, nan, nan, nan, nan, nan, nan, nan, nan, 0.562591], [ nan, nan, nan, nan, nan, nan, nan, nan, nan, 0.525096], [ nan, nan, nan, nan, nan, nan, nan, nan, nan, 0.416461]]) Coordinates: * index (index) int64 0 1 2 3 4 5 6 7 8 9 * variable (variable) int64 0 1 2 ``` #### Output of ``xr.show_versions()``
INSTALLED VERSIONS ------------------ commit: None python: 3.6.8 |Anaconda, Inc.| (default, Dec 29 2018, 19:04:46) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] python-bits: 64 OS: Darwin OS-release: 18.6.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.4 libnetcdf: 4.6.1 xarray: 0.12.1 pandas: 0.24.2 numpy: 1.16.4 scipy: 1.2.1 netCDF4: 1.4.2 pydap: None h5netcdf: None h5py: 2.9.0 Nio: None zarr: None cftime: 1.0.3.4 nc_time_axis: None PseudonetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: 2.0.0 distributed: 2.0.1 matplotlib: 3.1.0 cartopy: None seaborn: 0.9.0 setuptools: 41.0.1 pip: 19.1.1 conda: None pytest: None IPython: 7.5.0 sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3066/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue