wesm/pandas — Issue #543: Craft API for 3D (Panel) <-> 2D (DataFrame) reshaping operations
Author: wesm
Created: 2011-12-26 03:28:09+00:00
State: open
Labels: Enhancement

cc @lodagro, moving further discussion here from the mailing list

```
Panel was my first idea to use, but i got stuck rather quickly :-) I am unfamiliar with to_long() and LongPanel,
What you suggested is definitely more pathonic (pandas way of doing).

Concerning 3D<->2D manipulations API. First thing i looked for in Panel API was stack and unstack since these handle 2D<->1D manipulations on DataFrame,.
So i would reuse these method names. Just an idea...

Panel.stack(self, stack_ax=None, columns_ax=None, index_ax=None, dropna=True)
stack_ax: int, panel ax that will be used to reduce from 3D<->2D, defaults to ...
columns_ax: int, panel ax that will be used to create columns in resulting DataFrame, defaults to ...
index_ax: int, panel ax that will be used to create index in resulting DataFrame, defaults to ...

Maybe better to use only two of the three axes, since one can only choose two freely.

Being able to select from which ax to stack or take column and index data avoids the need to swap axes before stacking.
```