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
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 39 additions & 12 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1930,25 +1930,52 @@ def to_pickle(self, path, compression='infer',

def to_clipboard(self, excel=True, sep=None, **kwargs):
"""
Attempt to write text representation of object to the system 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 : boolean, defaults to 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 : 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

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.

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.

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
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`
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

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

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

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

comma-separated values (csv) file.

Notes
-----
Requirements for your platform
- Linux: xclip, or xsel (with gtk or PyQt4 modules)
- Windows: none
- OS X: none
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
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

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.to_clipboard(index=False)
"""
from pandas.io import clipboards
clipboards.to_clipboard(self, excel=excel, sep=sep, **kwargs)
Expand Down