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/pull/650#issuecomment-218358483,https://api.github.com/repos/pydata/xarray/issues/650,218358483,MDEyOklzc3VlQ29tbWVudDIxODM1ODQ4Mw==,2443309,2016-05-11T04:25:04Z,2016-05-11T04:25:04Z,MEMBER,"@MaximilianR - I really like this idea. I'm going to close this PR and we can continue to discuss this feature in the original issue (https://github.com/pydata/xarray/issues/422#issuecomment-218358372). ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,115933483 https://github.com/pydata/xarray/pull/650#issuecomment-218321387,https://api.github.com/repos/pydata/xarray/issues/650,218321387,MDEyOklzc3VlQ29tbWVudDIxODMyMTM4Nw==,1217238,2016-05-10T23:28:52Z,2016-05-10T23:28:52Z,MEMBER,"@MaximilianR great idea! A groupby like interface is much cleaner than adding more orthogonal code paths to .mean and the like. ","{""total_count"": 3, ""+1"": 0, ""-1"": 1, ""laugh"": 0, ""hooray"": 2, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,115933483 https://github.com/pydata/xarray/pull/650#issuecomment-218315882,https://api.github.com/repos/pydata/xarray/issues/650,218315882,MDEyOklzc3VlQ29tbWVudDIxODMxNTg4Mg==,5635139,2016-05-10T22:54:51Z,2016-05-10T22:54:51Z,MEMBER,"How about designing this as a `groupby`-like interface? In the same way as `.rolling` (or `.expanding` & `.ewm` in pandas)? So for example `ds.weighted(weights=ds.dim).mean()`. And then this is extensible, clean, pandan-tic. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,115933483 https://github.com/pydata/xarray/pull/650#issuecomment-218304910,https://api.github.com/repos/pydata/xarray/issues/650,218304910,MDEyOklzc3VlQ29tbWVudDIxODMwNDkxMA==,10194086,2016-05-10T22:00:35Z,2016-05-10T22:00:35Z,MEMBER,"I could imagine to continue working on this - however, there are some open design questions: - Do we include `skipna`? (I would say yes) - Do we allow the weights to contain NaN? (I would say yes, although disallowing it would make it easier.) - Does `skipna` also apply to the weights or are NaNs always skipped in the weights? (I would suggest the latter.) - Do we need a `skipna_weights` for a fine grained control of this? (This sounds unnecessary) - Do you agree with the above given examples? ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,115933483 https://github.com/pydata/xarray/pull/650#issuecomment-218302515,https://api.github.com/repos/pydata/xarray/issues/650,218302515,MDEyOklzc3VlQ29tbWVudDIxODMwMjUxNQ==,1217238,2016-05-10T21:49:53Z,2016-05-10T21:49:53Z,MEMBER,"> Do you know if a weighted mean is planned in pandas? Like most new features for pandas (or xarray, for that matter), there isn't anyone who has committed to working on it -- it will depend on the interest of a contributor. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,115933483 https://github.com/pydata/xarray/pull/650#issuecomment-218302130,https://api.github.com/repos/pydata/xarray/issues/650,218302130,MDEyOklzc3VlQ29tbWVudDIxODMwMjEzMA==,10194086,2016-05-10T21:48:02Z,2016-05-10T21:48:02Z,MEMBER,"It seems incorporating this to `mean` may not be very practical and `average` not the cleanest solution. Do you know if a weighted `mean` is planned in `pandas`? Anyway, I have tried to put together some corner cases whre there are NaN in the data or the weights. Unfortunately there is no `np.nanaverage`, so I also compared it to `np.ma.average`. I put together a gist with a lot of examples: https://gist.github.com/mathause/720cbca2d97597a99534581b8ca296a5 The above implementation works fine, however there are currently two cases where I expect another answer: ``` data = [1, np.nan]; weights = [0, 1.] >>> 0. ``` I think this should return NaN. ``` data = [1, 1.]; weights = [np.nan, np.nan] >>> 0 data = [1, 1.]; weights = [np.nan, 0] >>> 0 ``` I think these should also return NaN. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,115933483 https://github.com/pydata/xarray/pull/650#issuecomment-186354428,https://api.github.com/repos/pydata/xarray/issues/650,186354428,MDEyOklzc3VlQ29tbWVudDE4NjM1NDQyOA==,1217238,2016-02-19T18:36:22Z,2016-02-19T18:37:47Z,MEMBER,"I would still lean toward trying to put this into `mean`. You already have most of what you need -- it would just be a matter of dropping `mean` from the list of injected methods. https://github.com/pydata/xarray/issues/770 might help with some of the redundant code (if/when we get around to it). ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,115933483 https://github.com/pydata/xarray/pull/650#issuecomment-186214729,https://api.github.com/repos/pydata/xarray/issues/650,186214729,MDEyOklzc3VlQ29tbWVudDE4NjIxNDcyOQ==,10194086,2016-02-19T13:34:33Z,2016-02-19T13:34:33Z,MEMBER,"I am fine having it as extra method. I think it is an important feature to have - I use this function every day. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,115933483 https://github.com/pydata/xarray/pull/650#issuecomment-185542959,https://api.github.com/repos/pydata/xarray/issues/650,185542959,MDEyOklzc3VlQ29tbWVudDE4NTU0Mjk1OQ==,2443309,2016-02-18T05:00:58Z,2016-02-18T05:00:58Z,MEMBER,"I'm doing some cleanup on my outstanding issues/PRs. After thinking about this again, I'm not all than keen on pushing this into the `mean` method. I actually think it will end up being a bit of an ordeal to make happen. `mean` is currently injected as one of the `NAN_REDUCE_METHODS`. Its not entirely clear to me if it will be ""cleaner"" to refactor `mean` to support `weights`. Thoughts? ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,115933483 https://github.com/pydata/xarray/pull/650#issuecomment-156154844,https://api.github.com/repos/pydata/xarray/issues/650,156154844,MDEyOklzc3VlQ29tbWVudDE1NjE1NDg0NA==,10194086,2015-11-12T16:24:02Z,2015-11-12T16:24:02Z,MEMBER,"Didn't realize you were working on this. Pulling it into mean is fine for me (if you need the weights it is a one-liner). `average` in numpy seems comparatively complicated - maybe that's why it got it's own function... - average with no valid elements (or 0 weight) seems to return NaN which is fine - maybe you need to add tests when the data contains NaN @jhamman you showed this in a lecture? cool :) ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,115933483 https://github.com/pydata/xarray/pull/650#issuecomment-156139264,https://api.github.com/repos/pydata/xarray/issues/650,156139264,MDEyOklzc3VlQ29tbWVudDE1NjEzOTI2NA==,2443309,2015-11-12T15:32:07Z,2015-11-12T15:32:35Z,MEMBER,"Okay, let's go with the `mean` refactor. We'll drop the `returned` arg and just add `weights` to the method. @mathause - any comment? ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,115933483 https://github.com/pydata/xarray/pull/650#issuecomment-156018718,https://api.github.com/repos/pydata/xarray/issues/650,156018718,MDEyOklzc3VlQ29tbWVudDE1NjAxODcxOA==,1217238,2015-11-12T06:58:40Z,2015-11-12T06:58:40Z,MEMBER,"If you think the ability to return `sum_of_weights` is important, then this probably makes sense as a separate method -- that would be pretty confusing to add to `mean`. Otherwise, I would be inclined to simply add `weights=None` to `mean`. That would require a bit of refactoring but shouldn't be too bad. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,115933483 https://github.com/pydata/xarray/pull/650#issuecomment-155478982,https://api.github.com/repos/pydata/xarray/issues/650,155478982,MDEyOklzc3VlQ29tbWVudDE1NTQ3ODk4Mg==,2443309,2015-11-10T16:34:41Z,2015-11-10T16:34:41Z,MEMBER,"> Any thoughts on the tradeoff between adding `average` vs adding a `weights` argument to `mean`? I guess it's nice that this mirrors NumPy. That would be the main motivation. If Pandas is going the way of pydata/pandas#10030 via mean, I think we could do that as well. I actually like that approach more since we tend to call it a ""weighted mean"" (see title of pandas issue). ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,115933483 https://github.com/pydata/xarray/pull/650#issuecomment-155357189,https://api.github.com/repos/pydata/xarray/issues/650,155357189,MDEyOklzc3VlQ29tbWVudDE1NTM1NzE4OQ==,1217238,2015-11-10T08:29:44Z,2015-11-10T08:29:44Z,MEMBER,"Any thoughts on the tradeoff between adding `average` vs adding a `weights` argument to `mean`? I guess it's nice that this mirrors NumPy. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,115933483 https://github.com/pydata/xarray/pull/650#issuecomment-155161359,https://api.github.com/repos/pydata/xarray/issues/650,155161359,MDEyOklzc3VlQ29tbWVudDE1NTE2MTM1OQ==,2443309,2015-11-09T19:16:29Z,2015-11-09T19:16:29Z,MEMBER,"Thanks @maximilianr. There has been an open issue here on this for a while (#422). @shoyer - I'm actually not sure I love how I implemented this but I'm teaching a session on open source contributions and code review today so I threw this up here as an example. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,115933483 https://github.com/pydata/xarray/pull/650#issuecomment-155153560,https://api.github.com/repos/pydata/xarray/issues/650,155153560,MDEyOklzc3VlQ29tbWVudDE1NTE1MzU2MA==,5635139,2015-11-09T18:51:51Z,2015-11-09T18:51:51Z,MEMBER,"xref https://github.com/pydata/pandas/issues/10030 ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,115933483