October 2017
Intermediate to advanced
532 pages
16h 10m
English
The filter method comes with another parameter, items, which takes a list of exact column names. This is nearly an exact duplication of the indexing operator, except that a KeyError will not be raised if one of the strings does not match a column name. For instance, movie.filter(items=['actor_1_name', 'asdf']) runs without error and returns a single column DataFrame.
One confusing aspect of select_dtypes is its flexibility to take both strings and Python objects. The following table should clarify all the possible ways to select the many different column data types. There is no standard or preferred method of referring to data types in pandas, so it's good to be aware of both ways:
|
Python object |
String |
Notes ... |
Read now
Unlock full access