Note that this method clears any known divisions. If your mapping function is monotonically increasing then use `is_monotonic` to apply the mapping function to the old divisions and assign the new divisions to the output.
(self, arg, na_action=None, meta=None, is_monotonic=False)
| 4722 | |
| 4723 | @derived_from(pd.Index) |
| 4724 | def map(self, arg, na_action=None, meta=None, is_monotonic=False): |
| 4725 | """ |
| 4726 | Note that this method clears any known divisions. |
| 4727 | |
| 4728 | If your mapping function is monotonically increasing then use `is_monotonic` |
| 4729 | to apply the mapping function to the old divisions and assign the new |
| 4730 | divisions to the output. |
| 4731 | |
| 4732 | """ |
| 4733 | if isinstance(arg, Series): |
| 4734 | if not expr.are_co_aligned(self.expr, arg.expr): |
| 4735 | if meta is None: |
| 4736 | warnings.warn(meta_warning(meta, method="map")) |
| 4737 | return new_collection( |
| 4738 | expr.MapIndexAlign(self, arg, na_action, meta, is_monotonic) |
| 4739 | ) |
| 4740 | if meta is None: |
| 4741 | meta = expr.emulate(M.map, self, arg, na_action=na_action, udf=True) |
| 4742 | warnings.warn(meta_warning(meta, method="map")) |
| 4743 | return new_collection( |
| 4744 | expr.Map( |
| 4745 | self, arg=arg, na_action=na_action, meta=meta, is_monotonic=is_monotonic |
| 4746 | ) |
| 4747 | ) |
| 4748 | |
| 4749 | def __dir__(self): |
| 4750 | o = set(dir(type(self))) |