Skip to content

Instantly share code, notes, and snippets.

@mdengler
Created June 10, 2016 03:25
Show Gist options
  • Save mdengler/c53d77c92f6db9c2aab7bc59af655fb2 to your computer and use it in GitHub Desktop.
Save mdengler/c53d77c92f6db9c2aab7bc59af655fb2 to your computer and use it in GitHub Desktop.
panel4d iloc and slices?
>>> p4 = pd.Panel4D({i: pd.Panel({j: pd.DataFrame(range(10)) for j in range(10)}) for i in range(10)})
>>> p4.iloc[:,:,0]
<class 'pandas.core.panel.Panel'>
Dimensions: 10 (items) x 10 (major_axis) x 1 (minor_axis)
Items axis: 0 to 9
Major_axis axis: 0 to 9
Minor_axis axis: 0 to 0
>>> p4.iloc[slice(None), slice(None), slice(0)]
<class 'pandas.core.panelnd.Panel4D'>
Dimensions: 10 (labels) x 10 (items) x 0 (major_axis) x 1 (minor_axis)
Labels axis: 0 to 9
Items axis: 0 to 9
Major_axis axis: None
Minor_axis axis: 0 to 0
@mdengler
Copy link
Author

Thanks to papna on #pydata:

>>> p4.iloc[slice(None), slice(None), 0]
<class 'pandas.core.panel.Panel'>
Dimensions: 10 (items) x 10 (major_axis) x 1 (minor_axis)
Items axis: 0 to 9
Major_axis axis: 0 to 9
Minor_axis axis: 0 to 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment