html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/6772#issuecomment-1438776293,https://api.github.com/repos/pydata/xarray/issues/6772,1438776293,IC_kwDOAMm_X85Vwfvl,2448579,2023-02-21T16:33:14Z,2023-02-21T16:53:35Z,MEMBER,"I think the reason it's like this is the conflict `min_periods` vs `skipna` issue.
We could just raise and ask the user to provide an appropriate `min_periods` (`min_periods=window` for `skipna=False` and `min_periods=1` for `skipna=True`)
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1301023040
https://github.com/pydata/xarray/issues/6772#issuecomment-1438733254,https://api.github.com/repos/pydata/xarray/issues/6772,1438733254,IC_kwDOAMm_X85VwVPG,14808389,2023-02-21T16:04:37Z,2023-02-21T16:04:37Z,MEMBER,"Apologies for letting this sit for so long.
The reason for the unexpected behavior seems to be that `mean` is implemented using `sum / count`:
https://github.com/pydata/xarray/blob/21d86450b3cec595c74aa410cbcc367c9c7f8a0a/xarray/core/rolling.py#L176
https://github.com/pydata/xarray/blob/21d86450b3cec595c74aa410cbcc367c9c7f8a0a/xarray/core/rolling.py#L161-L163
where `min_periods` is applied in the `sum` (by masking values where `count < min_periods`).
However, `sum` on rolling objects will fill any missing values with `0` before doing anything else, so when the actual sum is computed `skipna` does not have any effect.
So if you were to set `min_periods=1` you'd get the same result as what you'd expect while `min_periods=3` is what you're seeing.
@pydata/xarray, any idea what to do here? Should we document that passing `skipna` does not have any effect on rolling window sums / means, or would it be better to change the implementation? Or maybe I'm missing something else?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1301023040