December 2018
Beginner to intermediate
682 pages
18h 1m
English
The indexing operator changes behavior based on what type of object is passed to it. The following pseudocode outlines how DataFrame indexing operator handles the object that it is passed:
>>> df[item] # Where `df` is a DataFrame and item is some objectIf item is a string then Find a column name that matches the item exactly Raise KeyError if there is no match Return the column as a SeriesIf item is a list of strings then Raise KeyError if one or more strings in item don't match columns Return a DataFrame with just the columns in the list
If item is a slice object then Works with either integer or string slices Raise KeyError if label from label slice is not in index Return all ROWS that are selected by the sliceIf item is ...