当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


Python cudf.core.column.string.StringMethods.wrap用法及代码示例

用法:

StringMethods.wrap(width: int, **kwargs) → SeriesOrIndex

在系列/索引中包装长字符串,以便在长度小于给定宽度的段落中格式化。

参数

widthint

最大线宽。

返回

系列或索引

注意

尚不支持参数expand_tabsbool , replace_whitespace , drop_whitespace , break_long_words , break_on_hyphens , expand_tabsbool,如果将它们设置为任何值,将引发 NotImplementedError。

该方法目前实现了R的stringr库str_wrap函数的行为匹配,通过如下参数设置可以获得等效的pandas实现:

expand_tabs = 假

replace_whitespace = 真

drop_whitespace = 真

break_long_words = 假

break_on_hyphens = 假

例子

>>> 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

相关用法


注:本文由纯净天空筛选整理自rapids.ai大神的英文原创作品 cudf.core.column.string.StringMethods.wrap。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。