pyspark.pandas.Series.to_clipboard

Series.to_clipboard(excel: bool = True, sep: Optional[str] = None, **kwargs: Any) → None[source]

Copy object to the system clipboard.

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

Note

This method should only be used if the resulting DataFrame is expected to be small, as all the data is loaded into the driver’s memory.

Parameters
excelbool, default True
  • True, use the provided separator, writing in a csv format for allowing easy pasting into excel.

  • False, write a string representation of the object to the clipboard.

sepstr, default '\t'

Field delimiter.

**kwargs

These parameters will be passed to DataFrame.to_csv.

See also

read_clipboard

Read text from clipboard.

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 = ps.DataFrame([[1, 2, 3], [4, 5, 6]], columns=['A', 'B', 'C'])  
>>> df.to_clipboard(sep=',')  
... # Wrote the following to the system clipboard:
... # ,A,B,C
... # 0,1,2,3
... # 1,4,5,6

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

>>> df.to_clipboard(sep=',', index=False)  
... # Wrote the following to the system clipboard:
... # A,B,C
... # 1,2,3
... # 4,5,6

This function also works for Series:

>>> df = ps.Series([1, 2, 3, 4, 5, 6, 7], name='x')  
>>> df.to_clipboard(sep=',')  
... # Wrote the following to the system clipboard:
... # 0, 1
... # 1, 2
... # 2, 3
... # 3, 4
... # 4, 5
... # 5, 6
... # 6, 7