OtherTest Flashcards
1
Q
Pandas - Properties.## Filtrer un DataFrame.
Par les labels ?
A
_property_DataFrame.loc[source]
Access a group of rows and columns by label(s) or a boolean array.
.loc[]
is primarily label based, but may also be used with a boolean array.
Allowed inputs are:
- A single label, e.g.
5
or'a'
, (note that5
is interpreted as a_label_of the index, andneveras an integer position along the index). - A list or array of labels, e.g.
['a','b','c']
. - A slice object with labels, e.g.
'a':'f'
.WarningNote that contrary to usual python slices,boththe start and the stop are included - A boolean array of the same length as the axis being sliced, e.g.
[True,False,True]
. - An alignable boolean Series. The index of the key will be aligned before masking.
- An alignable Index. The Index of the returned selection will be the input.
- A
callable
function with one argument (the calling Series or DataFrame) and that returns valid output for indexing (one of the above)
See more atSelection by Label.
Raises:
KeyError
If any items are not found.
IndexingError
If an indexed key is passed and its index is unalignable to the frame index.
2
Q
A