Skip to content

hierarchical index + frame_table + data_columns=True -> TypeError #4710

Closed
@kghose

Description

@kghose
import pandas as pd, numpy

r = numpy.empty((3,4))
index = pd.MultiIndex.from_tuples([('A','a'), ('A','b'), ('B','a'), ('B','b')])
df = pd.DataFrame(r, columns=index)

store = pd.HDFStore('df.h5')
store.put('data',df) #->OK
store.put('data1',df,table=True) #-> Ok
store.put('data2',df,table=True,data_columns=['A']) #-> Ok
store.put('data3',df,table=True,data_columns=True) #-> raises hell 
#TypeError: not all arguments converted during string formatting

store['data']['A'] #->OK
store['data1']['A'] #-> KeyError KeyError: u'no item named A'

In [43]: df = store['data']

In [44]: df
Out[44]: 
   A                            B               
   a             b              a              b
0  2 -1.727234e-77  2.964394e-323   0.000000e+00
1  0  0.000000e+00   0.000000e+00   0.000000e+00
2  0  0.000000e+00   0.000000e+00  8.344027e-309

In [45]: df = store['data1']

In [46]: df
Out[46]: 
   (A, a)        (A, b)         (B, a)         (B, b)
0       2 -1.727234e-77  2.964394e-323   0.000000e+00
1       0  0.000000e+00   0.000000e+00   0.000000e+00
2       0  0.000000e+00   0.000000e+00  8.344027e-309


pd.__version__ -> '0.12.0'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions