How it works...

When the index is not sorted and contains duplicates, as with college2, pandas will need to check every single value in the index in order to make the correct selection. When the index is sorted, as with college3, pandas takes advantage of an algorithm called binary search to greatly improve performance.

In the second half of the recipe, we use a unique column as the index. Pandas implements unique indexes with a hash table, which makes for even faster selection. Each index location can be looked up in nearly the same time regardless of its length.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.73.127