July 2019
Beginner to intermediate
740 pages
16h 52m
English
With selection, we grab entire columns. Using our earthquake data, let's grab the mag column, which contains the magnitudes of the earthquakes:
>>> df.mag0 1.351 1.292 3.423 0.444 2.16 ... 9327 0.629328 1.009329 2.409330 1.109331 0.66Name: mag, Length: 9332, dtype: float64
In the preceding example, we selected the mag column as an attribute of the dataframe; however, we can also access it with a dictionary-like notation:
>>> df['mag']0 1.351 1.292 3.423 0.444 2.16 ... 9327 0.629328 1.009329 2.409330 1.109331 0.66Name: mag, Length: 9332, dtype: float64
We aren't limited to selecting one column at a time. By passing a list to the dictionary lookup, we can select many columns, giving us a DataFrame object that is a subset of our ...
Read now
Unlock full access