Skip to content

feather drops MultiIndices from pandas DataFrames on serialize/deserialize #2494

@rs2

Description

@rs2
import pandas as pd
import pyarrow as pa
import pyarrow.feather as feather

pd.__version__
# '0.23.4'
pa.__version__
# '0.10.0'

df = pd.DataFrame(dict(a=[1, 2], b=['foo', pd.NaT], c=[3.14, -float('inf')], d=['baz', 'baz'])).set_index(['a', 'b'])
df.d = df.d.astype('category')
df.columns = pd.MultiIndex.from_product([[42], ['foo', 'bar']])

df.index
#  MultiIndex(levels=[[1, 2], ['foo']],
#             labels=[[0, 1], [0, -1]],
#             names=['a', 'b'])

df.columns
# MultiIndex(levels=[[42], ['bar', 'foo']],
#            labels=[[0, 0], [1, 0]])

feather.write_feather(df, PATH)
read_df = feather.read_feather(PATH)

read_df.index
# RangeIndex(start=0, stop=2, step=1)
read_df.columns
# Index(['('42', 'foo')', '('42', 'bar')'], dtype='object')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions