{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/10030","repository_url":"https://api.github.com/repos/pydata/pandas","labels_url":"https://api.github.com/repos/pydata/pandas/issues/10030/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/10030/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/10030/events","html_url":"https://github.com/pydata/pandas/issues/10030","id":72193794,"number":10030,"title":"weighted mean","user":{"login":"bgrayburn","id":3170676,"avatar_url":"https://avatars.githubusercontent.com/u/3170676?v=3","gravatar_id":"","url":"https://api.github.com/users/bgrayburn","html_url":"https://github.com/bgrayburn","followers_url":"https://api.github.com/users/bgrayburn/followers","following_url":"https://api.github.com/users/bgrayburn/following{/other_user}","gists_url":"https://api.github.com/users/bgrayburn/gists{/gist_id}","starred_url":"https://api.github.com/users/bgrayburn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgrayburn/subscriptions","organizations_url":"https://api.github.com/users/bgrayburn/orgs","repos_url":"https://api.github.com/users/bgrayburn/repos","events_url":"https://api.github.com/users/bgrayburn/events{/privacy}","received_events_url":"https://api.github.com/users/bgrayburn/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pydata/pandas/labels/Difficulty%20Intermediate","name":"Difficulty Intermediate","color":"fbca04"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Effort%20Medium","name":"Effort Medium","color":"006b75"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Enhancement","name":"Enhancement","color":"4E9A06"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/pydata/pandas/milestones/32","html_url":"https://github.com/pydata/pandas/milestones/Next%20Major%20Release","labels_url":"https://api.github.com/repos/pydata/pandas/milestones/32/labels","id":933188,"number":32,"title":"Next Major Release","description":"after 0.18.0 of course","creator":{"login":"jreback","id":953992,"avatar_url":"https://avatars.githubusercontent.com/u/953992?v=3","gravatar_id":"","url":"https://api.github.com/users/jreback","html_url":"https://github.com/jreback","followers_url":"https://api.github.com/users/jreback/followers","following_url":"https://api.github.com/users/jreback/following{/other_user}","gists_url":"https://api.github.com/users/jreback/gists{/gist_id}","starred_url":"https://api.github.com/users/jreback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jreback/subscriptions","organizations_url":"https://api.github.com/users/jreback/orgs","repos_url":"https://api.github.com/users/jreback/repos","events_url":"https://api.github.com/users/jreback/events{/privacy}","received_events_url":"https://api.github.com/users/jreback/received_events","type":"User","site_admin":false},"open_issues":941,"closed_issues":135,"state":"open","created_at":"2015-01-13T10:53:19Z","updated_at":"2016-05-11T16:34:44Z","due_on":"2016-08-31T04:00:00Z","closed_at":null},"comments":25,"created_at":"2015-04-30T15:24:04Z","updated_at":"2016-05-11T17:29:51Z","closed_at":null,"body":"A \"weights\" labeled parameter in the df.mean method would be extremely useful. In numpy this functionality is provided via np.average instead of np.mean which I'm assuming is how similar functionality would be added to pandas.\r\n\r\nex requested feature:\r\n```\r\n> a = np.array([[2,4,6],[8,10,12]])\r\n> w = [.5, 0, .5]\r\n> np_avg = np.average(a, weights = w, axis=1)\r\n#output ->  array([ 4., 10.])\r\n> pd_avg = pandas.DataFrame(a).mean(weights = w, axis=1)\r\n#desired output -> series with entries 4 and 10\r\n```\r\n\r\nIf this is a desired feature I'll complete this and submit a pull request if desired. If this is somewhere already I've overlooked, my apologies, I've tried to look thoroughly."},"comment":{"url":"https://api.github.com/repos/pydata/pandas/issues/comments/218531028","html_url":"https://github.com/pydata/pandas/issues/10030#issuecomment-218531028","issue_url":"https://api.github.com/repos/pydata/pandas/issues/10030","id":218531028,"user":{"login":"shoyer","id":1217238,"avatar_url":"https://avatars.githubusercontent.com/u/1217238?v=3","gravatar_id":"","url":"https://api.github.com/users/shoyer","html_url":"https://github.com/shoyer","followers_url":"https://api.github.com/users/shoyer/followers","following_url":"https://api.github.com/users/shoyer/following{/other_user}","gists_url":"https://api.github.com/users/shoyer/gists{/gist_id}","starred_url":"https://api.github.com/users/shoyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shoyer/subscriptions","organizations_url":"https://api.github.com/users/shoyer/orgs","repos_url":"https://api.github.com/users/shoyer/repos","events_url":"https://api.github.com/users/shoyer/events{/privacy}","received_events_url":"https://api.github.com/users/shoyer/received_events","type":"User","site_admin":false},"created_at":"2016-05-11T17:29:50Z","updated_at":"2016-05-11T17:29:50Z","body":"> How are we defining weights here? Are negative weights accepted (I think the domain could depend on the function)? Must weights be of the same length as the data points?\r\n\r\nMy vision for the `weights` argument is quite similar to how it is currently defined on `DataFrame.sample`:\r\nhttp://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.sample.html\r\n\r\nSo weights need to non-negative numbers that are alignable with the object being weighted. They do not need to be prenormalized, though perhaps there should be a keyword argument on `weightby` to indicate that that doesn't need to be checked (if it's actually a real performance concern). We also might add an `axis` argument, which allows you to select the axis over weights are applied. This would let weight columns in a DataFrame differently, for example.\r\n\r\n> Does this API do any validation or is that deferred to the stats functions (if weights can be a lambda, I imagine it's the latter)?\r\n\r\nIdeally we could share validation between different methods on `weightby`. I don't think it particularly matters whether you validate before or after calling the submethod on the `WeightByMethods` object."}}