Skip to content

DOC: update the pandas.core.generic.NDFrame.to_clipboard docstring #20134

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 9 commits into from
Mar 13, 2018
Merged

DOC: update the pandas.core.generic.NDFrame.to_clipboard docstring #20134

merged 9 commits into from
Mar 13, 2018

Conversation

dandxy89
Copy link
Contributor

@dandxy89 dandxy89 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 pandas.core.generic.NDFrame.to_clipboard
  • The PEP8 style check passes: git diff upstream/master -u -- "*.py" | flake8 --diff
  • The html version looks good: python doc/make.py --single pandas.core.generic.NDFrame.to_clipboard
  • It has been proofread on language by another sprint participant

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

################################################################################
############# Docstring (pandas.core.generic.NDFrame.to_clipboard) #############
################################################################################

Copy object to the system clipboard.

Write a text representation of object to the system clipboard.
This can be pasted into Excel, for example.

Parameters
----------
excel : bool
    Default setting for this argument is True.
    If True, use the provided separator, writing in a csv format for
    allowing easy pasting into excel.
    If False, write a string representation of the object to the
    clipboard.
sep : str, default tab
    Field delimiter.
kwargs : optional
    These parameters will be passed to either
    :py:meth:`pandas.DataFrame.to_csv`
    or :py:meth:`pandas.Series.to_csv` methods depending on the
    Object type.

See Also
--------
pandas.core.frame.DataFrame.to_csv : Write a DataFrame to a
    comma-separated values (csv) file.
pandas.core.series.Series.to_csv : Write a Series to a
    comma-separated values (csv) file.

Notes
-----
Requirements for your platform.
  - Linux : `xclip`, or `xsel` (with `gtk` or `PyQt4` modules)
  - Windows : none
  - OS X : none

Examples
--------
Copy the contents of a DataFrame to the clipboard.

>>> df = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=['A', 'B', 'C'])
>>> df.to_clipboard()

We can omit the the index by passing the keyword 'index' and setting it to false.

>>> df.to_clipboard(index=False)

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

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.

@pep8speaks
Copy link

pep8speaks commented Mar 10, 2018

Hello @dandxy89! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on March 13, 2018 at 20:48 Hours UTC

other keywords are passed to to_csv
excel : bool
Default setting for this argument is True.
If True, use the provided separator, writing in a csv format for
Copy link
Contributor

Choose a reason for hiding this comment

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

@jorisvandenbossche I think we indenting or '-' here to separate these cases?

Copy link
Member

Choose a reason for hiding this comment

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

Depends on the context, in this case for True/False I think it is fine as sentences (but if there are more options certainly better to explicitly use lists)

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't think we have a policy. But I think

- True : use the provided separator,...
- False : ...

looks nice.

Field delimiter.
kwargs : optional
These parameters will be passed to either
:py:meth:`pandas.DataFrame.to_csv`
Copy link
Contributor

Choose a reason for hiding this comment

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

don't need the ':py:' prefix

@jreback jreback added Docs Output-Formatting __repr__ of pandas objects, to_string labels Mar 10, 2018
to the clipboard
sep : optional, defaults to tab
other keywords are passed to to_csv
excel : bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Default would go on this line. so bool, default True.


See Also
--------
pandas.core.frame.DataFrame.to_csv : Write a DataFrame to a
Copy link
Contributor

Choose a reason for hiding this comment

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

Just DataFrame.to_csv

--------
pandas.core.frame.DataFrame.to_csv : Write a DataFrame to a
comma-separated values (csv) file.
pandas.core.series.Series.to_csv : Write a Series to a
Copy link
Contributor

Choose a reason for hiding this comment

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

Just Series.to_csv

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Added some more comments

to the clipboard
sep : optional, defaults to tab
other keywords are passed to to_csv
excel : bool
Copy link
Member

Choose a reason for hiding this comment

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

please leave the default: bool, default True

other keywords are passed to to_csv
excel : bool
Default setting for this argument is True.
If True, use the provided separator, writing in a csv format for
Copy link
Member

Choose a reason for hiding this comment

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

Depends on the context, in this case for True/False I think it is fine as sentences (but if there are more options certainly better to explicitly use lists)

clipboard.
sep : str, default tab
Field delimiter.
kwargs : optional
Copy link
Member

Choose a reason for hiding this comment

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

kwargs : optional -> **kwargs

These parameters will be passed to either
:py:meth:`pandas.DataFrame.to_csv`
or :py:meth:`pandas.Series.to_csv` methods depending on the
Object type.
Copy link
Member

Choose a reason for hiding this comment

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

Since they actually have the same optional keyword, I would just refer to DataFrame.to_csv to keep it a bit shorter


See Also
--------
pandas.core.frame.DataFrame.to_csv : Write a DataFrame to a
Copy link
Member

Choose a reason for hiding this comment

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

pandas.core.frame.DataFrame.to_csv -> DataFrame.to_csv (same below)

would also refer to read_clipboard

>>> df.to_clipboard()

We can omit the the index by passing the keyword 'index' and setting
it to false.
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the leading space here.

>>> df = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=['A', 'B', 'C'])
>>> df.to_clipboard()

We can omit the the index by passing the keyword 'index' and setting
Copy link
Contributor

Choose a reason for hiding this comment

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

backticks for "index" instead of quotes

@dandxy89
Copy link
Contributor Author

@jreback ready for a review.

@TomAugspurger TomAugspurger added this to the 0.23.0 milestone Mar 13, 2018
@codecov
Copy link

codecov bot commented Mar 13, 2018

Codecov Report

Merging #20134 into master will decrease coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #20134      +/-   ##
==========================================
- Coverage   91.72%    91.7%   -0.03%     
==========================================
  Files         150      150              
  Lines       49156    49152       -4     
==========================================
- Hits        45090    45074      -16     
- Misses       4066     4078      +12
Flag Coverage Δ
#multiple 90.08% <ø> (-0.03%) ⬇️
#single 41.84% <ø> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/generic.py 95.84% <ø> (ø) ⬆️
pandas/plotting/_converter.py 65.07% <0%> (-1.74%) ⬇️
pandas/core/base.py 96.78% <0%> (-0.02%) ⬇️
pandas/core/series.py 93.85% <0%> (-0.01%) ⬇️
pandas/core/indexes/base.py 96.66% <0%> (-0.01%) ⬇️
pandas/core/indexes/multi.py 95.06% <0%> (ø) ⬆️

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 840d432...ea10208. Read the comment docs.

@TomAugspurger
Copy link
Contributor

Used the same trick as DtypeWarning for showing the "output" of to_clipboard.

Thanks @dandxy89!

@TomAugspurger TomAugspurger merged commit 74bf0d0 into pandas-dev:master Mar 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants