cudf.core.column.string.StringMethods.wrap#
- StringMethods.wrap(width: int, **kwargs) SeriesOrIndex[source]#
将Series/Index中的长字符串换行,使其在段落中格式化,长度小于给定宽度。
- Parameters:
- widthint
最大行宽。
- Returns:
- Series or Index
注释
参数 expand_tabsbool, replace_whitespace, drop_whitespace, break_long_words, break_on_hyphens, expand_tabsbool 目前还不支持,如果设置为任何值,将会引发一个 NotImplementedError。
此方法目前实现了与R的stringr库
str_wrap函数相匹配的行为,可以通过以下参数设置获得等效的pandas实现:expand_tabs = False
replace_whitespace = True
drop_whitespace = True
break_long_words = False
break_on_hyphens = False
示例
>>> 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