Skip to content

DOC: update the DataFrame.plot.line docstring #20163

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

Merged
merged 7 commits into from
Mar 12, 2018

Conversation

ifosch
Copy link
Contributor

@ifosch ifosch commented Mar 10, 2018

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

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

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


################################################################################
#################### Docstring (pandas.DataFrame.plot.line) ####################
################################################################################

Plot DataFrame columns as lines.

This function is useful to plot lines using DataFrame's values
as coordinates.

Parameters
----------
x : int or str, optional
    Columns to use for the horizontal axis.
    Either the location or the label of the columns to be used.
    By default, it will use the `DataFrame` indices.
y : int, str, or list of them, optional
    The values to be plotted.
    Either the location or the label of the columns to be used.
    By default, it will use the remaining DataFrame numeric columns.
kwds : optional
    Keyword arguments to pass on to :py:meth:pandas.DataFrame.plot.

Returns
-------
axes : :class:matplotlib.AxesSubplot or :class:numpy.ndarray of
       them.

See Also
--------
matplotlib.pyplot.plot : Plot y versus x as lines and/or markers.

Examples
--------

.. plot::
    :context: close-figs

    The following example shows the populations for some animals
    over the years.

    >>> df = pd.DataFrame({
    ...    'pig': [20, 18, 489, 675, 1776],
    ...    'horse': [4, 25, 281, 600, 1900]
    ...    }, index=[1990, 1997, 2003, 2009, 2014])
    >>> lines = df.plot.line()

.. plot::
    :context: close-figs

    The following example shows the relationship between both
    populations.

    >>> lines = df.plot.line(x='pig', y='horse')

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

Docstring for "pandas.DataFrame.plot.line" correct. :)

If the validation script still gives errors, but you think there is a good reason
to deviate in this case (and there are certainly such cases), please state this
explicitly.

Line plot
Plot `DataFrame` columns as lines.

This function is useful to plot lines using `DataFrame`'s values
Copy link
Contributor

Choose a reason for hiding this comment

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

I think sphinx complains if you do you have something right after a `. Just do DataFrame without the backticks.


This function is useful to plot lines using `DataFrame`'s values
as coordinates.
It allows to specify which columns to use for the axes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can remove this line since we discuess that in the parameters section.

x, y : label or position, optional
Coordinates for each point.
`**kwds` : optional
x : int, str, list of int or list of str, optional
Copy link
Contributor

Choose a reason for hiding this comment

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

I think x has to be an int or str. Lists are not allowed for x, just y.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We tested on Jupyter and these seem to be allowed. However, the result makes not much sense. I'm changing this, anyway.

Coordinates for each point.
`**kwds` : optional
x : int, str, list of int or list of str, optional
It defines the X axis coordinates.
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove "it". Just have "Column to use for the horizontal axis." and then the rest of your description.

It defines the X axis coordinates.
Either the location or the label of the columns to be used.
By default, it will use the `DataFrame` indices.
y : int, str, list of int or list of str, optional
Copy link
Contributor

Choose a reason for hiding this comment

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

I thin we write this as int, str, or list of them, optional.

Either the location or the label of the columns to be used.
By default, it will use the `DataFrame` indices.
y : int, str, list of int or list of str, optional
It defines the values to be plotted.
Copy link
Contributor

Choose a reason for hiding this comment

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

"The values to be plotted."

y : int, str, list of int or list of str, optional
It defines the values to be plotted.
Either the location or the label of the columns to be used.
By default, it will use the remaining `DataFrame` columns.
Copy link
Contributor

Choose a reason for hiding this comment

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

No backticks. Specify that it's the remaining numeric columns.

Keyword arguments to pass on to :py:meth:`pandas.DataFrame.plot`.

Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.AxesSubplot` or :meth:`np.array` of
Copy link
Contributor

Choose a reason for hiding this comment

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

:meth:np.array -> ndarray. I don't care either way about the sphinx markup so either

:class:numpy.ndarray

or

numpy.ndarray

The following example shows the relationship between both
populations.

>>> lines = df.plot.line('pig', 'horse')
Copy link
Contributor

Choose a reason for hiding this comment

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

Specify x='pig', y='horse'

@ifosch ifosch force-pushed the docstring-plot-line branch from b58be42 to 69455a4 Compare March 11, 2018 00:21
@ifosch
Copy link
Contributor Author

ifosch commented Mar 11, 2018

Fixes are up now

@codecov
Copy link

codecov bot commented Mar 11, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@f85ae92). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #20163   +/-   ##
=========================================
  Coverage          ?   91.72%           
=========================================
  Files             ?      150           
  Lines             ?    49152           
  Branches          ?        0           
=========================================
  Hits              ?    45086           
  Misses            ?     4066           
  Partials          ?        0
Flag Coverage Δ
#multiple 90.11% <ø> (?)
#single 41.84% <ø> (?)
Impacted Files Coverage Δ
pandas/plotting/_core.py 82.23% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f85ae92...75b1a22. Read the comment docs.

Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

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

Pushed a couple small updates.

Will wait to see if anyone else has thoughts, otherwise ready to merge.

@ifosch
Copy link
Contributor Author

ifosch commented Mar 12, 2018

Thanks @TomAugspurger !

@TomAugspurger TomAugspurger merged commit 5d35f0f into pandas-dev:master Mar 12, 2018
@TomAugspurger
Copy link
Contributor

Thank you!

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

Successfully merging this pull request may close these issues.

2 participants