October 2017
Intermediate to advanced
532 pages
16h 10m
English
Boolean selection gives much more flexibility than index selection as it is possible to condition on any number of columns. In this recipe, we used a single column as the index. It is possible to concatenate multiple columns together to form an index. For instance, in the following code, we set the index equal to the concatenation of the city and state columns:
>>> college.index = college['CITY'] + ', ' + college['STABBR']>>> college = college.sort_index()>>> college.head()

From here, we can select all colleges from a particular city and state combination without boolean indexing. Let's select all colleges from Miami, FL:
Read now
Unlock full access