{"action":"created","comment":{"url":"https://api.github.com/repos/blaze/dask/pulls/comments/38878849","id":38878849,"diff_hunk":"@@ -562,6 +563,41 @@ def std(self, axis=None, ddof=1):\n             name = '{0}std(ddof={1})'.format(self._token_prefix, ddof)\n             return map_partitions(np.sqrt, no_default, v, token=name)\n \n+    def quantile(self, q=0.5, axis=0):\n+        \"\"\" Approximate row-wise and precise column-wise quantiles of DataFrame\n+\n+        q : list/array of floats, default 0.5 (50%)\n+            Iterable of numbers ranging from 0 to 1 for the desired quantiles\n+        axis : {0, 1, 'index', 'columns'} (default 0)\n+            0 or 'index' for row-wise, 1 or 'columns' for column-wis\n+        \"\"\"\n+        axis = self._validate_axis(axis)\n+        name = 'quantiles-concat--' + tokenize(self, q, axis)\n+\n+        if axis == 1:\n+            if isinstance(q, list):\n+                # Not supported, the result will have current index as columns\n+                raise ValueError(\"'q' must be scalar when axis=1 is specified\")\n+            return map_partitions(pd.DataFrame.quantile, None, self,\n+                                  q, axis, token=name)\n+        else:\n+            num = self._get_numeric_data()\n+            quantiles = tuple(quantile(self[c], q) for c in num.columns)\n+\n+            dask = {}\n+            dask = merge(dask, *[q.dask for q in quantiles])\n+            qnames = [(q._name, 0) for q in quantiles]\n+\n+            if isinstance(quantiles[0], Scalar):\n+                dask[(name, 0)] = (pd.Series, (list, qnames), num.columns)\n+                divisions = (min(num.columns), max(num.columns))","path":"dask/dataframe/core.py","position":48,"original_position":48,"commit_id":"b4f1b96623ee10f39ad23f933faaf0b12d6788e6","original_commit_id":"b4f1b96623ee10f39ad23f933faaf0b12d6788e6","user":{"login":"mrocklin","id":306380,"avatar_url":"https://avatars.githubusercontent.com/u/306380?v=3","gravatar_id":"","url":"https://api.github.com/users/mrocklin","html_url":"https://github.com/mrocklin","followers_url":"https://api.github.com/users/mrocklin/followers","following_url":"https://api.github.com/users/mrocklin/following{/other_user}","gists_url":"https://api.github.com/users/mrocklin/gists{/gist_id}","starred_url":"https://api.github.com/users/mrocklin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrocklin/subscriptions","organizations_url":"https://api.github.com/users/mrocklin/orgs","repos_url":"https://api.github.com/users/mrocklin/repos","events_url":"https://api.github.com/users/mrocklin/events{/privacy}","received_events_url":"https://api.github.com/users/mrocklin/received_events","type":"User","site_admin":false},"body":"We don't actually know `num.columns`, do we?  We would need to track dtypes through all dataframe operations to know this, wouldn't we?","created_at":"2015-09-07T20:27:33Z","updated_at":"2015-09-07T20:27:33Z","html_url":"https://github.com/blaze/dask/pull/675#discussion_r38878849","pull_request_url":"https://api.github.com/repos/blaze/dask/pulls/675","_links":{"self":{"href":"https://api.github.com/repos/blaze/dask/pulls/comments/38878849"},"html":{"href":"https://github.com/blaze/dask/pull/675#discussion_r38878849"},"pull_request":{"href":"https://api.github.com/repos/blaze/dask/pulls/675"}}},"pull_request":{"url":"https://api.github.com/repos/blaze/dask/pulls/675","id":44359558,"html_url":"https://github.com/blaze/dask/pull/675","diff_url":"https://github.com/blaze/dask/pull/675.diff","patch_url":"https://github.com/blaze/dask/pull/675.patch","issue_url":"https://api.github.com/repos/blaze/dask/issues/675","number":675,"state":"open","locked":false,"title":"Add DataFrame.quantile","user":{"login":"sinhrks","id":1696302,"avatar_url":"https://avatars.githubusercontent.com/u/1696302?v=3","gravatar_id":"","url":"https://api.github.com/users/sinhrks","html_url":"https://github.com/sinhrks","followers_url":"https://api.github.com/users/sinhrks/followers","following_url":"https://api.github.com/users/sinhrks/following{/other_user}","gists_url":"https://api.github.com/users/sinhrks/gists{/gist_id}","starred_url":"https://api.github.com/users/sinhrks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinhrks/subscriptions","organizations_url":"https://api.github.com/users/sinhrks/orgs","repos_url":"https://api.github.com/users/sinhrks/repos","events_url":"https://api.github.com/users/sinhrks/events{/privacy}","received_events_url":"https://api.github.com/users/sinhrks/received_events","type":"User","site_admin":false},"body":"Add ``DataFrame.quantile``, also added default ``q=0.5`` as the same as pandas.\r\n\r\n```\r\nimport numpy as np\r\nimport pandas as pd\r\ndf = pd.DataFrame(np.random.randn(10, 5), columns=list('abcde'))\r\nimport dask.dataframe as dd\r\n\r\nddf = dd.from_pandas(df ,3)\r\nddf.quantile().compute()\r\n# a    0.659425\r\n# b    0.806636\r\n# c    0.488996\r\n# d    0.429355\r\n# e    1.724968\r\n# dtype: float64\r\n\r\nddf.quantile([0.2, 0.5]).compute()\r\n#             a         b         c         d         e\r\n# 0.2 -0.371454 -0.337292 -0.390311 -0.902120  0.042564\r\n# 0.5  0.659425  0.806636  0.488996  0.429355  1.724968\r\n```\r\n\r\n``axis=1`` with multiple q values raises ``ValueError``, because index is transformed to column.\r\n\r\n```\r\n# dask\r\nddf.quantile([0.2, 0.5], axis=1).compute()\r\n# ValueError: 'q' must be scalar when axis=1 is specified\r\n\r\n# pandas (for reference)\r\ndf.quantile([0.2, 0.5], axis=1)\r\n#             0         1         2         3         4         5         6  \\\r\n# 0.2  0.160987  0.298286 -1.162020  0.923334 -0.348533 -1.167978 -0.299672   \r\n# 0.5  0.785835  1.038735  0.159291  1.545565  0.617093 -0.483535 -0.230895   \r\n# \r\n#             7         8         9  \r\n# 0.2 -0.656627 -1.125129 -0.384619  \r\n# 0.5 -0.348572 -0.168746 -0.264975\r\n```","created_at":"2015-09-07T14:17:47Z","updated_at":"2015-09-07T20:27:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aeca385c245c3630f686fb418d2979b6b0e796a7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/blaze/dask/pulls/675/commits","review_comments_url":"https://api.github.com/repos/blaze/dask/pulls/675/comments","review_comment_url":"https://api.github.com/repos/blaze/dask/pulls/comments{/number}","comments_url":"https://api.github.com/repos/blaze/dask/issues/675/comments","statuses_url":"https://api.github.com/repos/blaze/dask/statuses/b4f1b96623ee10f39ad23f933faaf0b12d6788e6","head":{"label":"sinhrks:quantiles","ref":"quantiles","sha":"b4f1b96623ee10f39ad23f933faaf0b12d6788e6","user":{"login":"sinhrks","id":1696302,"avatar_url":"https://avatars.githubusercontent.com/u/1696302?v=3","gravatar_id":"","url":"https://api.github.com/users/sinhrks","html_url":"https://github.com/sinhrks","followers_url":"https://api.github.com/users/sinhrks/followers","following_url":"https://api.github.com/users/sinhrks/following{/other_user}","gists_url":"https://api.github.com/users/sinhrks/gists{/gist_id}","starred_url":"https://api.github.com/users/sinhrks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinhrks/subscriptions","organizations_url":"https://api.github.com/users/sinhrks/orgs","repos_url":"https://api.github.com/users/sinhrks/repos","events_url":"https://api.github.com/users/sinhrks/events{/privacy}","received_events_url":"https://api.github.com/users/sinhrks/received_events","type":"User","site_admin":false},"repo":{"id":38960014,"name":"dask","full_name":"sinhrks/dask","owner":{"login":"sinhrks","id":1696302,"avatar_url":"https://avatars.githubusercontent.com/u/1696302?v=3","gravatar_id":"","url":"https://api.github.com/users/sinhrks","html_url":"https://github.com/sinhrks","followers_url":"https://api.github.com/users/sinhrks/followers","following_url":"https://api.github.com/users/sinhrks/following{/other_user}","gists_url":"https://api.github.com/users/sinhrks/gists{/gist_id}","starred_url":"https://api.github.com/users/sinhrks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinhrks/subscriptions","organizations_url":"https://api.github.com/users/sinhrks/orgs","repos_url":"https://api.github.com/users/sinhrks/repos","events_url":"https://api.github.com/users/sinhrks/events{/privacy}","received_events_url":"https://api.github.com/users/sinhrks/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sinhrks/dask","description":"Task scheduling and blocked algorithms for parallel processing","fork":true,"url":"https://api.github.com/repos/sinhrks/dask","forks_url":"https://api.github.com/repos/sinhrks/dask/forks","keys_url":"https://api.github.com/repos/sinhrks/dask/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sinhrks/dask/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sinhrks/dask/teams","hooks_url":"https://api.github.com/repos/sinhrks/dask/hooks","issue_events_url":"https://api.github.com/repos/sinhrks/dask/issues/events{/number}","events_url":"https://api.github.com/repos/sinhrks/dask/events","assignees_url":"https://api.github.com/repos/sinhrks/dask/assignees{/user}","branches_url":"https://api.github.com/repos/sinhrks/dask/branches{/branch}","tags_url":"https://api.github.com/repos/sinhrks/dask/tags","blobs_url":"https://api.github.com/repos/sinhrks/dask/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sinhrks/dask/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sinhrks/dask/git/refs{/sha}","trees_url":"https://api.github.com/repos/sinhrks/dask/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sinhrks/dask/statuses/{sha}","languages_url":"https://api.github.com/repos/sinhrks/dask/languages","stargazers_url":"https://api.github.com/repos/sinhrks/dask/stargazers","contributors_url":"https://api.github.com/repos/sinhrks/dask/contributors","subscribers_url":"https://api.github.com/repos/sinhrks/dask/subscribers","subscription_url":"https://api.github.com/repos/sinhrks/dask/subscription","commits_url":"https://api.github.com/repos/sinhrks/dask/commits{/sha}","git_commits_url":"https://api.github.com/repos/sinhrks/dask/git/commits{/sha}","comments_url":"https://api.github.com/repos/sinhrks/dask/comments{/number}","issue_comment_url":"https://api.github.com/repos/sinhrks/dask/issues/comments{/number}","contents_url":"https://api.github.com/repos/sinhrks/dask/contents/{+path}","compare_url":"https://api.github.com/repos/sinhrks/dask/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sinhrks/dask/merges","archive_url":"https://api.github.com/repos/sinhrks/dask/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sinhrks/dask/downloads","issues_url":"https://api.github.com/repos/sinhrks/dask/issues{/number}","pulls_url":"https://api.github.com/repos/sinhrks/dask/pulls{/number}","milestones_url":"https://api.github.com/repos/sinhrks/dask/milestones{/number}","notifications_url":"https://api.github.com/repos/sinhrks/dask/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sinhrks/dask/labels{/name}","releases_url":"https://api.github.com/repos/sinhrks/dask/releases{/id}","created_at":"2015-07-12T11:42:08Z","updated_at":"2015-07-12T11:42:08Z","pushed_at":"2015-09-07T14:19:00Z","git_url":"git://github.com/sinhrks/dask.git","ssh_url":"git@github.com:sinhrks/dask.git","clone_url":"https://github.com/sinhrks/dask.git","svn_url":"https://github.com/sinhrks/dask","homepage":"http://dask.pydata.org","size":8359,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"blaze:master","ref":"master","sha":"b3dce54e1d15a4a4eec246f9bd6c0980f6318440","user":{"login":"blaze","id":12833921,"avatar_url":"https://avatars.githubusercontent.com/u/12833921?v=3","gravatar_id":"","url":"https://api.github.com/users/blaze","html_url":"https://github.com/blaze","followers_url":"https://api.github.com/users/blaze/followers","following_url":"https://api.github.com/users/blaze/following{/other_user}","gists_url":"https://api.github.com/users/blaze/gists{/gist_id}","starred_url":"https://api.github.com/users/blaze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blaze/subscriptions","organizations_url":"https://api.github.com/users/blaze/orgs","repos_url":"https://api.github.com/users/blaze/repos","events_url":"https://api.github.com/users/blaze/events{/privacy}","received_events_url":"https://api.github.com/users/blaze/received_events","type":"Organization","site_admin":false},"repo":{"id":28782747,"name":"dask","full_name":"blaze/dask","owner":{"login":"blaze","id":12833921,"avatar_url":"https://avatars.githubusercontent.com/u/12833921?v=3","gravatar_id":"","url":"https://api.github.com/users/blaze","html_url":"https://github.com/blaze","followers_url":"https://api.github.com/users/blaze/followers","following_url":"https://api.github.com/users/blaze/following{/other_user}","gists_url":"https://api.github.com/users/blaze/gists{/gist_id}","starred_url":"https://api.github.com/users/blaze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blaze/subscriptions","organizations_url":"https://api.github.com/users/blaze/orgs","repos_url":"https://api.github.com/users/blaze/repos","events_url":"https://api.github.com/users/blaze/events{/privacy}","received_events_url":"https://api.github.com/users/blaze/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/blaze/dask","description":"Task scheduling and blocked algorithms for parallel processing","fork":false,"url":"https://api.github.com/repos/blaze/dask","forks_url":"https://api.github.com/repos/blaze/dask/forks","keys_url":"https://api.github.com/repos/blaze/dask/keys{/key_id}","collaborators_url":"https://api.github.com/repos/blaze/dask/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/blaze/dask/teams","hooks_url":"https://api.github.com/repos/blaze/dask/hooks","issue_events_url":"https://api.github.com/repos/blaze/dask/issues/events{/number}","events_url":"https://api.github.com/repos/blaze/dask/events","assignees_url":"https://api.github.com/repos/blaze/dask/assignees{/user}","branches_url":"https://api.github.com/repos/blaze/dask/branches{/branch}","tags_url":"https://api.github.com/repos/blaze/dask/tags","blobs_url":"https://api.github.com/repos/blaze/dask/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/blaze/dask/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/blaze/dask/git/refs{/sha}","trees_url":"https://api.github.com/repos/blaze/dask/git/trees{/sha}","statuses_url":"https://api.github.com/repos/blaze/dask/statuses/{sha}","languages_url":"https://api.github.com/repos/blaze/dask/languages","stargazers_url":"https://api.github.com/repos/blaze/dask/stargazers","contributors_url":"https://api.github.com/repos/blaze/dask/contributors","subscribers_url":"https://api.github.com/repos/blaze/dask/subscribers","subscription_url":"https://api.github.com/repos/blaze/dask/subscription","commits_url":"https://api.github.com/repos/blaze/dask/commits{/sha}","git_commits_url":"https://api.github.com/repos/blaze/dask/git/commits{/sha}","comments_url":"https://api.github.com/repos/blaze/dask/comments{/number}","issue_comment_url":"https://api.github.com/repos/blaze/dask/issues/comments{/number}","contents_url":"https://api.github.com/repos/blaze/dask/contents/{+path}","compare_url":"https://api.github.com/repos/blaze/dask/compare/{base}...{head}","merges_url":"https://api.github.com/repos/blaze/dask/merges","archive_url":"https://api.github.com/repos/blaze/dask/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/blaze/dask/downloads","issues_url":"https://api.github.com/repos/blaze/dask/issues{/number}","pulls_url":"https://api.github.com/repos/blaze/dask/pulls{/number}","milestones_url":"https://api.github.com/repos/blaze/dask/milestones{/number}","notifications_url":"https://api.github.com/repos/blaze/dask/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/blaze/dask/labels{/name}","releases_url":"https://api.github.com/repos/blaze/dask/releases{/id}","created_at":"2015-01-04T18:50:00Z","updated_at":"2015-09-03T11:31:16Z","pushed_at":"2015-09-07T19:30:01Z","git_url":"git://github.com/blaze/dask.git","ssh_url":"git@github.com:blaze/dask.git","clone_url":"https://github.com/blaze/dask.git","svn_url":"https://github.com/blaze/dask","homepage":"http://dask.pydata.org","size":12767,"stargazers_count":313,"watchers_count":313,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":56,"mirror_url":null,"open_issues_count":81,"forks":56,"open_issues":81,"watchers":313,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/blaze/dask/pulls/675"},"html":{"href":"https://github.com/blaze/dask/pull/675"},"issue":{"href":"https://api.github.com/repos/blaze/dask/issues/675"},"comments":{"href":"https://api.github.com/repos/blaze/dask/issues/675/comments"},"review_comments":{"href":"https://api.github.com/repos/blaze/dask/pulls/675/comments"},"review_comment":{"href":"https://api.github.com/repos/blaze/dask/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/blaze/dask/pulls/675/commits"},"statuses":{"href":"https://api.github.com/repos/blaze/dask/statuses/b4f1b96623ee10f39ad23f933faaf0b12d6788e6"}}}}