[
https://issues.apache.org/jira/browse/ARROW-1751?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16224264#comment-16224264
]
ASF GitHub Bot commented on ARROW-1751:
---------------------------------------
wesm closed pull request #1268: ARROW-1751: [Python] Pandas 0.21.0 introduces a
breaking API change for MultiIndex construction
URL: https://github.com/apache/arrow/pull/1268
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/python/pyarrow/pandas_compat.py b/python/pyarrow/pandas_compat.py
index 5592d8dd9..d6c844c84 100644
--- a/python/pyarrow/pandas_compat.py
+++ b/python/pyarrow/pandas_compat.py
@@ -493,6 +493,16 @@ def table_to_blockmanager(options, table, memory_pool,
nthreads=1):
labels=labels,
names=columns.names
)
+
+ # flatten a single level column MultiIndex for pandas 0.21.0 :(
+ if isinstance(columns, pd.MultiIndex) and columns.nlevels == 1:
+ levels, = columns.levels
+ labels, = columns.labels
+
+ # Cheaply check that we do not somehow have duplicate column names
+ assert len(levels) == len(labels), 'Found non-unique column index'
+ columns = levels[labels]
+
axes = [columns, index]
return _int.BlockManager(blocks, axes)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> [Python] Pandas 0.21.0 introduces a breaking API change for MultiIndex
> construction
> -----------------------------------------------------------------------------------
>
> Key: ARROW-1751
> URL: https://issues.apache.org/jira/browse/ARROW-1751
> Project: Apache Arrow
> Issue Type: Bug
> Components: Python
> Affects Versions: 0.7.1
> Reporter: Phillip Cloud
> Assignee: Phillip Cloud
> Labels: pull-request-available
> Fix For: 0.8.0
>
>
> Pandas 0.21.0:
> {code}
> In [10]: pd.__version__
> Out[10]: '0.21.0'
> In [11]: pd.MultiIndex.from_tuples([('a',), ('b',)])
> Out[11]:
> MultiIndex(levels=[['a', 'b']],
> labels=[[0, 1]])
> {code}
> Pandas 0.20.3
> {code}
> In [2]: pd.__version__
> Out[2]: '0.20.3'
> In [3]: pd.MultiIndex.from_tuples([('a',), ('b',)])
> Out[3]: Index(['a', 'b'], dtype='object')
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)