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)
| 4800 | |
| 4801 | @derived_from(pd.Index) |
| 4802 | def map(self, arg, na_action=None, meta=None, is_monotonic=False): |
| 4803 | """ |
| 4804 | Note that this method clears any known divisions. |
| 4805 | |
| 4806 | If your mapping function is monotonically increasing then use `is_monotonic` |
| 4807 | to apply the mapping function to the old divisions and assign the new |
| 4808 | divisions to the output. |
| 4809 | |
| 4810 | """ |
| 4811 | if isinstance(arg, Series): |
| 4812 | if not expr.are_co_aligned(self.expr, arg.expr): |
| 4813 | if meta is None: |
| 4814 | warnings.warn(meta_warning(meta, method="map")) |
| 4815 | return new_collection( |
| 4816 | expr.MapIndexAlign(self, arg, na_action, meta, is_monotonic) |
| 4817 | ) |
| 4818 | if meta is None: |
| 4819 | meta = expr.emulate(M.map, self, arg, na_action=na_action, udf=True) |
| 4820 | warnings.warn(meta_warning(meta, method="map")) |
| 4821 | return new_collection( |
| 4822 | expr.Map( |
| 4823 | self, arg=arg, na_action=na_action, meta=meta, is_monotonic=is_monotonic |
| 4824 | ) |
| 4825 | ) |
| 4826 | |
| 4827 | def __dir__(self): |
| 4828 | o = set(dir(type(self))) |