Create DataFrame Hassle-free By Using Clipboard
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.