pandas.Series.str.wrap

pandas 3.1.1 · Series and accessors · method

Break long strings into lines at the specified display width.

Call syntax

Series.str.wrap(…) Full signature
Series.str.wrap(
    width,
    expand_tabs=True,
    tabsize=8,
    replace_whitespace=True,
    drop_whitespace=True,
    initial_indent='',
    subsequent_indent='',
    fix_sentence_endings=False,
    break_long_words=True,
    break_on_hyphens=True,
    max_lines=None,
    placeholder=' [...]',
)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
width Required
Positional or keyword
int

Set the requested width of the formatted result.

expand_tabs Optional
Positional or keyword
Default True
bool
tabsize Optional
Positional or keyword
Default 8
int
replace_whitespace Optional
Positional or keyword
Default True
bool
drop_whitespace Optional
Positional or keyword
Default True
bool
initial_indent Optional
Positional or keyword
Default ''
str
subsequent_indent Optional
Positional or keyword
Default ''
str
fix_sentence_endings Optional
Positional or keyword
Default False
bool
break_long_words Optional
Positional or keyword
Default True
bool
break_on_hyphens Optional
Positional or keyword
Default True
bool
max_lines Optional
Positional or keyword
Default None
int
placeholder Optional
Positional or keyword
Default ' [...]'
str

Returns

Series or Index