Building dataset - p.4 Data Analysis with Python and Pandas Tutorial

sentdex · Beginner ·🛠️ AI Tools & Apps ·10y ago

Key Takeaways

The video tutorial demonstrates data analysis with Python and Pandas, utilizing tools like Quondo and Pandas to retrieve and manipulate housing price index data for all 50 US states. It covers importing modules, generating Quondo code, authenticating with API keys, and extracting data from Wikipedia pages using pandas.read_html().

Full Transcript

hello everybody and welcome to part four of data analysis with python and pandas in this tutorial what we're going to be doing is beginning to build our data set for a real estate analysis so to start uh we're going to come over here to quondo and now you will need to sign up make an account you don't actually need to at this point but B by the next video you will and the code is going to include code that will require an account as well as um we're going to need the quondal module so to get the quondal module you can either install it from you know their website or again you can go pip install quondo simple as that once you have quondo you're able to use quandle doget and you can get and then use a little ticker and boom you're done so let's say we're looking for um housing price index we search we wait and we get this Freddy Mac database and then in here you can already see we've got house price index for Alaska Alabama Arkansas and so on so we click more from this database and this is the housing price index basically for every state at first anyways and then there's some other information here too now what if we wanted to grab the housing price index for every single state because the idea is that uh the housing markets are probably all going to follow each other okay so um there might be some Divergence and then there might be some laggards and there might be some uh leaders right but what ends up happening is every time there's any Divergence as far as at least directionally uh we're concerned we almost pretty much promis that we're going to get back to the mean okay of of the housing price in uh index so the idea first is to confirm that hypothesis so the hypothesis is that all housing markets follow the same path they might have a different um see magnitude of that path right so if if one market goes up they all go up or if most markets go up a specific Market is going to go up maybe not by the same degree but it's going to have to go up so here we're saying they're definitely at least correlated to some degree but we need to be able to test that and find out if that's even true we believe that to be true but we want to make sure so we want to pull every single um housing price index but we're not going to go through here by hand click Alaska download click Alabama download and then we're also you know right now we've got a list of 50 states that we would need to use and I mean we could type them all out by hand but that's going to be kind of annoying so instead what we're going to do is like let's click Alaska and we can already see up here the it's hpia a but we can also see the quondo code over here f Mac HPI a and you could also click on Python and get the quondal doget now if we scroll down the other thing you'll note uh that we'll kind of show later on though is like let's say you don't want all the way back to 1975 like you could modify this to be uh 1999 okay and then when you go to now that you've changed that when you go to click python it's going to add that trim uh and that makes the data that it's returned to you start at $ 1999 which is pretty ni anyway so we know this is the Quanto code and what we want to do is find a list of the United States and just automatically generate this quantal code uh rather than typing it out by hand like all the 50 states so uh the first step we're going to come over here and we're going to go ahead and first import quondal that's the quondo module that we had uh had you install right away and then of course import pandas as PD now when you make an account on quondo you can go to your um you know your little name uh and then go to API or something like that and it'll have your API key there you can write your API key in your script I'm just not going to because I don't want everybody to use my key so I'm just going to have API key equals open and I've put a little file in here called quondal API key. text the intention to read and then. read and now that's my API key again you don't need to do that if you don't wanted to next I'm going to say DF equals qu. getet and we can throw in basically this right here so we could say get fmac HPI for Alaska and then uh we'll do um wonder what I always thought AK was for aransa but I guess I'm wrong maybe it's a for organsa anyway moving on off token equals API key and uh that's that then we can print DF head and we'll get a returned data frame in a moment now you'll see uh that we have the date here and it's already being treated as the index which is pretty nifty if you're using the quondal uh module you'll have um the automatic assignment there of the in index now I'm going to close out of this and now what we want is the uh a list of the 50 states so let's just do um 50 USA States abbreviations or something like this um and then yeah so you come over here 50 US States abbreviations and eventually you find the Wikipedia page so we would click on that and we're kind of like looking around and here we go go we've got quite a few um looking is this I'm trying to think if this is the one that I actually used list of this one's US state abbreviations but the one I was looking for is actually just the US state so let's see let's do us 50 US [Music] states I want that with simple let's see maybe this is it yeah there we go so list of US states and it's this nice table with the abbreviations in it easy yeah AR for AR so had to figure that one out anyway moving this over so what we want to do is we want to read the table from here so we could use Python and regular expressions and split out this table or we could use something like beautiful soup or something but we want a table and this is a pandas tutorial and we actually happen to have read HTML so let's do it so moving this over we are going to say fit States in equals pd. read HTML and we want to read this link copy that over here paste now when you read HTML this puts the information into a list of data frames even though there's only one table it's going to make like multiple attempts at reading this table it might also read this little list here and it'll probably read this kind of table here so you think like oh there's only one table here I promise there's more than one table and it's going to find it so fit States will be a list of data frames okay so we can at first print F States and I'm going to go ahead and comment the these two lines out we don't need those two lines so let's save and run that real quick yeah so there you go you got a bunch of junk in here we can pretty much deduce that each like uh you know this right here this is the beginning of a list you see the square brackets then you've got data frame one would be here and then data frame number two and so on so data frame one would have the index value of a zero so it looks like the First Data frame is the one that we want that's index zero so we can close out of this and we can say instead of F50 States we can say we want fit States zero right so at the moment fit States alone and in fact let's just do this let's say this this is a list then copy that paste uh 50 states zero this is a data frame right so now we're going to print F State 0 now 50 state 0 is a data frame of its own and then what are we looking for Well turns out we're looking for column zero so that's a column which will output to us basically a series so let's copy this paste and again so now we want column zero so zero this is a column fantastic and now of column zero we want everything from element one onward because element zero is abbreviation or you know index Z is abbreviation so what do we do now now we say for abbv for abbreviation um what do we want to do infi states 0 0 one colon we are going to print and we're going to just print it out just to see that we got it right fmac HPI uncore plus string version should already be a string but just in case abbv okay so now save and run that and here are all of the basically uh I don't know what to call it ticker or whatever the API name that we want a query for right so Alabama Alaska Arizona Arkansas California Colorado Connecticut and so on all the way down the list so now we've got that now all we need to do is create new data frames based on these and begin kind of adding them together so we've got a lot of stuff that we're actually going to have to cover in order to add them together we have to first learn how to actually concatenate and combine data frames so in the next tutorial we'll be talking about how you go about combining data frames whether they share an index or not combining them on columns and all kinds of stuff it's pretty uh there's a lot of options that we can do here uh obviously because there's a lot of ways you would combine data frames right so anyways that's what we'll be doing in the next tutorial questions comments below otherwise as as always thanks for watching thanks for all the support and subscriptions and until next time

Original Description

In this part of Data Analysis with Python and Pandas tutorial series, we're going to expand things a bit. Let's consider that we're multi-billionaires, or multi-millionaires, but it's more fun to be billionaires, and we're trying to diversify our portfolio as much as possible. We want to have all types of asset classes, so we've got stocks, bonds, maybe a money market account, and now we're looking to get into real estate to be solid. You've all seen the commercials right? You buy a CD for $60, attend some $500 seminar, and you're set to start making your 6 figure at a time investments into property, right? Okay, maybe not, but we definitely want to do some research and have some sort of strategy for buying real estate. So, what governs the prices of homes, and do we need to do the research to find this out? Generally, no, you don't really need to do that digging, we know the factors. The factors for home prices are governed by: The economy, interest rates, and demographics. These are the three major influences in general for real estate value. Now, of course, if you're buying land, various other things matter, how level is it, are we going to need to do some work to the land before we can actually lay foundation, how is drainage etc. If there is a house, then we have even more factors, like the roof, windows, heating/AC, floors, foundation, and so on. We can begin to consider these factors later, but first we'll start at the macro level. You will see how quickly our data sets inflate here as it is, it'll blow up fast. So, our first step is to just collect the data. Quandl still represents a great place to start, but this time let's automate the data grabbing. We're going to pull housing data for the 50 states first, but then we stand to try to gather other data as well. We definitely dont want to be manually pulling this data. First, if you do not already have an account, you need to get one. This will give you an API key and unlimited API requests to the free da
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from sentdex · sentdex · 0 of 60

← Previous Next →
1 Matplotlib Python Tutorial Part 1: Basics and your first Graph!
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
2 Python Encryption Tutorial with PyCrypto
Python Encryption Tutorial with PyCrypto
sentdex
3 Python's Logging Function
Python's Logging Function
sentdex
4 wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
5 wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
6 wxPython Programming Tutorial 3: Menu Bar and Menu Button
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
7 wxPython Programming Tutorial 4: Panels
wxPython Programming Tutorial 4: Panels
sentdex
8 wxPython Programming Tutorial 5: User Input Saved To Variables
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
9 wxPython Programming Tutorial 6: Multiple Choice Input
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
10 wxPython Programming Tutorial 7: Adding Static Text and Colors
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
11 wxPython Programming Tutorial 8: Custom Button Images
wxPython Programming Tutorial 8: Custom Button Images
sentdex
12 wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
13 Basic PHP Tutorial 13: Multi-dimensional Array
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
14 Basic PHP Tutorial 15: Functions and Global Variables
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
15 Basic PHP Tutorial 12: Associative Array
Basic PHP Tutorial 12: Associative Array
sentdex
16 Basic PHP Tutorial 14: Foreach loop
Basic PHP Tutorial 14: Foreach loop
sentdex
17 Basic PHP Tutorial 16: Include and Require
Basic PHP Tutorial 16: Include and Require
sentdex
18 Basic PHP Tutorial 7: Assignment, comparison and Logical operators
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
19 Basic PHP Tutorial 4: Variables and Comments
Basic PHP Tutorial 4: Variables and Comments
sentdex
20 Basic PHP Tutorial 11: Arrays part 1, basic array
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
21 Basic PHP Tutorial 6: If else and else if conditionals cont'd
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
22 Basic PHP Tutorial 1: Intro to PHP
Basic PHP Tutorial 1: Intro to PHP
sentdex
23 Basic PHP Tutorial 3: HTML with PHP
Basic PHP Tutorial 3: HTML with PHP
sentdex
24 Basic PHP Tutorial 9: While Loop
Basic PHP Tutorial 9: While Loop
sentdex
25 Basic PHP Tutorial 10: Switch Statement
Basic PHP Tutorial 10: Switch Statement
sentdex
26 Basic PHP Tutorial 2: Print and Echo
Basic PHP Tutorial 2: Print and Echo
sentdex
27 Basic PHP Tutorial 5: If else and else if conditional statements
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
28 Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
29 Basic PHP Tutorial 17: User Input Form Example / String Manipulation
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
30 Basic PHP Tutorial 18: HTML Entities and forms cont'd
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
31 Basic PHP Tutorial 19: Finding words in strings
Basic PHP Tutorial 19: Finding words in strings
sentdex
32 Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
33 Basic PHP Programming Tutorial 22: Hashing part 2: salting
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
34 Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
35 Basic PHP Programming Tutorial 21: MD5 Hashing For Security
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
36 Basic PHP Programming Tutorial 24: String similarity
Basic PHP Programming Tutorial 24: String similarity
sentdex
37 Basic PHP Programming Tutorial 25: Time and Time stamps
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
38 Basic PHP Programming Tutorial 26: Die and Exit
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
39 Basic PHP Programming Tutorial 27: MySQL Databases Part 1
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
40 Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
41 Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
42 Basic PHP Programming Tutorial 30: MySQL database in Use
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
43 Django Tutorial Web Development with Python Part 1: Installing Django
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
44 Python Tutorial: File Deletion and Folder Deletion / directory deletion
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
45 Python Tutorial: How to Rename Files and Move Files with Python
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
46 3D Graphs in Matplotlib for Python: Basic 3D Line
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
47 3D Plotting in Matplotlib for Python: 3D Scatter Plot
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
48 3D Charts in Matplotlib for Python: Multiple datasets scatter plot
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
49 Sikuli Tutorial 1: Visually programming in python!
Sikuli Tutorial 1: Visually programming in python!
sentdex
50 Sikuli Tutorial 2: Program visually in python!
Sikuli Tutorial 2: Program visually in python!
sentdex
51 Sikuli Tutorial 3: Program visually in python!
Sikuli Tutorial 3: Program visually in python!
sentdex
52 3D Bar Charts in Python and Matplotlib
3D Bar Charts in Python and Matplotlib
sentdex
53 3D Plane wire frame Graph Chart in Python
3D Plane wire frame Graph Chart in Python
sentdex
54 Raspberry Pi Part 1 Introduction
Raspberry Pi Part 1 Introduction
sentdex
55 Raspberry Pi Part 8: First Download and Update! (Firmware)
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
56 Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
57 Raspberry Pi Part 11: Remote Desktop
Raspberry Pi Part 11: Remote Desktop
sentdex
58 Twitter Analysis: How to rank a user's influence
Twitter Analysis: How to rank a user's influence
sentdex
59 GPIO Tutorial for Pi Part 2 - Programming the GPIO
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
60 GPIO Tutorial for Raspberry Pi Part 1 - Setting up
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex

This video tutorial teaches data analysis with Python and Pandas, covering topics like data retrieval, manipulation, and visualization. It demonstrates how to use tools like Quondo and Pandas to build datasets and extract insights from housing price index data. By following this tutorial, viewers can learn how to work with APIs, authenticate with API keys, and perform data analysis tasks.

Key Takeaways
  1. Import Quondo module
  2. Import Pandas module
  3. Generate Quondo code for all 50 US states
  4. Use API key to authenticate with Quondo
  5. Download housing price index data from Quondo database
  6. Read API key from text file
  7. Use API key for authentication
  8. Read HTML table from Wikipedia page
  9. Extract column zero from data frame
  10. Print series from column zero
💡 The tutorial highlights the importance of data analysis and manipulation in extracting insights from large datasets, and demonstrates how to use tools like Quondo and Pandas to achieve this.

Related AI Lessons

How to Create a Second Version of Yourself Inside Obsidian Using AI (Step-by-Step Guide)
Learn to create a second version of yourself inside Obsidian using AI with a step-by-step guide
Medium · ChatGPT
How to prepare for Spain civil service TIC exam using AI in 2026
Learn how to prepare for the Spain civil service TIC exam using AI in 2026, boosting your chances of success with technology-driven study techniques
Dev.to · David García
Going Viral! How I Created AI Kissing Videos Step by Step Easily Using AIAI.com
Create viral AI kissing videos using AIAI.com in a step-by-step process, leveraging AI technology for creative content creation
Medium · AI
How to prepare TIC teacher exams in Spain with AI (oposiciones 2026)
Prepare for TIC teacher exams in Spain using AI with these actionable steps
Dev.to AI
Up next
Low-Tech, High-Impact: Replacing Your Receptionist With a $15 AI Phone System
Maximum Lawyer
Watch →