pandas_select.label.EndsWith¶
-
class
EndsWith
(pat, case=True, axis='columns', level=None)[source]¶ Select labels that end with a suffix.
- Parameters
pat – Character sequence. Regular expressions are not accepted.
case (default True) – If True, case sensitive.
axis (default 'columns') – Axis along which the function is applied, {0 or ‘index’, 1 or ‘columns’}
level (optional) – Either the integer position of the level or its name. It should only be set if
axis
targets a MultiIndex, otherwise aIndexError
will be raised.
See also
StartsWith
Same as EndsWith, but tests the start of string.
Notes
If applied to a
MultiIndex
withlevel=None
, all the levels will be tested.Examples
>>> df = pd.DataFrame({"bat": [1], "Bear": [1], "caT": [1]}) >>> df bat Bear caT 0 1 1 1 >>> df[EndsWith("t")] bat 0 1 >>> df[EndsWith("t", case=False)] bat caT 0 1 1