cudf.core.column.string.StringMethods.wrap#

StringMethods.wrap(width: int, **kwargs) SeriesOrIndex[source]#

Wrap long strings in the Series/Index to be formatted in paragraphs with length less than a given width.

Parameters:
widthint

Maximum line width.

Returns:
Series or Index

Notes

The parameters expand_tabsbool, replace_whitespace, drop_whitespace, break_long_words, break_on_hyphens, expand_tabsbool are not yet supported and will raise a NotImplementedError if they are set to any value.

This method currently achieves behavior matching R’s stringr library str_wrap function, the equivalent pandas implementation can be obtained using the following parameter setting:

expand_tabs = False

replace_whitespace = True

drop_whitespace = True

break_long_words = False

break_on_hyphens = False

Examples

>>> import cudf
>>> data = ['line to be wrapped', 'another line to be wrapped']
>>> s = cudf.Series(data)
>>> s.str.wrap(12)
0             line to be\nwrapped
1    another line\nto be\nwrapped
dtype: object