Choose Rows
Select rows in the dataset.
Top and Bottom Rows
Return the first or last n rows.
Range of Rows
Return a range of rows from the dataset. The indexers .loc
and .iloc
have the ability to
select data from the dataset by label and location respectively.
See also
Filter Rows
Boolean indexing
Use of boolean vectors to filter the data. The operators are: |
for or, &
for and, and ~
for not.
Using isin
Combine DataFrame’s isin
with the any()
and all()
methods to quickly select subsets of your
data that meet a given criteria. This is useful for the cases when you don’t know which of the sought
labels are in fact present.
Using query
The query()
method allows selection using an expression.
See also
-
Boolean indexing in the pandas User Guide.
-
Indexing with isin in the pandas User Guide.
-
The query() method in the pandas User Guide.
Duplicates
The methods duplicated
and drop_duplicates
identify and remove duplicate rows in a DataFrame.
A subset of columns can be used to identify duplicates.
See also
- Duplicate data in the pandas User Guide.