{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/11603","labels_url":"https://api.github.com/repos/pydata/pandas/issues/11603/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/11603/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/11603/events","html_url":"https://github.com/pydata/pandas/pull/11603","id":116942772,"number":11603,"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},"labels":[{"url":"https://api.github.com/repos/pydata/pandas/labels/API%20Design","name":"API Design","color":"AD7FA8"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Reshaping","name":"Reshaping","color":"02d7e1"}],"state":"open","locked":false,"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":37,"closed_issues":15,"state":"open","created_at":"2015-07-19T20:18:45Z","updated_at":"2015-11-30T11:47:27Z","due_on":"2016-01-31T05:00:00Z","closed_at":null},"comments":11,"created_at":"2015-11-14T18:12:18Z","updated_at":"2015-12-01T11:42:47Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pydata/pandas/pulls/11603","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"},"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```"},"comment":{"url":"https://api.github.com/repos/pydata/pandas/issues/comments/160943433","html_url":"https://github.com/pydata/pandas/pull/11603#issuecomment-160943433","issue_url":"https://api.github.com/repos/pydata/pandas/issues/11603","id":160943433,"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},"created_at":"2015-12-01T11:42:47Z","updated_at":"2015-12-01T11:42:47Z","body":"@shoyer @jorisvandenbossche ok, deprecated ``freq``, ``how``.\r\n\r\nOn another note, might this be a good time to fix ``.resample``, so\r\n\r\n``s.resample('D',how='max')`` -> ``s.resample('D').max()``.\r\n\r\nNote that this WOULD be a breaking change, meaning the ``s.resample('D')`` would raise an exception rather than 'just work', because the ``how`` arg is defaulted to ``'mean'``. So it wouldn't go unnoticed.\r\n\r\nthoughts?"}}