5 PanelND (Experimental)

Warning

In 0.19.0 PanelND is deprecated and will be removed in a future version. The recommended way to represent these types of n-dimensional data are with the xarray package.

PanelND is a module with a set of factory functions to enable a user to construct N-dimensional named containers like Panel4D, with a custom set of axis labels. Thus a domain-specific container can easily be created.

The following creates a Panel5D. A new panel type object must be sliceable into a lower dimensional object. Here we slice to a Panel4D.

In [1]: from pandas.core import panelnd

In [2]: Panel5D = panelnd.create_nd_panel_factory(
   ...:     klass_name   = 'Panel5D',
   ...:     orders  = [ 'cool', 'labels','items','major_axis','minor_axis'],
   ...:     slices  = { 'labels' : 'labels', 'items' : 'items',
   ...:                 'major_axis' : 'major_axis', 'minor_axis' : 'minor_axis' },
   ...:     slicer  = pd.Panel4D,
   ...:     aliases = { 'major' : 'major_axis', 'minor' : 'minor_axis' },
   ...:     stat_axis    = 2)
   ...: 

In [3]: p5d = Panel5D(dict(C1 = p4d))

In [4]: p5d
Out[4]: 
<class 'pandas.core.panelnd.Panel5D'>
Dimensions: 1 (cool) x 2 (labels) x 2 (items) x 5 (major_axis) x 4 (minor_axis)
Cool axis: C1 to C1
Labels axis: Label1 to Label2
Items axis: Item1 to Item2
Major_axis axis: 2000-01-01 00:00:00 to 2000-01-05 00:00:00
Minor_axis axis: A to D

# print a slice of our 5D
In [5]: p5d.ix['C1',:,:,0:3,:]
Out[5]: 
<class 'pandas.core.panelnd.Panel4D'>
Dimensions: 2 (labels) x 2 (items) x 3 (major_axis) x 4 (minor_axis)
Labels axis: Label1 to Label2
Items axis: Item1 to Item2
Major_axis axis: 2000-01-01 00:00:00 to 2000-01-03 00:00:00
Minor_axis axis: A to D

# transpose it
In [6]: p5d.transpose(1,2,3,4,0)
Out[6]: 
<class 'pandas.core.panelnd.Panel5D'>
Dimensions: 2 (cool) x 2 (labels) x 5 (items) x 4 (major_axis) x 1 (minor_axis)
Cool axis: Label1 to Label2
Labels axis: Item1 to Item2
Items axis: 2000-01-01 00:00:00 to 2000-01-05 00:00:00
Major_axis axis: A to D
Minor_axis axis: C1 to C1

# look at the shape & dim
In [7]: p5d.shape
Out[7]: (1, 2, 2, 5, 4)

In [8]: p5d.ndim
Out[8]: 5