Creating a Data Frame for Book Prices and Titles

Create a DataFrame from collected data and explore methods to scrape multiple result pages.

Efficiently structure scraped data into data frames using Python, and learn strategies for scaling your web scraping efforts.

Key Insights

  • Create structured data frames effectively in Python by transforming scraped data into dictionaries, making it easier to manage and analyze information.
  • After structuring your data, leverage powerful operations such as sorting by price or identifying the lowest-priced items for more insightful analysis.
  • Plan for larger-scale scraping tasks, considering that scraping all data across multiple pages—such as the total of 1,000 results mentioned—requires additional automation and iteration techniques.

This lesson is a preview from our Data Science & AI Certificate Online (includes software) and Python Certification Online (includes software & exam). Enroll in a course for detailed lessons, live instructor support, and project-based training.

Now that we've got all that data, let's put it into a data frame. And that's not really very easy. We can say books is pd.DataFrame and we'll make it from a little dictionary where we'll say the "Title" column is our titles from above, and the "Price" column is our prices from above.

And we'll say let's take a look at that books DataFrame. Here it is. It's looking pretty good.

Okay. Now we can do all kinds of work like finding the cheapest one or sorting them by price, all kinds of things we could do. Now what we want to do next is, right now we only have the first page, but there are 50 pages.

There are a total of 1,000 results, and we're currently looking at results 41 to 60. How can we scrape all of them? We'll start exploring that in the next video.

Colin Jaffe

Colin Jaffe is a programmer, writer, and teacher with a passion for creative code, customizable computing environments, and simple puns. He loves teaching code, from the fundamentals of algorithmic thinking to the business logic and user flow of application building—he particularly enjoys teaching JavaScript, Python, API design, and front-end frameworks.

Colin has taught code to a diverse group of students since learning to code himself, including young men of color at All-Star Code, elementary school kids at The Coding Space, and marginalized groups at Pursuit. He also works as an instructor for Noble Desktop, where he teaches classes in the Full-Stack Web Development Certificate and the Data Science & AI Certificate.

Colin lives in Brooklyn with his wife, two kids, and many intricate board games.

More articles by Colin Jaffe

How to Learn Data Science

Build practical, career-focused machine learning skills through hands-on training designed for beginners and professionals alike. Learn fundamental tools and workflows that prepare you for real-world projects or industry certification.