pandas 1.4.2

ParametersRaisesReturns
isin(self, values) -> 'npt.NDArray[np.bool_]'

Return a boolean NumPy Array showing whether each element in the Categorical matches an element in the passed sequence of :None:None:`values` exactly.

Parameters

values : set or list-like

The sequence of values to test. Passing in a single string will raise a TypeError . Instead, turn a single string into a list of one element.

Raises

TypeError
  • If :None:None:`values` is not a set or list-like

Returns

np.ndarray[bool]

Check whether :None:None:`values` are contained in Categorical.

See Also

pandas.Series.isin

Equivalent method on Series.

Examples

This example is valid syntax, but we were not able to check execution
>>> s = pd.Categorical(['lama', 'cow', 'lama', 'beetle', 'lama',
...  'hippo'])
... s.isin(['cow', 'lama']) array([ True, True, True, False, True, False])

Passing a single string as s.isin('lama') will raise an error. Use a list of one element instead:

This example is valid syntax, but we were not able to check execution
>>> s.isin(['lama'])
array([ True, False,  True, False,  True, False])
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/arrays/categorical.py#2434
type: <class 'function'>
Commit: