Skip to content

Commit 916f4cb

Browse files
committed
update doc for method slice_replace
1 parent fb556ed commit 916f4cb

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

pandas/core/strings.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1180,19 +1180,36 @@ def str_slice(arr, start=None, stop=None, step=None):
11801180

11811181
def str_slice_replace(arr, start=None, stop=None, repl=None):
11821182
"""
1183+
Replace a sliced string.
1184+
11831185
Replace a slice of each string in the Series/Index with another
11841186
string.
11851187
11861188
Parameters
11871189
----------
11881190
start : int or None
1191+
Left edge index.
11891192
stop : int or None
1193+
Right edge index.
11901194
repl : str or None
1191-
String for replacement
1195+
String for replacement.
11921196
11931197
Returns
11941198
-------
11951199
replaced : Series/Index of objects
1200+
1201+
Examples
1202+
--------
1203+
>>> s = pd.Series(['This is a Test 1', 'This is a Test 2'])
1204+
>>> s
1205+
0 This is a Test 1
1206+
1 This is a Test 2
1207+
dtype: object
1208+
>>> s = s.str.slice_replace(8, 14, 'an Example')
1209+
>>> s
1210+
0 This is an Example 1
1211+
1 This is an Example 2
1212+
dtype: object
11961213
"""
11971214
if repl is None:
11981215
repl = ''

0 commit comments

Comments
 (0)