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)
| 4765 | |
| 4766 | @derived_from(pd.Index) |
| 4767 | def map(self, arg, na_action=None, meta=None, is_monotonic=False): |
| 4768 | """ |
| 4769 | Note that this method clears any known divisions. |
| 4770 | |
| 4771 | If your mapping function is monotonically increasing then use `is_monotonic` |
| 4772 | to apply the mapping function to the old divisions and assign the new |
| 4773 | divisions to the output. |
| 4774 | |
| 4775 | """ |
| 4776 | if isinstance(arg, Series): |
| 4777 | if not expr.are_co_aligned(self.expr, arg.expr): |
| 4778 | if meta is None: |
| 4779 | warnings.warn(meta_warning(meta, method="map")) |
| 4780 | return new_collection( |
| 4781 | expr.MapIndexAlign(self, arg, na_action, meta, is_monotonic) |
| 4782 | ) |
| 4783 | if meta is None: |
| 4784 | meta = expr.emulate(M.map, self, arg, na_action=na_action, udf=True) |
| 4785 | warnings.warn(meta_warning(meta, method="map")) |
| 4786 | return new_collection( |
| 4787 | expr.Map( |
| 4788 | self, arg=arg, na_action=na_action, meta=meta, is_monotonic=is_monotonic |
| 4789 | ) |
| 4790 | ) |
| 4791 | |
| 4792 | def __dir__(self): |
| 4793 | o = set(dir(type(self))) |