{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/12541","repository_url":"https://api.github.com/repos/pydata/pandas","labels_url":"https://api.github.com/repos/pydata/pandas/issues/12541/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/12541/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/12541/events","html_url":"https://github.com/pydata/pandas/issues/12541","id":138804699,"number":12541,"title":"BUG: window function count should count anything non-null","user":{"login":"kawochen","id":10709573,"avatar_url":"https://avatars.githubusercontent.com/u/10709573?v=3","gravatar_id":"","url":"https://api.github.com/users/kawochen","html_url":"https://github.com/kawochen","followers_url":"https://api.github.com/users/kawochen/followers","following_url":"https://api.github.com/users/kawochen/following{/other_user}","gists_url":"https://api.github.com/users/kawochen/gists{/gist_id}","starred_url":"https://api.github.com/users/kawochen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kawochen/subscriptions","organizations_url":"https://api.github.com/users/kawochen/orgs","repos_url":"https://api.github.com/users/kawochen/repos","events_url":"https://api.github.com/users/kawochen/events{/privacy}","received_events_url":"https://api.github.com/users/kawochen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pydata/pandas/labels/Algos","name":"Algos","color":"eb6420"},{"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%20Low","name":"Effort Low","color":"006b75"},{"url":"https://api.github.com/repos/pydata/pandas/labels/Missing-data","name":"Missing-data","color":"d7e102"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/pydata/pandas/milestones/38","html_url":"https://github.com/pydata/pandas/milestones/0.18.1","labels_url":"https://api.github.com/repos/pydata/pandas/milestones/38/labels","id":1570594,"number":38,"title":"0.18.1","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":103,"closed_issues":5,"state":"open","created_at":"2016-02-08T15:29:59Z","updated_at":"2016-03-07T18:42:44Z","due_on":"2016-04-12T04:00:00Z","closed_at":null},"comments":6,"created_at":"2016-03-06T15:56:09Z","updated_at":"2016-03-07T23:27:50Z","closed_at":null,"body":" Right now `np.Inf` and non-numeric types are not counted.\r\n#### Code Sample, a copy-pastable example if possible\r\n```\r\nimport pandas as pd\r\nimport numpy as np\r\nfrom pandas import DataFrame\r\n\r\ndf = DataFrame({'A': pd.date_range('20130101',periods=4), 'B': [0, 1, 2, np.Inf], 'C':['a', 'b', 'c', 'd']})\r\n\r\nroll = df.rolling(window=2)\r\nres = roll.count()\r\nprint(res)\r\n## partial output A, B don't error\r\n     A    B\r\n0  1.0  1.0\r\n1  2.0  2.0\r\n2  2.0  2.0\r\n3  2.0  1.0\r\n## column C errors\r\n```\r\n#### Expected Output\r\n```\r\n   A  B  C\r\n0  1  1  1\r\n1  2  2  2\r\n2  2  2  2\r\n3  2  2  2\r\n```\r\n#### output of ``pd.show_versions()``\r\n```\r\nINSTALLED VERSIONS\r\n------------------\r\ncommit: a0aaad98e8c567a3a04aef165cdb159fbd98d13f\r\npython: 3.5.1.final.0\r\npython-bits: 64\r\nOS: Linux\r\nOS-release: 3.13.0-76-generic\r\nmachine: x86_64\r\nprocessor: x86_64\r\nbyteorder: little\r\nLC_ALL: None\r\nLANG: en_US.UTF-8\r\n\r\npandas: 0.18.0rc1+77.ga0aaad9.dirty\r\nnose: 1.3.7\r\npip: 8.0.1\r\nsetuptools: 19.4\r\nCython: 0.23.4\r\nnumpy: 1.10.2\r\nscipy: None\r\nstatsmodels: None\r\nxarray: None\r\nIPython: 4.0.0\r\nsphinx: None\r\npatsy: None\r\ndateutil: 2.4.2\r\npytz: 2015.7\r\nblosc: None\r\nbottleneck: 1.0.0\r\ntables: None\r\nnumexpr: None\r\nmatplotlib: None\r\nopenpyxl: None\r\nxlrd: None\r\nxlwt: None\r\nxlsxwriter: None\r\nlxml: None\r\nbs4: None\r\nhtml5lib: None\r\nhttplib2: None\r\napiclient: None\r\nsqlalchemy: 1.0.10\r\npymysql: None\r\npsycopg2: None\r\njinja2: None\r\nboto: None\r\n```\r\nI think it can be patched, together with #12538, by\r\n```\r\n--- a/pandas/core/window.py\r\n+++ b/pandas/core/window.py\r\n@@ -509,19 +509,9 @@ class _Rolling_and_Expanding(_Rolling):\r\n         blocks, obj = self._create_blocks(how=None)\r\n         results = []\r\n         for b in blocks:\r\n-\r\n-            if com.needs_i8_conversion(b.values):\r\n-                result = b.notnull().astype(int)\r\n-            else:\r\n-                try:\r\n-                    result = np.isfinite(b).astype(float)\r\n-                except TypeError:\r\n-                    result = np.isfinite(b.astype(float)).astype(float)\r\n-\r\n-                result[pd.isnull(result)] = 0\r\n-\r\n-            result = self._constructor(result, window=window, min_perio\r\n-                                       center=self.center).sum()\r\n+            result = self._constructor(\r\n+                b.notnull(), window=window, min_periods=0, center=self.\r\n+            ).sum().astype(int)\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/pydata/pandas/issues/comments/193503880","html_url":"https://github.com/pydata/pandas/issues/12541#issuecomment-193503880","issue_url":"https://api.github.com/repos/pydata/pandas/issues/12541","id":193503880,"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":"2016-03-07T23:27:50Z","updated_at":"2016-03-07T23:27:50Z","body":"So for consistency make this return ints.\r\n\r\nWe can always revisit the ``counting things -> uints`` later"}}