@@ -2232,26 +2232,66 @@ def removesuffix(self, suffix: str):
2232
2232
return self ._wrap_result (result )
2233
2233
2234
2234
@forbid_nonstring_types (["bytes" ])
2235
- def wrap (self , width : int , ** kwargs ):
2235
+ def wrap (
2236
+ self ,
2237
+ width : int ,
2238
+ expand_tabs : bool = True ,
2239
+ tabsize : int = 8 ,
2240
+ replace_whitespace : bool = True ,
2241
+ drop_whitespace : bool = True ,
2242
+ initial_indent : str = "" ,
2243
+ subsequent_indent : str = "" ,
2244
+ fix_sentence_endings : bool = False ,
2245
+ break_long_words : bool = True ,
2246
+ break_on_hyphens : bool = True ,
2247
+ max_lines : int | None = None ,
2248
+ placeholder : str = " [...]" ,
2249
+ ):
2236
2250
r"""
2237
2251
Wrap strings in Series/Index at specified line width.
2238
2252
2239
2253
This method has the same keyword parameters and defaults as
2240
- :class:`textwrap.TextWrapper`.
2254
+ :class:`textwrap.TextWrapper`.
2241
2255
2242
2256
Parameters
2243
2257
----------
2244
- width : int
2258
+ width : int, optional
2245
2259
Maximum line width.
2246
2260
expand_tabs : bool, optional
2247
2261
If True, tab characters will be expanded to spaces (default: True).
2262
+ tabsize : int, optional
2263
+ If expand_tabs is true, then all tab characters in text will be
2264
+ expanded to zero or more spaces, depending on the current column
2265
+ and the given tab size (default: 8).
2248
2266
replace_whitespace : bool, optional
2249
2267
If True, each whitespace character (as defined by string.whitespace)
2250
2268
remaining after tab expansion will be replaced by a single space
2251
2269
(default: True).
2252
2270
drop_whitespace : bool, optional
2253
2271
If True, whitespace that, after wrapping, happens to end up at the
2254
2272
beginning or end of a line is dropped (default: True).
2273
+ initial_indent : str, optional
2274
+ String that will be prepended to the first line of wrapped output.
2275
+ Counts towards the length of the first line. The empty string is
2276
+ not indented (default: '').
2277
+ subsequent_indent : str, optional
2278
+ String that will be prepended to all lines of wrapped output except
2279
+ the first. Counts towards the length of each line except the first
2280
+ (default: '').
2281
+ fix_sentence_endings : bool, optional
2282
+ If true, TextWrapper attempts to detect sentence endings and ensure
2283
+ that sentences are always separated by exactly two spaces. This is
2284
+ generally desired for text in a monospaced font. However, the sentence
2285
+ detection algorithm is imperfect: it assumes that a sentence ending
2286
+ consists of a lowercase letter followed by one of '.', '!', or '?',
2287
+ possibly followed by one of '"' or "'", followed by a space. One
2288
+ problem with this algorithm is that it is unable to detect the
2289
+ difference between “Dr.” in `[...] Dr. Frankenstein's monster [...]`
2290
+ and “Spot.” in `[...] See Spot. See Spot run [...]`
2291
+ Since the sentence detection algorithm relies on string.lowercase
2292
+ for the definition of “lowercase letter”, and a convention of using
2293
+ two spaces after a period to separate sentences on the same line,
2294
+ it is specific to English-language texts (default: False).
2255
2295
break_long_words : bool, optional
2256
2296
If True, then words longer than width will be broken in order to ensure
2257
2297
that no lines are longer than width. If it is false, long words will
@@ -2262,6 +2302,12 @@ def wrap(self, width: int, **kwargs):
2262
2302
only whitespaces will be considered as potentially good places for line
2263
2303
breaks, but you need to set break_long_words to false if you want truly
2264
2304
insecable words (default: True).
2305
+ max_lines : int, optional
2306
+ If not None, then the output will contain at most max_lines lines, with
2307
+ placeholder appearing at the end of the output (default: None).
2308
+ placeholder : str, optional
2309
+ String that will appear at the end of the output text if it has been
2310
+ truncated (default: ' [...]').
2265
2311
2266
2312
Returns
2267
2313
-------
@@ -2287,7 +2333,20 @@ def wrap(self, width: int, **kwargs):
2287
2333
1 another line\nto be\nwrapped
2288
2334
dtype: object
2289
2335
"""
2290
- result = self ._data .array ._str_wrap (width , ** kwargs )
2336
+ result = self ._data .array ._str_wrap (
2337
+ width = width ,
2338
+ expand_tabs = expand_tabs ,
2339
+ tabsize = tabsize ,
2340
+ replace_whitespace = replace_whitespace ,
2341
+ drop_whitespace = drop_whitespace ,
2342
+ initial_indent = initial_indent ,
2343
+ subsequent_indent = subsequent_indent ,
2344
+ fix_sentence_endings = fix_sentence_endings ,
2345
+ break_long_words = break_long_words ,
2346
+ break_on_hyphens = break_on_hyphens ,
2347
+ max_lines = max_lines ,
2348
+ placeholder = placeholder ,
2349
+ )
2291
2350
return self ._wrap_result (result )
2292
2351
2293
2352
@forbid_nonstring_types (["bytes" ])
0 commit comments