In [27]: for key in pnl.minor_axis :
....: print key
....: print pnl.minor_xs (key)
Pandas Panel : How To Iterate Over the Minor Axis?
-
18-07-2023 - |
Question
What is the preferred way to iterate over all the items (which are dataframes) in a Panel's Minor Axis?
At the moment I am using
pnl = pd.Panel( ... )
for key, df in pnl.transpose(2,1,0).iteritems():
print( key )
but it looks ugly and unpythonic.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow