Skip to content

[Python] pa.RecordBatch.from_pandas doesn't accept DataFrame with numeric column names #17262

@asfimport

Description

@asfimport
import pyarrow as pa
import pandas as pd

df = pd.DataFrame([1])
pa.RecordBatch.from_pandas(df)

Exception:

TypeError                                 Traceback (most recent call last)
<ipython-input-5-670ba4a2ddb2> in <module>()
      3 
      4 df = pd.DataFrame([1])
----> 5 pa.RecordBatch.from_pandas(df)

table.pxi in pyarrow.lib.RecordBatch.from_pandas()

table.pxi in pyarrow.lib._dataframe_to_arrays()

/home/icexelloss/miniconda3/envs/spark-dev/lib/python3.5/site-packages/pyarrow/pandas_compat.py in construct_metadata(df, index_levels, preserve_index, types)
    187                         arrow_type=arrow_type
    188                     )
--> 189                     for name, arrow_type in zip(df.columns, df_types)
    190                 ] + (
    191                     [

/home/icexelloss/miniconda3/envs/spark-dev/lib/python3.5/site-packages/pyarrow/pandas_compat.py in <listcomp>(.0)
    187                         arrow_type=arrow_type
    188                     )
--> 189                     for name, arrow_type in zip(df.columns, df_types)
    190                 ] + (
    191                     [

/home/icexelloss/miniconda3/envs/spark-dev/lib/python3.5/site-packages/pyarrow/pandas_compat.py in get_column_metadata(column, name, arrow_type)
    125         raise TypeError(
    126             'Column name must be a string. Got column {} of type {}'.format(
--> 127                 name, type(name).__name__
    128             )
    129         )

TypeError: Column name must be a string. Got column 0 of type int64

Reporter: Li Jin / @icexelloss
Assignee: Wes McKinney / @wesm

Note: This issue was originally created as ARROW-1291. Please see the migration documentation for further details.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions