Skip to content

Commit 524cd3e

Browse files
committed
Panel4D is like a Panel object, but provides 4 dimensions: labels, items, major_axis, minor_axis
instead of using a dict of Panels to hold data, the Panel4D provides a convenient represenation in pandas space with named dimensions to allow easy axis swapping and slicing testing ------- tests/test_panel4d.py provides a similar methodology to test_panel.py Panel4D required an overhall of many methods in panel.py and one change in core/index.py (regarding multi-indexing) almost all methods in a Panel are extended to Panel4D (with the exception in that Panel now allows a multi-axis on axis 0) docstrings need to be refreshed a bit and made a bit more general all tests that are not skipped pass (tested with 0.9rc1) join is a work in progress further ------- panelnd.py provides a factory function for creation of generic panel-like ND structures with custom named dimensions (this works, but not fully tested - examples are in the docstring)
1 parent b4f4e25 commit 524cd3e

File tree

9 files changed

+1558
-204
lines changed

9 files changed

+1558
-204
lines changed

pandas/core/api.py

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from pandas.core.series import Series, TimeSeries
1515
from pandas.core.frame import DataFrame
1616
from pandas.core.panel import Panel
17+
from pandas.core.panel4d import Panel4D
1718
from pandas.core.groupby import groupby
1819
from pandas.core.reshape import (pivot_simple as pivot, get_dummies,
1920
lreshape)

pandas/core/indexing.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,16 @@ def _multi_take_opportunity(self, tup):
240240
def _multi_take(self, tup):
241241
from pandas.core.frame import DataFrame
242242
from pandas.core.panel import Panel
243+
from pandas.core.panel4d import Panel4D
243244

244245
if isinstance(self.obj, DataFrame):
245246
index = self._convert_for_reindex(tup[0], axis=0)
246247
columns = self._convert_for_reindex(tup[1], axis=1)
247248
return self.obj.reindex(index=index, columns=columns)
249+
elif isinstance(self.obj, Panel4D):
250+
conv = [self._convert_for_reindex(x, axis=i)
251+
for i, x in enumerate(tup)]
252+
return self.obj.reindex(labels=tup[0],items=tup[1], major=tup[2], minor=tup[3])
248253
elif isinstance(self.obj, Panel):
249254
conv = [self._convert_for_reindex(x, axis=i)
250255
for i, x in enumerate(tup)]

0 commit comments

Comments
 (0)