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