Wrap long strings in the array in paragraphs with length less than `width`. This method has the same keyword parameters and defaults as :class:`textwrap.TextWrapper`. If `width` is array-like, it is broadcast against the array and applied elementwise.
(self, width: int | Any, **kwargs)
| 1643 | return self.strip(to_strip, side="right") |
| 1644 | |
| 1645 | def wrap(self, width: int | Any, **kwargs) -> T_DataArray: |
| 1646 | """ |
| 1647 | Wrap long strings in the array in paragraphs with length less than `width`. |
| 1648 | |
| 1649 | This method has the same keyword parameters and defaults as |
| 1650 | :class:`textwrap.TextWrapper`. |
| 1651 | |
| 1652 | If `width` is array-like, it is broadcast against the array and applied |
| 1653 | elementwise. |
| 1654 | |
| 1655 | Parameters |
| 1656 | ---------- |
| 1657 | width : int or array-like of int |
| 1658 | Maximum line-width. |
| 1659 | If array-like, it is broadcast. |
| 1660 | **kwargs |
| 1661 | keyword arguments passed into :class:`textwrap.TextWrapper`. |
| 1662 | |
| 1663 | Returns |
| 1664 | ------- |
| 1665 | wrapped : same type as values |
| 1666 | """ |
| 1667 | ifunc = lambda x: textwrap.TextWrapper(width=x, **kwargs) |
| 1668 | tw = StringAccessor(width)._apply(func=ifunc, dtype=np.object_) # type: ignore[type-var] # hack? |
| 1669 | func = lambda x, itw: "\n".join(itw.wrap(x)) |
| 1670 | return self._apply(func=func, func_args=(tw,)) |
| 1671 | |
| 1672 | # Mapping is only covariant in its values, maybe use a custom CovariantMapping? |
| 1673 | def translate(self, table: Mapping[Any, str | bytes | int | None]) -> T_DataArray: |