Python | Pandas dataframe.to_clipboard()
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
dataframe.to_clipboard() function copy object to the system clipboard. This function writes a text representation of the object to the system clipboard. This could be easily pasted into excel or notepad++.
Syntax: DataFrame.to_clipboard(excel=True, sep=None, **kwargs)
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 : For link to the CSV file used in the code, click here
Example #1: Use
to_clipboard() function to copy the object to the clipboard in a non-excel format.
Now we will copy this object to clipboard in a non-excel format.
We have simply pasted, what got copied to the clipboard after executing the previous command. The software used was “Notepad++”.
Example #2: Use
to_clipboard() function to copy the object to the clipboard in an excel format.
Now we will copy this object to clipboard in an excel format.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course