October 2019
Beginner to intermediate
674 pages
16h 43m
English
To complete this chapter, we'll discuss operations on indexes. We sometimes need to operate on indexes when we wish to realign our data or select it in different ways. There are various operations:
Note that set_index allows the creation of an index on an existing DataFrame and returns an indexed DataFrame, as we have seen before:
In [939]: stockIndexDataDF=pd.read_csv('./stock_index_data.csv')
In [940]: stockIndexDataDF
Out[940]: TradingDate Nasdaq S&P 500 Russell 2000
0 2014/01/30 4123.13 1794.19 1139.36
1 2014/01/31 4103.88 1782.59 1130.88
2 2014/02/03 3996.96 1741.89 1094.58
3 2014/02/04 4031.52 1755.20 1102.84
4 2014/02/05 4011.55 1751.64 1093.59
5 2014/02/06 4057.12 1773.43 1103.93
Now, we can set the index as ...
Read now
Unlock full access