{"action":"created","comment":{"url":"https://api.github.com/repos/pydata/pandas/pulls/comments/47632982","id":47632982,"diff_hunk":"@@ -37,27 +38,18 @@\n import pandas.algos as _algos\n import pandas.hashtable as _hash\n \n-_agg_doc = \"\"\"Aggregate using input function or dict of {column -> function}\n-\n-Parameters\n-----------\n-arg : function or dict\n-    Function to use for aggregating groups. If a function, must either\n-    work when passed a DataFrame or when passed to DataFrame.apply. If\n-    passed a dict, the keys must be DataFrame column names.\n-\n-Notes\n------\n-Numpy functions mean/median/prod/sum/std/var are special cased so the\n-default behavior is applying the function along axis=0\n-(e.g., np.mean(arr_2d, axis=0)) as opposed to\n-mimicking the default Numpy behavior (e.g., np.mean(arr_2d)).\n-\n-Returns\n--------\n-aggregated : DataFrame\n-\"\"\"\n+_doc_template = \"\"\"\n+\n+        Returns\n+        -------\n+        same type as input","path":"pandas/core/groupby.py","position":48,"original_position":48,"commit_id":"25584402f79536a962f1b989646b3229bad9815b","original_commit_id":"25584402f79536a962f1b989646b3229bad9815b","user":{"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},"body":"yeh, we could prob add another appender for the reductions and a different one for the transforms. But will leave that for another PR.","created_at":"2015-12-15T13:07:22Z","updated_at":"2015-12-15T13:07:22Z","html_url":"https://github.com/pydata/pandas/pull/11603#discussion_r47632982","pull_request_url":"https://api.github.com/repos/pydata/pandas/pulls/11603","_links":{"self":{"href":"https://api.github.com/repos/pydata/pandas/pulls/comments/47632982"},"html":{"href":"https://github.com/pydata/pandas/pull/11603#discussion_r47632982"},"pull_request":{"href":"https://api.github.com/repos/pydata/pandas/pulls/11603"}}},"pull_request":{"url":"https://api.github.com/repos/pydata/pandas/pulls/11603","id":50728632,"html_url":"https://github.com/pydata/pandas/pull/11603","diff_url":"https://github.com/pydata/pandas/pull/11603.diff","patch_url":"https://github.com/pydata/pandas/pull/11603.patch","issue_url":"https://api.github.com/repos/pydata/pandas/issues/11603","number":11603,"state":"open","locked":false,"title":"API: provide Rolling/Expanding/EWM objects for deferred rolling type calculations #10702","user":{"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},"body":"closes #10702 \r\ncloses #9052\r\nxref #4950, removal of depr\r\n \r\nSo this basically takes all of the ``pd.rolling_*``,``pd.expanding_*``,``pd.ewma_*`` routines and allows an object oriented interface, similar to groupby.\r\n\r\nSome benefits:\r\n\r\n- nice tab completions on the Rolling/Expanding/EWM objects\r\n- much cleaner code internally\r\n- complete back compat, e.g. everything just works like it did\r\n- added a ``.agg/aggregate`` function, similar to groupby, where you can do multiple aggregations at once\r\n- added ``__getitem__`` accessing, e.g. ``df.rolling(....)['A','B'].sum()`` for a nicer API\r\n- allows for much of #8659  to be done very easily\r\n- fix for coercing Timedeltas properly\r\n- handling nuiscance (string) columns\r\n\r\nOther:\r\n- along with window doc rewrite, fixed doc-strings for groupby/window to provide back-refs\r\n\r\nToDO:\r\n- [x] I think that all of the doc-strings are correct, but need check\r\n- [x] implement ``.agg``\r\n- [x] update API.rst, what's new\r\n- [x] deprecate the ``pd.expanding_*``,``pd.rolling_*``,``pd.ewma_*`` interface as this is polluting the top-level namespace quite a bit\r\n- [x] change the docs to use the new API\r\n\r\n```\r\nIn [4]: df = DataFrame({'A' : range(5), 'B' : pd.timedelta_range('1 day',periods=5), 'C' : 'foo'})\r\n\r\nIn [5]: df.rolling(window=2).sum()\r\nOut[5]: \r\n    A      B    C\r\n0 NaN    NaT  foo\r\n1   1 3 days  foo\r\n2   3 5 days  foo\r\n3   5 7 days  foo\r\n4   7 9 days  foo\r\n\r\nIn [6]: df.rolling(window=2)['A','C'].sum()\r\nOut[6]: \r\n    A    C\r\n0 NaN  foo\r\n1   1  foo\r\n2   3  foo\r\n3   5  foo\r\n4   7  foo\r\n\r\nIn [2]: r = df.rolling(window=3)\r\n\r\nIn [3]: r.\r\nr.A         r.C         r.corr      r.cov       r.max       r.median    r.name      r.skew      r.sum       \r\nr.B         r.apply     r.count     r.kurt      r.mean      r.min       r.quantile  r.std       r.var       \r\n```\r\n\r\ndo rolling/expanding/ewma ops\r\n```\r\nIn [1]: s = Series(range(5))\r\n\r\nIn [2]: r = s.rolling(2)\r\n\r\nI# pd.rolling_sum\r\nIn [3]: r.sum()\r\nOut[3]: \r\n0   NaN\r\n1     1\r\n2     3\r\n3     5\r\n4     7\r\ndtype: float64\r\n\r\n# nicer repr\r\nIn [4]: r\r\nOut[4]: Rolling [window->2,center->False,axis->0]\r\n\r\nIn [5]: e = s.expanding(min_periods=2)\r\n\r\n# pd.expanding_sum\r\nIn [6]: e.sum()\r\nOut[6]: \r\n0   NaN\r\n1     1\r\n2     3\r\n3     6\r\n4    10\r\ndtype: float64\r\n\r\nIn [7]: em = s.ewm(com=10)\r\n\r\n# pd.ewma\r\nIn [8]: em.mean()\r\nOut[8]: \r\n0    0.000000\r\n1    0.523810\r\n2    1.063444\r\n3    1.618832\r\n4    2.189874\r\ndtype: float64\r\n```\r\n\r\nand allow the various aggregation type of ops (similar to groupby)\r\n```\r\nIn [1]: df = DataFrame({'A' : range(5), 'B' : pd.timedelta_range('1 day',periods=5), 'C' : 'foo'})\r\n\r\nIn [2]: r = df.rolling(2,min_periods=1)\r\n\r\nIn [3]: r.agg([np.sum,np.mean])\r\nOut[3]: \r\n    A           B                    C     \r\n  sum mean    sum            mean  sum mean\r\n0   0  0.0 1 days 1 days 00:00:00  foo  foo\r\n1   1  0.5 3 days 1 days 12:00:00  foo  foo\r\n2   3  1.5 5 days 2 days 12:00:00  foo  foo\r\n3   5  2.5 7 days 3 days 12:00:00  foo  foo\r\n4   7  3.5 9 days 4 days 12:00:00  foo  foo\r\n\r\nIn [4]: r.agg({'A' : 'sum', 'B' : 'mean'})\r\nOut[4]: \r\n   A               B\r\n0  0 1 days 00:00:00\r\n1  1 1 days 12:00:00\r\n2  3 2 days 12:00:00\r\n3  5 3 days 12:00:00\r\n4  7 4 days 12:00:00\r\n```","created_at":"2015-11-14T18:12:18Z","updated_at":"2015-12-15T13:07:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e594d1ffe8f5a2081089a0dc4c35bbd4d32b6d4b","assignee":null,"milestone":{"url":"https://api.github.com/repos/pydata/pandas/milestones/36","html_url":"https://github.com/pydata/pandas/milestones/0.18.0","labels_url":"https://api.github.com/repos/pydata/pandas/milestones/36/labels","id":1214851,"number":36,"title":"0.18.0","description":"","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":63,"closed_issues":63,"state":"open","created_at":"2015-07-19T20:18:45Z","updated_at":"2015-12-15T12:44:02Z","due_on":"2016-01-31T05:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/pydata/pandas/pulls/11603/commits","review_comments_url":"https://api.github.com/repos/pydata/pandas/pulls/11603/comments","review_comment_url":"https://api.github.com/repos/pydata/pandas/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/11603/comments","statuses_url":"https://api.github.com/repos/pydata/pandas/statuses/25584402f79536a962f1b989646b3229bad9815b","head":{"label":"jreback:rolling","ref":"rolling","sha":"25584402f79536a962f1b989646b3229bad9815b","user":{"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},"repo":{"id":2142250,"name":"pandas","full_name":"jreback/pandas","owner":{"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},"private":false,"html_url":"https://github.com/jreback/pandas","description":"Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more","fork":true,"url":"https://api.github.com/repos/jreback/pandas","forks_url":"https://api.github.com/repos/jreback/pandas/forks","keys_url":"https://api.github.com/repos/jreback/pandas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jreback/pandas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jreback/pandas/teams","hooks_url":"https://api.github.com/repos/jreback/pandas/hooks","issue_events_url":"https://api.github.com/repos/jreback/pandas/issues/events{/number}","events_url":"https://api.github.com/repos/jreback/pandas/events","assignees_url":"https://api.github.com/repos/jreback/pandas/assignees{/user}","branches_url":"https://api.github.com/repos/jreback/pandas/branches{/branch}","tags_url":"https://api.github.com/repos/jreback/pandas/tags","blobs_url":"https://api.github.com/repos/jreback/pandas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jreback/pandas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jreback/pandas/git/refs{/sha}","trees_url":"https://api.github.com/repos/jreback/pandas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jreback/pandas/statuses/{sha}","languages_url":"https://api.github.com/repos/jreback/pandas/languages","stargazers_url":"https://api.github.com/repos/jreback/pandas/stargazers","contributors_url":"https://api.github.com/repos/jreback/pandas/contributors","subscribers_url":"https://api.github.com/repos/jreback/pandas/subscribers","subscription_url":"https://api.github.com/repos/jreback/pandas/subscription","commits_url":"https://api.github.com/repos/jreback/pandas/commits{/sha}","git_commits_url":"https://api.github.com/repos/jreback/pandas/git/commits{/sha}","comments_url":"https://api.github.com/repos/jreback/pandas/comments{/number}","issue_comment_url":"https://api.github.com/repos/jreback/pandas/issues/comments{/number}","contents_url":"https://api.github.com/repos/jreback/pandas/contents/{+path}","compare_url":"https://api.github.com/repos/jreback/pandas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jreback/pandas/merges","archive_url":"https://api.github.com/repos/jreback/pandas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jreback/pandas/downloads","issues_url":"https://api.github.com/repos/jreback/pandas/issues{/number}","pulls_url":"https://api.github.com/repos/jreback/pandas/pulls{/number}","milestones_url":"https://api.github.com/repos/jreback/pandas/milestones{/number}","notifications_url":"https://api.github.com/repos/jreback/pandas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jreback/pandas/labels{/name}","releases_url":"https://api.github.com/repos/jreback/pandas/releases{/id}","created_at":"2011-08-02T12:17:07Z","updated_at":"2015-11-07T20:22:56Z","pushed_at":"2015-12-15T11:29:56Z","git_url":"git://github.com/jreback/pandas.git","ssh_url":"git@github.com:jreback/pandas.git","clone_url":"https://github.com/jreback/pandas.git","svn_url":"https://github.com/jreback/pandas","homepage":"http://pandas.sourceforge.net","size":71556,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":1,"forks":5,"open_issues":1,"watchers":5,"default_branch":"master"}},"base":{"label":"pydata:master","ref":"master","sha":"d0ac06af0361d0ebfcb3865b019878a20668b469","user":{"login":"pydata","id":1284191,"avatar_url":"https://avatars.githubusercontent.com/u/1284191?v=3","gravatar_id":"","url":"https://api.github.com/users/pydata","html_url":"https://github.com/pydata","followers_url":"https://api.github.com/users/pydata/followers","following_url":"https://api.github.com/users/pydata/following{/other_user}","gists_url":"https://api.github.com/users/pydata/gists{/gist_id}","starred_url":"https://api.github.com/users/pydata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pydata/subscriptions","organizations_url":"https://api.github.com/users/pydata/orgs","repos_url":"https://api.github.com/users/pydata/repos","events_url":"https://api.github.com/users/pydata/events{/privacy}","received_events_url":"https://api.github.com/users/pydata/received_events","type":"Organization","site_admin":false},"repo":{"id":858127,"name":"pandas","full_name":"pydata/pandas","owner":{"login":"pydata","id":1284191,"avatar_url":"https://avatars.githubusercontent.com/u/1284191?v=3","gravatar_id":"","url":"https://api.github.com/users/pydata","html_url":"https://github.com/pydata","followers_url":"https://api.github.com/users/pydata/followers","following_url":"https://api.github.com/users/pydata/following{/other_user}","gists_url":"https://api.github.com/users/pydata/gists{/gist_id}","starred_url":"https://api.github.com/users/pydata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pydata/subscriptions","organizations_url":"https://api.github.com/users/pydata/orgs","repos_url":"https://api.github.com/users/pydata/repos","events_url":"https://api.github.com/users/pydata/events{/privacy}","received_events_url":"https://api.github.com/users/pydata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pydata/pandas","description":"Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more","fork":false,"url":"https://api.github.com/repos/pydata/pandas","forks_url":"https://api.github.com/repos/pydata/pandas/forks","keys_url":"https://api.github.com/repos/pydata/pandas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pydata/pandas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pydata/pandas/teams","hooks_url":"https://api.github.com/repos/pydata/pandas/hooks","issue_events_url":"https://api.github.com/repos/pydata/pandas/issues/events{/number}","events_url":"https://api.github.com/repos/pydata/pandas/events","assignees_url":"https://api.github.com/repos/pydata/pandas/assignees{/user}","branches_url":"https://api.github.com/repos/pydata/pandas/branches{/branch}","tags_url":"https://api.github.com/repos/pydata/pandas/tags","blobs_url":"https://api.github.com/repos/pydata/pandas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pydata/pandas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pydata/pandas/git/refs{/sha}","trees_url":"https://api.github.com/repos/pydata/pandas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pydata/pandas/statuses/{sha}","languages_url":"https://api.github.com/repos/pydata/pandas/languages","stargazers_url":"https://api.github.com/repos/pydata/pandas/stargazers","contributors_url":"https://api.github.com/repos/pydata/pandas/contributors","subscribers_url":"https://api.github.com/repos/pydata/pandas/subscribers","subscription_url":"https://api.github.com/repos/pydata/pandas/subscription","commits_url":"https://api.github.com/repos/pydata/pandas/commits{/sha}","git_commits_url":"https://api.github.com/repos/pydata/pandas/git/commits{/sha}","comments_url":"https://api.github.com/repos/pydata/pandas/comments{/number}","issue_comment_url":"https://api.github.com/repos/pydata/pandas/issues/comments{/number}","contents_url":"https://api.github.com/repos/pydata/pandas/contents/{+path}","compare_url":"https://api.github.com/repos/pydata/pandas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pydata/pandas/merges","archive_url":"https://api.github.com/repos/pydata/pandas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pydata/pandas/downloads","issues_url":"https://api.github.com/repos/pydata/pandas/issues{/number}","pulls_url":"https://api.github.com/repos/pydata/pandas/pulls{/number}","milestones_url":"https://api.github.com/repos/pydata/pandas/milestones{/number}","notifications_url":"https://api.github.com/repos/pydata/pandas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pydata/pandas/labels{/name}","releases_url":"https://api.github.com/repos/pydata/pandas/releases{/id}","created_at":"2010-08-24T01:37:33Z","updated_at":"2015-12-15T12:21:53Z","pushed_at":"2015-12-15T12:58:44Z","git_url":"git://github.com/pydata/pandas.git","ssh_url":"git@github.com:pydata/pandas.git","clone_url":"https://github.com/pydata/pandas.git","svn_url":"https://github.com/pydata/pandas","homepage":"http://pandas.pydata.org","size":129325,"stargazers_count":5441,"watchers_count":5441,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2148,"mirror_url":null,"open_issues_count":1551,"forks":2148,"open_issues":1551,"watchers":5441,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pydata/pandas/pulls/11603"},"html":{"href":"https://github.com/pydata/pandas/pull/11603"},"issue":{"href":"https://api.github.com/repos/pydata/pandas/issues/11603"},"comments":{"href":"https://api.github.com/repos/pydata/pandas/issues/11603/comments"},"review_comments":{"href":"https://api.github.com/repos/pydata/pandas/pulls/11603/comments"},"review_comment":{"href":"https://api.github.com/repos/pydata/pandas/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pydata/pandas/pulls/11603/commits"},"statuses":{"href":"https://api.github.com/repos/pydata/pandas/statuses/25584402f79536a962f1b989646b3229bad9815b"}}}}