You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Panel can only be heterogeneous in the items. I just added an orient option to Panel so you can do:
In [4]: panel = Panel.from_dict({'1':a,'2':b}, orient='minor')
In [5]: panel
Out[5]:
<class 'pandas.core.panel.Panel'>
Dimensions: 3 (items) x 30 (major) x 2 (minor)
Items: a to c
Major axis: 0 to 29
Minor axis: 1 to 2
In [6]: panel['a'].values.dtype
Out[6]: dtype('float64')
In [7]: panel['b'].values.dtype
Out[7]: dtype('object')
In [8]: panel['c'].values.dtype
Out[8]: dtype('float64')
in the example below, "a" is a mixed type dataframe. Once included in the Panel, all columns become of type object:
In [249]: a=DataFrame(randn(30,3),columns=('a','b','c'))
In [250]: b=DataFrame(randn(30,3),columns=('a','b','c'))
In [251]: a['b']=a['b'].astype(object)
In [252]: a.dtypes
Out[252]:
a float64
b object
c float64
In [253]: b.dtypes
Out[253]:
a float64
b float64
c float64
In [254]: Panel({'1':a,'2':b})['1'].dtypes
Out[254]:
a object
b object
c object
In [255]: Panel({'1':a,'2':b})['2'].dtypes
Out[255]:
a float64
b float64
c float64
The text was updated successfully, but these errors were encountered: