w3resource

Pandas: Create a DataFrame from the clipboard

Pandas: DataFrame Exercise-79 with Solution

Write a Pandas program to create a DataFrame from the clipboard (data from an Excel spreadsheet or a Google Sheet).

Sample Excel Data:

Python Exercises: Sample Excel data.

Sample Solution :

Python Code :

import pandas as pd
df = pd.read_clipboard()
print("Data from clipboard to DataFrame:")
print(df)

Sample Output:

Data from clipboard to DataFrame:
   1  2  3  4
0  2  3  4  5
1  4  5  1  0
2  2  3  7  8

Python-Pandas Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Pandas program to replace the current value in a dataframe column based on last largest value. If the current value is less than last largest value replaces the value with 0.
Next: Write a Pandas program to check for inequality of two given DataFrames.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/python-exercises/pandas/python-pandas-data-frame-exercise-79.php