The Pandas function dataframe.to_clipboard()
copies the object to the system clipboard. This function writes the textual representation of the object to the system clipboard. This can be easily pasted into Excel or Notepad ++.
Syntax: DataFrame.to_clipboard (excel = True, sep = None, ** kwargs)
Parameters:
excel: 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.
sep: Field delimiter.
** kwargs: These parameters will be passed to DataFrame.to_csv.
Note: to link to the CSV file used in the code, click here
Example # 1: Use to_clipboard ()
to copy the object to the clipboard in the format, to_clipboard ()
Excel.
|
Output:
We will now copy this object to the clipboard in a non-Excel format.
|
Output:
We just pasted what was copied to the clipboard after the previous command. Notepad ++ software was used.
Example # 2: Use to_clipboard ()
to copy the object to the clipboard in Excel format.
|
Output:
Now we will copy this object to the clipboard in Excel format.
|
Output: