How to copy and paste a DataFrame to your clipboard

1 min

This is probably one of the most underrated ways to save your DataFrame.

The Pandas library does have a method that will copy your DataFrame to the system clipboard.

This is EXTREMELY useful when you want to quickly share it with someone.

Using this method you only will have to CTRL + V (CMD + V for Mac users) to paste the results anywhere.

Here is how to copy a DataFrame to the system clipboard.

# Import the Pandas library
import pandas as pd

# We create our example dataframe
df = pd.DataFrame({"col1" : range(0,10)})

# We copy the dataframe to your system clipboard
# To paste it, you will only need to CTRL + V or CMD + V for Mac users
df.to_clipboard()
How to copy the dataframe to your system clipboard

Here you are! You now know how to copy a DataFrame to the system clipboard!

More on DataFrames

If you want to know more about DataFrame and Pandas. Check out the other articles I wrote on the topic, just here :

Pandas - The Python You Need
We gathered the only Python essentials that you will probably ever need.