pandas 1.4.2

ParametersReturns
replace(self, to_replace, value, inplace: 'bool' = False)

Parameters

to_replace: object :

The value to be replaced

value: object :

The value to replace it with

inplace: bool :

Whether the operation is done in-place

Returns

None if inplace is True, otherwise the new Categorical after replacement

Replaces all instances of one value with another

Examples

This example is valid syntax, but we were not able to check execution
>>> s = pd.Categorical([1, 2, 1, 3])
... s.replace(1, 3) [3, 2, 3, 3] Categories (2, int64): [2, 3]
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#2487
type: <class 'function'>
Commit: