Dispatch to Series.replace column-wise. Parameters ---------- mapping : dict of the form {col: (target, value)} inplace : bool regex : bool or same types as `to_replace` in DataFrame.replace Returns ------- DataFr
(
self, mapping: dict[Hashable, tuple[Any, Any]], inplace: bool, regex
)
| 6546 | return super().pop(item=item) |
| 6547 | |
| 6548 | def _replace_columnwise( |
| 6549 | self, mapping: dict[Hashable, tuple[Any, Any]], inplace: bool, regex |
| 6550 | ) -> Self: |
| 6551 | """ |
| 6552 | Dispatch to Series.replace column-wise. |
| 6553 | |
| 6554 | Parameters |
| 6555 | ---------- |
| 6556 | mapping : dict |
| 6557 | of the form {col: (target, value)} |
| 6558 | inplace : bool |
| 6559 | regex : bool or same types as `to_replace` in DataFrame.replace |
| 6560 | |
| 6561 | Returns |
| 6562 | ------- |
| 6563 | DataFrame |
| 6564 | """ |
| 6565 | # Operate column-wise |
| 6566 | res = self if inplace else self.copy(deep=False) |
| 6567 | ax = self.columns |
| 6568 | |
| 6569 | for i, ax_value in enumerate(ax): |
| 6570 | if ax_value in mapping: |
| 6571 | ser = self.iloc[:, i] |
| 6572 | |
| 6573 | target, value = mapping[ax_value] |
| 6574 | newobj = ser.replace(target, value, regex=regex) |
| 6575 | |
| 6576 | res._iset_item(i, newobj, inplace=inplace) |
| 6577 | |
| 6578 | return res if inplace else res.__finalize__(self) |
| 6579 | |
| 6580 | def shift( |
| 6581 | self, |
no test coverage detected