-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: update the pandas.Series.str.slice_replace docstring #20273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
916f4cb
bbed286
7a0cf0c
56a854e
5263522
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1180,19 +1180,36 @@ def str_slice(arr, start=None, stop=None, step=None): | |
|
||
def str_slice_replace(arr, start=None, stop=None, repl=None): | ||
""" | ||
Replace a sliced string. | ||
|
||
Replace a slice of each string in the Series/Index with another | ||
string. | ||
|
||
Parameters | ||
---------- | ||
start : int or None | ||
Left edge index. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you indicate what None means? (I suppose this is the from the start of the string) Can you also change "int or None" into "int, optional"? And then maybe you can say for the above "If not specified, slice from the start of each string" (and same for end, but then "slice until the end of each string" |
||
stop : int or None | ||
Right edge index. | ||
repl : str or None | ||
String for replacement | ||
String for replacement. | ||
|
||
Returns | ||
------- | ||
replaced : Series/Index of objects | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For a See Also, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And we also have |
||
Examples | ||
-------- | ||
>>> s = pd.Series(['This is a Test 1', 'This is a Test 2']) | ||
>>> s | ||
0 This is a Test 1 | ||
1 This is a Test 2 | ||
dtype: object | ||
>>> s = s.str.slice_replace(8, 14, 'an Example') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. blank line between cases |
||
>>> s | ||
0 This is an Example 1 | ||
1 This is an Example 2 | ||
dtype: object | ||
""" | ||
if repl is None: | ||
repl = '' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's implied, but I'd like to see this say what the sliced bit is replaced with
and then the rest of the docstring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "a slice of a string" is easier to understand than "sliced string"