[ 
https://issues.apache.org/jira/browse/ARROW-18297?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Joris Van den Bossche updated ARROW-18297:
------------------------------------------
    Summary: [Python] from/to pandas with MultiIndex raises incorrectly  (was: 
from/to pandas with MultiIndex raises incorrectly)

> [Python] from/to pandas with MultiIndex raises incorrectly
> ----------------------------------------------------------
>
>                 Key: ARROW-18297
>                 URL: https://issues.apache.org/jira/browse/ARROW-18297
>             Project: Apache Arrow
>          Issue Type: Bug
>            Reporter: Shoham Debnath
>            Priority: Major
>
> The error only throws, when one Index is RangeIndex and the other isn't
> {code:java}
> df = pd.DataFrame({"a":[1,2], "b":[3,4]})
> df = df.set_index(["a"], append=True)
> pa.Table.from_pandas(df).to_pandas()
> Traceback (most recent call last):
>   File 
> "/Users/debnathshoham/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/IPython/core/interactiveshell.py",
>  line 3378, in run_code
>     exec(code_obj, self.user_global_ns, self.user_ns)
>   File "<ipython-input-121-bf4b7b5f6b6e>", line 1, in <module>
>     pa.Table.from_pandas(df).to_pandas()
>   File "pyarrow/array.pxi", line 823, in 
> pyarrow.lib._PandasConvertible.to_pandas
>   File "pyarrow/table.pxi", line 3913, in pyarrow.lib.Table._to_pandas
>   File 
> "/Users/debnathshoham/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/pyarrow/pandas_compat.py",
>  line 808, in table_to_blockmanager
>     table, index = _reconstruct_index(table, index_descriptors,
>   File 
> "/Users/debnathshoham/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/pyarrow/pandas_compat.py",
>  line 959, in _reconstruct_index
>     result_table, index_level, index_name = _extract_index_level(
>   File 
> "/Users/debnathshoham/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/pyarrow/pandas_compat.py",
>  line 997, in _extract_index_level
>     logical_name = field_name_to_metadata[field_name]['name']
> KeyError: 'a' {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to