Daily Dose of Data Science

Share this post

Create DataFrame Hassle-free By Using Clipboard

www.blog.dailydoseofds.com

Create DataFrame Hassle-free By Using Clipboard

Avi Chawla
Oct 31, 2022
2
Share

Many Pandas users think that a DataFrame can ONLY be loaded from disk. However, this is not true.

Imagine one wants to create a DataFrame from tabular data printed on a website. Here, they are most likely to be tempted to copy the contents to a CSV and read it using Pandas' ๐—ฟ๐—ฒ๐—ฎ๐—ฑ_๐—ฐ๐˜€๐˜ƒ() method. But this is not an ideal approach here.

Instead, with the ๐—ฟ๐—ฒ๐—ฎ๐—ฑ_๐—ฐ๐—น๐—ถ๐—ฝ๐—ฏ๐—ผ๐—ฎ๐—ฟ๐—ฑ() method, you can eliminate the CSV step altogether.

This method allows you to create a DataFrame from tabular data stored in a clipboard buffer. Thus, you just need to copy the data and invoke the method to create a DataFrame. This is an elegant approach that saves plenty of time.

Read more here: Pandas Docs.

View a video version of this post on LinkedIn: Post Link.

Thanks for reading Daily Dose of Data Science! Subscribe for free to learn something new and insightful about Python and Data Science every day. Also, get a Free Data Science PDF (250+ pages) with 200+ tips.


I like to explore, experiment and write about data science concepts and tools. You could connect with me on LinkedIn.

2
Share
Previous
Next
Comments
Top
New
Community

No posts

Ready for more?

ยฉ 2023 Avi Chawla
Privacy โˆ™ Terms โˆ™ Collection notice
Start WritingGet the app
Substackย is the home for great writing