Multi-indexing

We'll now turn to the topic of multi-indexing. Multi-level or hierarchical indexing is useful because it enables pandas users to select and massage data in multiple dimensions by using data structures such as Series and DataFrames. In order to start, let's save the following data to a file, stock_index_prices.csv, and read it in:

    In[950]:sharesIndexDataDF=pd.read_csv('./stock_index_prices.csv')
    In [951]: sharesIndexDataDF Out[951]: TradingDate PriceType Nasdaq S&P 500 Russell 2000 0 2014/02/21 open 4282.17 1841.07 1166.25 1 2014/02/21 close 4263.41 1836.25 1164.63 2 2014/02/21 high 4284.85 1846.13 1168.43 3 2014/02/24 open 4273.32 1836.78 1166.74 4 2014/02/24 close 4292.97 1847.61 1174.55 5 2014/02/24 high 4311.13 1858.71 ...

Get Mastering pandas - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.