Series.loc
Access a group of rows by label(s) or a boolean array.
danfo.Series.loc()
Parameters
Type
Description
Default
rows
Array, String
Array, string slice, index of row positions boolean mask to filter by.
Examples
.loc()
is label position based (from 0
to length-1
of the row axis).
Allowed inputs are:
An integer, e.g.
"r1"
.A list or array of integers, e.g.
["a", "b", "d"]
.A boolean mask. E.g [ true, false, false ]
A string slice object with ints, e.g.
[
'"a":"d"'], ["1:4"]
Note: only **** the start label is included, and the end label is ignored.
.loc
will raise a ValueEror
if a requested label is not found.
Indexing by specific row index
Index by a slice of row
The loc function also accepts string slices of the form [start: end], e.g [`"a":"e"`]. This will return all values from label positions a
to e
.
By specifying a start index in a slice, all values after that index are returned.
Slice Series by boolean condition
Last updated
Was this helpful?