In many applications, the data may be spread across many files or databases, the storage form is not conducive to analysis. This section concerns can be polymerized, combined, a method of remodeling data.
1, hierarchical indexes
Hierarchical index (hierarchical indexing) is an important feature pandas, which allows you to have multiple (two or more) index level on one axis. Abstract point that it allows you to handle data at high latitudes to lower latitudes form. Let's look at a simple chestnut: Create a Series, and with a list of list or as an array index:
data = pd.Series(np.random.randn(9), index=[['a', 'a', 'a', 'b', 'b', 'c', 'c', 'd', 'd'], [1, 2, 3, 1, 3, 1, 2, 2, 3]]) print(data)
a 1 -1.624220 2 -1.061747 3 0.895593 b 1 -2.702315 3 -1.690189 c 1 2.608471 2 1.167507 d 2 0.139161 3 1.298629 dtype: float64
The results are seen beautified Series format with MultiIndex index. Between the index "spacer" means "directly above the label":
print(data.index)
MultiIndex ([(a '1), ('a', 2), ('a', 3), ('b', 1), ('b', 3), ('c', 1), ('c', 2), ('d', 2), ('d', 3)], )
For objects a hierarchical index, you can use so-called partial index
Continuously updated in ......