{"action":"created","comment":{"url":"https://api.github.com/repos/apache/arrow/pulls/comments/114058594","pull_request_review_id":35501401,"id":114058594,"diff_hunk":"@@ -540,15 +559,56 @@ cdef class RecordBatch:\n cdef table_to_blockmanager(const shared_ptr[CTable]& table, int nthreads):\n     cdef:\n         PyObject* result_obj\n-        CColumn* col\n-        int i\n+        Column col\n+        CTable* ctable = table.get()\n+        size_t row_count = ctable.num_rows()\n+        CSchema* schema = ctable.schema().get()\n+        shared_ptr[CTable] block_table = table\n+        list index_arrays = []\n+        size_t i\n+        size_t total_columns = ctable.num_columns()\n+        list names = [\n+            frombytes(ctable.column(i).get().name())\n+            for i in range(total_columns)\n+        ]\n+        dict metadata = box_metadata(schema.metadata().get()) or {}\n+        tuple indices = ()\n+        tuple indices_have_name = ()\n+        size_t number_of_index_levels\n+        size_t index_start\n+\n+    if b'indices' in metadata:\n+        indices = tuple(metadata[b'indices'])\n+        indices_have_name = tuple(metadata[b'has_name'])\n+        assert len(indices) == len(indices_have_name)\n+\n+    number_of_index_levels = len(indices)\n+    index_start = total_columns - number_of_index_levels\n+\n+    for i, has_name in zip(indices, indices_have_name):\n+        col = Column()\n+        col.init(ctable.column(i))\n+        idx = _pandas().Index(\n+            col.to_pandas().values,\n+            name=names[i] if has_name else None\n+        )\n+        index_arrays.append(idx)\n+        ctable.RemoveColumn(i, &block_table)\n+        del names[i]\n+\n+    cdef list axes = [\n+        names[:index_start],\n+        _pandas().MultiIndex.from_arrays(\n+            index_arrays\n+        ) if index_arrays else _pandas().RangeIndex(row_count),\n+    ]","path":"python/pyarrow/_table.pyx","position":93,"original_position":93,"commit_id":"2099d1fc5914ee9408f8d5e9d61e661ea200f504","original_commit_id":"2099d1fc5914ee9408f8d5e9d61e661ea200f504","user":{"login":"wesm","id":329591,"avatar_url":"https://avatars1.githubusercontent.com/u/329591?v=3","gravatar_id":"","url":"https://api.github.com/users/wesm","html_url":"https://github.com/wesm","followers_url":"https://api.github.com/users/wesm/followers","following_url":"https://api.github.com/users/wesm/following{/other_user}","gists_url":"https://api.github.com/users/wesm/gists{/gist_id}","starred_url":"https://api.github.com/users/wesm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wesm/subscriptions","organizations_url":"https://api.github.com/users/wesm/orgs","repos_url":"https://api.github.com/users/wesm/repos","events_url":"https://api.github.com/users/wesm/events{/privacy}","received_events_url":"https://api.github.com/users/wesm/received_events","type":"User","site_admin":false},"body":"Same comment as above re: doing this in pure Python. It would also encourage adding appropriate public APIs to `pyarrow.Table`. We already have `Table.remove_column`, so it is probably better to use that if possible. ","created_at":"2017-04-29T18:04:25Z","updated_at":"2017-04-29T18:08:48Z","html_url":"https://github.com/apache/arrow/pull/612#discussion_r114058594","pull_request_url":"https://api.github.com/repos/apache/arrow/pulls/612","_links":{"self":{"href":"https://api.github.com/repos/apache/arrow/pulls/comments/114058594"},"html":{"href":"https://github.com/apache/arrow/pull/612#discussion_r114058594"},"pull_request":{"href":"https://api.github.com/repos/apache/arrow/pulls/612"}}},"pull_request":{"url":"https://api.github.com/repos/apache/arrow/pulls/612","id":118254682,"html_url":"https://github.com/apache/arrow/pull/612","diff_url":"https://github.com/apache/arrow/pull/612.diff","patch_url":"https://github.com/apache/arrow/pull/612.patch","issue_url":"https://api.github.com/repos/apache/arrow/issues/612","number":612,"state":"open","locked":false,"title":"ARROW-881: [Python] Reconstruct Pandas DataFrame indexes using metadata","user":{"login":"cpcloud","id":417981,"avatar_url":"https://avatars2.githubusercontent.com/u/417981?v=3","gravatar_id":"","url":"https://api.github.com/users/cpcloud","html_url":"https://github.com/cpcloud","followers_url":"https://api.github.com/users/cpcloud/followers","following_url":"https://api.github.com/users/cpcloud/following{/other_user}","gists_url":"https://api.github.com/users/cpcloud/gists{/gist_id}","starred_url":"https://api.github.com/users/cpcloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpcloud/subscriptions","organizations_url":"https://api.github.com/users/cpcloud/orgs","repos_url":"https://api.github.com/users/cpcloud/repos","events_url":"https://api.github.com/users/cpcloud/events{/privacy}","received_events_url":"https://api.github.com/users/cpcloud/received_events","type":"User","site_admin":false},"body":"This depends on [PARQUET-595](https://github.com/apache/parquet-cpp/pull/314) which hasn't been merged yet.\r\n\r\n\r\ncc @mrocklin","created_at":"2017-04-29T00:21:09Z","updated_at":"2017-04-29T18:08:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"41140e031d76c36ede0b4ae3ec43fc66e4819fca","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/arrow/pulls/612/commits","review_comments_url":"https://api.github.com/repos/apache/arrow/pulls/612/comments","review_comment_url":"https://api.github.com/repos/apache/arrow/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/arrow/issues/612/comments","statuses_url":"https://api.github.com/repos/apache/arrow/statuses/2099d1fc5914ee9408f8d5e9d61e661ea200f504","head":{"label":"cpcloud:ARROW-881","ref":"ARROW-881","sha":"2099d1fc5914ee9408f8d5e9d61e661ea200f504","user":{"login":"cpcloud","id":417981,"avatar_url":"https://avatars2.githubusercontent.com/u/417981?v=3","gravatar_id":"","url":"https://api.github.com/users/cpcloud","html_url":"https://github.com/cpcloud","followers_url":"https://api.github.com/users/cpcloud/followers","following_url":"https://api.github.com/users/cpcloud/following{/other_user}","gists_url":"https://api.github.com/users/cpcloud/gists{/gist_id}","starred_url":"https://api.github.com/users/cpcloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpcloud/subscriptions","organizations_url":"https://api.github.com/users/cpcloud/orgs","repos_url":"https://api.github.com/users/cpcloud/repos","events_url":"https://api.github.com/users/cpcloud/events{/privacy}","received_events_url":"https://api.github.com/users/cpcloud/received_events","type":"User","site_admin":false},"repo":{"id":83908626,"name":"arrow","full_name":"cpcloud/arrow","owner":{"login":"cpcloud","id":417981,"avatar_url":"https://avatars2.githubusercontent.com/u/417981?v=3","gravatar_id":"","url":"https://api.github.com/users/cpcloud","html_url":"https://github.com/cpcloud","followers_url":"https://api.github.com/users/cpcloud/followers","following_url":"https://api.github.com/users/cpcloud/following{/other_user}","gists_url":"https://api.github.com/users/cpcloud/gists{/gist_id}","starred_url":"https://api.github.com/users/cpcloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpcloud/subscriptions","organizations_url":"https://api.github.com/users/cpcloud/orgs","repos_url":"https://api.github.com/users/cpcloud/repos","events_url":"https://api.github.com/users/cpcloud/events{/privacy}","received_events_url":"https://api.github.com/users/cpcloud/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cpcloud/arrow","description":"Apache Arrow is a columnar in-memory analytics layer designed to accelerate big data. It houses a set of canonical in-memory representations of flat and hierarchical data along with multiple language-bindings for structure manipulation. It also provides IPC and common algorithm implementations. ","fork":true,"url":"https://api.github.com/repos/cpcloud/arrow","forks_url":"https://api.github.com/repos/cpcloud/arrow/forks","keys_url":"https://api.github.com/repos/cpcloud/arrow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cpcloud/arrow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cpcloud/arrow/teams","hooks_url":"https://api.github.com/repos/cpcloud/arrow/hooks","issue_events_url":"https://api.github.com/repos/cpcloud/arrow/issues/events{/number}","events_url":"https://api.github.com/repos/cpcloud/arrow/events","assignees_url":"https://api.github.com/repos/cpcloud/arrow/assignees{/user}","branches_url":"https://api.github.com/repos/cpcloud/arrow/branches{/branch}","tags_url":"https://api.github.com/repos/cpcloud/arrow/tags","blobs_url":"https://api.github.com/repos/cpcloud/arrow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cpcloud/arrow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cpcloud/arrow/git/refs{/sha}","trees_url":"https://api.github.com/repos/cpcloud/arrow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cpcloud/arrow/statuses/{sha}","languages_url":"https://api.github.com/repos/cpcloud/arrow/languages","stargazers_url":"https://api.github.com/repos/cpcloud/arrow/stargazers","contributors_url":"https://api.github.com/repos/cpcloud/arrow/contributors","subscribers_url":"https://api.github.com/repos/cpcloud/arrow/subscribers","subscription_url":"https://api.github.com/repos/cpcloud/arrow/subscription","commits_url":"https://api.github.com/repos/cpcloud/arrow/commits{/sha}","git_commits_url":"https://api.github.com/repos/cpcloud/arrow/git/commits{/sha}","comments_url":"https://api.github.com/repos/cpcloud/arrow/comments{/number}","issue_comment_url":"https://api.github.com/repos/cpcloud/arrow/issues/comments{/number}","contents_url":"https://api.github.com/repos/cpcloud/arrow/contents/{+path}","compare_url":"https://api.github.com/repos/cpcloud/arrow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cpcloud/arrow/merges","archive_url":"https://api.github.com/repos/cpcloud/arrow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cpcloud/arrow/downloads","issues_url":"https://api.github.com/repos/cpcloud/arrow/issues{/number}","pulls_url":"https://api.github.com/repos/cpcloud/arrow/pulls{/number}","milestones_url":"https://api.github.com/repos/cpcloud/arrow/milestones{/number}","notifications_url":"https://api.github.com/repos/cpcloud/arrow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cpcloud/arrow/labels{/name}","releases_url":"https://api.github.com/repos/cpcloud/arrow/releases{/id}","deployments_url":"https://api.github.com/repos/cpcloud/arrow/deployments","created_at":"2017-03-04T16:45:21Z","updated_at":"2017-03-19T21:39:06Z","pushed_at":"2017-04-29T00:20:28Z","git_url":"git://github.com/cpcloud/arrow.git","ssh_url":"git@github.com:cpcloud/arrow.git","clone_url":"https://github.com/cpcloud/arrow.git","svn_url":"https://github.com/cpcloud/arrow","homepage":"https://arrow.apache.org","size":4508,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"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":"apache:master","ref":"master","sha":"f7ab7270bb07466dabf84c015a6db2a192eb3dad","user":{"login":"apache","id":47359,"avatar_url":"https://avatars3.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":51905353,"name":"arrow","full_name":"apache/arrow","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars3.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/arrow","description":"Apache Arrow is a columnar in-memory analytics layer designed to accelerate big data. It houses a set of canonical in-memory representations of flat and hierarchical data along with multiple language-bindings for structure manipulation. It also provides IPC and common algorithm implementations. ","fork":false,"url":"https://api.github.com/repos/apache/arrow","forks_url":"https://api.github.com/repos/apache/arrow/forks","keys_url":"https://api.github.com/repos/apache/arrow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/arrow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/arrow/teams","hooks_url":"https://api.github.com/repos/apache/arrow/hooks","issue_events_url":"https://api.github.com/repos/apache/arrow/issues/events{/number}","events_url":"https://api.github.com/repos/apache/arrow/events","assignees_url":"https://api.github.com/repos/apache/arrow/assignees{/user}","branches_url":"https://api.github.com/repos/apache/arrow/branches{/branch}","tags_url":"https://api.github.com/repos/apache/arrow/tags","blobs_url":"https://api.github.com/repos/apache/arrow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/arrow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/arrow/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/arrow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/arrow/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/arrow/languages","stargazers_url":"https://api.github.com/repos/apache/arrow/stargazers","contributors_url":"https://api.github.com/repos/apache/arrow/contributors","subscribers_url":"https://api.github.com/repos/apache/arrow/subscribers","subscription_url":"https://api.github.com/repos/apache/arrow/subscription","commits_url":"https://api.github.com/repos/apache/arrow/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/arrow/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/arrow/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/arrow/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/arrow/contents/{+path}","compare_url":"https://api.github.com/repos/apache/arrow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/arrow/merges","archive_url":"https://api.github.com/repos/apache/arrow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/arrow/downloads","issues_url":"https://api.github.com/repos/apache/arrow/issues{/number}","pulls_url":"https://api.github.com/repos/apache/arrow/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/arrow/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/arrow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/arrow/labels{/name}","releases_url":"https://api.github.com/repos/apache/arrow/releases{/id}","deployments_url":"https://api.github.com/repos/apache/arrow/deployments","created_at":"2016-02-17T08:00:23Z","updated_at":"2017-04-29T08:14:47Z","pushed_at":"2017-04-29T00:21:09Z","git_url":"git://github.com/apache/arrow.git","ssh_url":"git@github.com:apache/arrow.git","clone_url":"https://github.com/apache/arrow.git","svn_url":"https://github.com/apache/arrow","homepage":"https://arrow.apache.org","size":4491,"stargazers_count":900,"watchers_count":900,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":219,"mirror_url":"git://git.apache.org/arrow.git","open_issues_count":8,"forks":219,"open_issues":8,"watchers":900,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/arrow/pulls/612"},"html":{"href":"https://github.com/apache/arrow/pull/612"},"issue":{"href":"https://api.github.com/repos/apache/arrow/issues/612"},"comments":{"href":"https://api.github.com/repos/apache/arrow/issues/612/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/arrow/pulls/612/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/arrow/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/arrow/pulls/612/commits"},"statuses":{"href":"https://api.github.com/repos/apache/arrow/statuses/2099d1fc5914ee9408f8d5e9d61e661ea200f504"}}}}
{"actor":{"display_login":"wesm"}}