-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Update Series.repeat docstring #20242
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 2 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 |
---|---|---|
|
@@ -918,12 +918,49 @@ def _set_values(self, key, value): | |
@deprecate_kwarg(old_arg_name='reps', new_arg_name='repeats') | ||
def repeat(self, repeats, *args, **kwargs): | ||
""" | ||
Repeat elements of an Series. Refer to `numpy.ndarray.repeat` | ||
for more information about the `repeats` argument. | ||
Repeat elements of a Series. | ||
|
||
Each element of the Series is repeated 'repeats' times. | ||
|
||
Parameters | ||
---------- | ||
repeats : int | ||
The number of repetitions for each element. | ||
*args | ||
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. You can remove args and kwargs. The validation function is an implementation detail that users shouldn't have to worry about. You could mention, perhaps in 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. Listen to @jorisvandenbossche about args and kwargs, not me :) 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. After discussion, you can document them like
|
||
These parameters will be passed to a validation function. | ||
**kwargs | ||
These parameters will be passed to a validation function. | ||
|
||
See also | ||
-------- | ||
numpy.ndarray.repeat | ||
Series.append : Concatenate two or more Series. | ||
pandas.concat : Concatenate two or more DataFrames. | ||
numpy.repeat : Repeat elements of an array. | ||
|
||
Returns | ||
------- | ||
Series | ||
The repeated version of the Series. | ||
|
||
Examples | ||
-------- | ||
>>> df = pd.DataFrame({'col1' : ['A','B','C'],'col2' : [ 0 , 1 , 2 ]}) | ||
>>> df | ||
col1 col2 | ||
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. Spacing looks off. Should move it over a few spaces I think. Double check that this is right. |
||
0 A 0 | ||
1 B 1 | ||
2 C 2 | ||
>>> df.col1.repeat(3) | ||
0 A | ||
0 A | ||
0 A | ||
1 B | ||
1 B | ||
1 B | ||
2 C | ||
2 C | ||
2 C | ||
Name: col1, dtype: object | ||
""" | ||
nv.validate_repeat(args, kwargs) | ||
new_index = self.index.repeat(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.
Single backtick for parameters like `repeats`