-
-
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
DOC: Updating str_repeat docstring #22571
Merged
datapythonista
merged 9 commits into
pandas-dev:master
from
JesperDramsch:str_repeat-docstring
Sep 18, 2018
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
17d5f83
Cleaned up DocString for str_repeat and added examples
JesperDramsch 6e9a869
PEP8-ing
JesperDramsch 55dcbb2
Suggested changes implemented
JesperDramsch ba258a9
blank line
JesperDramsch c2dbb94
Explanation
JesperDramsch 1f43f87
Array -> Sequence
JesperDramsch 6a86ba2
missing s
JesperDramsch 974cc68
Single string doc start
JesperDramsch a252aa7
Added periods
JesperDramsch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -675,20 +675,42 @@ 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 in the Series or Index. | ||
|
||
Parameters | ||
---------- | ||
repeats : int or array | ||
Same value for all (int) or different value per (array) | ||
repeats : int or sequence of int | ||
Same value for all (int) or different value per (sequence). | ||
|
||
Returns | ||
------- | ||
repeated : Series/Index of objects | ||
Series or Index of object | ||
Series or Index of repeated string objects specified by | ||
input parameter repeats. | ||
|
||
Examples | ||
-------- | ||
>>> s = pd.Series(['a', 'b', 'c']) | ||
>>> s | ||
0 a | ||
1 b | ||
2 c | ||
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 don't know that it is necessary, be I do see that elsewhere in our examples the |
||
|
||
Single int repeats string in Series | ||
|
||
>>> s.str.repeat(repeats=2) | ||
0 aa | ||
1 bb | ||
2 cc | ||
|
||
Sequence of int repeats corresponding string in Series | ||
|
||
>>> s.str.repeat(repeats=[1, 2, 3]) | ||
0 a | ||
1 bb | ||
2 ccc | ||
""" | ||
if is_scalar(repeats): | ||
|
||
def rep(x): | ||
try: | ||
return compat.binary_type.__mul__(x, repeats) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
sequence of int
might be fine, and maybe 'sequence' is a term that has a clear definition in the pandas community, but I often seearray_like
used in the numpy documentation. Not really recommending anything, just curious issequence
is used similarly here, or you were just using to to indicate a list/array/tuple/etc of integers.