chapter four

4 Indexes

 

Every data frame has an index (describing the rows) and a list of columns. Indexes in Pandas are extremely flexible and powerful; an index can even be hierarchical, allowing us to query our data in sophisticated ways. Understanding how we can create, replace, and use indexes is a crucial part of working with Pandas. In this chapter, we’ll practice working with indexes in a variety of ways. We’ll also see how we can change a data frame’s index, and how we can use it to summarize our data in a "pivot table."

4.1 Useful references

4.2 Exercise 21: Parking tickets

4.2.1 Discussion

4.2.2 Solution

4.2.3 Beyond the exercise

4.3 Exercise 22: State SAT scores (learning goal: setting and using a multi-index)

4.3.1 Discussion

4.3.2 Solution

4.3.3 Beyond the exercise

4.4 Exercise 23: Olympic games

4.4.1 Discussion

4.4.2 Solution

4.4.3 Beyond the exercise

4.5 Exercise 24: Olympic pivots

4.5.1 Discussion

4.5.2 Solution

4.5.3 Beyond the exercise

4.6 Summary