Skip to content

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

Closed
wants to merge 3 commits into from

Conversation

pedropazzini
Copy link

Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):

  • [ X] PR title is "DOC: update the docstring"
  • The validation script passes: scripts/validate_docstrings.py <your-function-or-method>
  • [ X] The PEP8 style check passes: git diff upstream/master -u -- "*.py" | flake8 --diff
  • [ X] The html version looks good: python doc/make.py --single <your-function-or-method>
  • [ X] It has been proofread on language by another sprint participant

Please include the output of the validation script below between the "```" ticks:


################################################################################
####################### Docstring (pandas.Series.repeat) #######################
################################################################################

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
    These parameters will be passed to a validation function.
**kwargs
    These parameters will be passed to a validation function.

See also
--------
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
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

################################################################################
################################## Validation ##################################
################################################################################

Errors found:
	Errors in parameters section
		Parameters {'kwargs', 'args'} not documented
		Unknown parameters {'**kwargs', '*args'}
		Parameter "*args" has no type
		Parameter "**kwargs" has no type

The errors returned for the script is an error, since t is not ready for **kwargs and *args parameters.

@TomAugspurger TomAugspurger changed the title Repeat DOC: Update Series.repeat docstring Mar 10, 2018
@jorisvandenbossche
Copy link
Member

@pedropazzini Can you check the similar PR #19985 to see if there is something in there you can use? (eg explanation for the **kwargs)

for more information about the `repeats` argument.
Repeat elements of a Series.

Each element of the Series is repeated 'repeats' times.
Copy link
Contributor

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`

----------
repeats : int
The number of repetitions for each element.
*args
Copy link
Contributor

Choose a reason for hiding this comment

The 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. repeats is the only valid argument.

You could mention, perhaps in Notes that "unlike numpy.repeat, `axis` is not a valid argument".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Listen to @jorisvandenbossche about args and kwargs, not me :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After discussion, you can document them like

*args, **kwargs
    Additional keywords have no effect but might be accepted for
    compatibility with numpy.

--------
>>> df = pd.DataFrame({'col1' : ['A','B','C'],'col2' : [ 0 , 1 , 2 ]})
>>> df
col1 col2
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@pedropazzini pedropazzini deleted the repeat branch March 10, 2018 22:26
@jorisvandenbossche
Copy link
Member

@pedropazzini Is there a reason that you closed this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants