-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
update the pandas.Series.str.repeat docstring #20634
Changes from all commits
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 |
---|---|---|
|
@@ -678,17 +678,45 @@ def str_replace(arr, pat, repl, n=-1, case=None, flags=0, regex=True): | |
|
||
def str_repeat(arr, repeats): | ||
""" | ||
Duplicate each string in the Series/Index by indicated number | ||
of times. | ||
Duplicate each string repeated by indicated number of times. | ||
|
||
Duplicate each string in the Series/Index by indicated number of times. | ||
A passed value of zero or negative integer will return an empty string. | ||
|
||
Parameters | ||
---------- | ||
repeats : int or array | ||
Same value for all (int) or different value per (array) | ||
repeats : int or array-like | ||
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 we use |
||
Same value for all (int) or different value per (array). | ||
|
||
Returns | ||
------- | ||
repeated : Series/Index of objects | ||
Series or Index | ||
Series or Index of repeated string objects specified by | ||
input parameter repeats. | ||
|
||
Examples | ||
-------- | ||
>>> s = pd.Series(['a', 'b', 'c', 'd', 'e']) | ||
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. I think having 5 cases that illustrate exactly the same is not very useful. Can we have:
Can you also show the value of |
||
|
||
Using same value for all: | ||
|
||
>>> s.str.repeat(repeats=4) | ||
0 aaaa | ||
1 bbbb | ||
2 cccc | ||
3 dddd | ||
4 eeee | ||
dtype: object | ||
|
||
Using different value per element: | ||
|
||
>>> s.str.repeat(repeats=[-2, -1, 0, 1, 2]) | ||
0 | ||
1 | ||
2 | ||
3 d | ||
4 ee | ||
dtype: object | ||
""" | ||
if is_scalar(repeats): | ||
|
||
|
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.
This seems redundant, can we get rid of it?