Using a 3D NumPy array with axis labels

Here, we show how to construct a Panel object from a 3D NumPy array. After defining the 3D array, a panel could be created by defining each of the three axes:

In [68]: stockData = np.array([[[63.03,61.48,75],
[62.05,62.75,46],
[62.74,62.19,53]],
[[411.90, 404.38, 2.9],
[405.45, 405.91, 2.6],
[403.15, 404.42, 2.4]]])
In [69]: stockHistoricalPrices = pd.Panel(stockData,
items=['FB', 'NFLX'], major_axis=pd.date_range('2/3/2014', periods=3),
minor_axis=['open price', 'closing price', 'volume'])
In [70]: stockHistoricalPrices
Out[70]:
<class 'pandas.core.panel.Panel'>
Dimensions: 2 (items) x 3 (major_axis) x 3 (minor_axis)
Items axis: FB to NFLX
Major_axis axis: 2014-02-03 00:00:00 to 2014-02-05 00:00:00
Minor_axis axis: open price to volume
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset