.html)
    * [ pandas.read_gbq ](pandas.read_gbq.html)
    * [ pandas.read_stata ](pandas.read_stata.html)
    * [ pandas.DataFrame.to_stata ](pandas.DataFrame.to_stata.html)
    * [ pandas.io.stata.StataReader.data_label ](pandas.io.stata.StataReader.data_label.html)
    * [ pandas.io.stata.StataReader.value_labels ](pandas.io.stata.StataReader.value_labels.html)
    * [ pandas.io.stata.StataReader.variable_labels ](pandas.io.stata.StataReader.variable_labels.html)
    * [ pandas.io.stata.StataWriter.write_file ](pandas.io.stata.StataWriter.write_file.html)
  * [ General functions ](../general_functions.html)
  * [ Series ](../series.html)
  * [ DataFrame ](../frame.html)
  * [ pandas arrays, scalars, and data types ](../arrays.html)
  * [ Index objects ](../indexing.html)
  * [ Date offsets ](../offset_frequency.html)
  * [ Window ](../window.html)
  * [ GroupBy ](../groupby.html)
  * [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * [ Input/output ](../io.html)
  * pandas.DataF... 

#  pandas.DataFrame.to_clipboard  #

DataFrame.  to_clipboard  (  _ *  _ , _ excel  =  True  _ , _ sep  =  None  _
, _ **  kwargs  _ )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/generic.py#L3173-L3247) #

    

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 True

    

Produce output in a csv format for easy pasting into excel.

  * True, use the provided separator for csv pasting. 

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

**sep** str, default ` '\t'  `

    

Field delimiter.

****kwargs**

    

These parameters will be passed to DataFrame.to_csv.

See also

[ ` DataFrame.to_csv  ` ](pandas.DataFrame.to_csv.html#pandas.DataFrame.to_csv
"pandas.DataFrame.to_csv")

    

Write a DataFrame to a comma-separated values (csv) file.

[ ` read_clipboard  ` ](pandas.read_clipboard.html#pandas.read_clipboard
"pandas.read_clipboard")

    

Read text from clipboard and pass to read_csv.

Notes

Requirements for your platform.

>   * Linux :  xclip  , or  xsel  (with  PyQt4  modules)
>
>   * Windows : none
>
>   * macOS : none
>
>

This method uses the processes developed for the package  pyperclip  . A
solution to render any output string format is given in the examples.

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

Using the original  pyperclip  package for any string output format.

    
    
    import pyperclip
    html = df.style.to_html()
    pyperclip.copy(html)
    

[ __ previous  pandas.read_clipboard  ](pandas.read_clipboard.html "previous
page") [ next  pandas.read_excel  __ ](pandas.read_excel.html "next page")

__ On this page

  * ` DataFrame.to_clipboard()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.to_clipboard.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.