October 2019
Beginner to intermediate
674 pages
16h 43m
English
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]: stockHistoricalPricesOut[70]:<class 'pandas.core.panel.Panel'>Dimensions: 2 (items) x 3 (major_axis) x 3 (minor_axis)Items axis: FB to NFLXMajor_axis axis: 2014-02-03 00:00:00 to 2014-02-05 00:00:00Minor_axis axis: ...Read now
Unlock full access