📱

Get Our Mobile App

Take your business learning on the go!

Download on the App StoreGet it on Google Play

Data Analyst Bootcamp for Beginners (SQL, Tableau, Power BI, Python, Excel, Pandas, Projects, more)

freeCodeCamp.org19:23:46

Transcription

You are in the right place to learn to become a data analyst in this massive boot camp. Alex the analyst will cover all the core topics that data analysts need to know, and along the way, you'll build plenty of projects to gain hands-on experience.

Hello everybody. My name is Alex Freeberg, better known as Alex the analyst on YouTube, and in this video, you're going to be taking my entire data analyst boot camp. This boot camp is comprised of videos that I've made over the past 3 years, and they cover a lot of different topics like SQL, Excel, Power BI, Tableau, and Python. Throughout the boot camp, there are a lot of hands-on, guided projects that will really help you learn these skills well.

And speaking of projects, there's an entire part near the end where you can build a free portfolio website where you can put all of your projects on so that hiring managers and recruiters can go and look at all these projects that you've built. If you wanted to go even more in depth into the skills that we learn in this boot camp, I have a data analytics learning platform called Analyst Builder. Analyst Builder was designed specifically for data analysts, so all of the courses and all the content are just for you, and it has a coding section where you can learn and practice for technical interviews.

Lastly, before we jump into the boot camp, I want to give a huge shout out to Free Code Camp for putting this all together. I personally learned a ton from Free Code Camp, and so I'm really honored that my boot camp is going to be here for you guys to learn, and I really hope you enjoy it.

What's going on everybody? It is 2023, and in this video, I'm going to help you become a data [Music] analyst. We're going to start at the very beginning, assuming you haven't started this process at all of becoming a data analyst. If you already have, you can kind of find, identify where you are in this process and then go from there.

Now, before we dive into everything, I want to warn you: I will be mentioning my own channel a lot in this video. I have videos and playlists on just about every single topic that we're going to be talking about today. I'll have all the links to those videos in the description so you can dive into those topics more in depth. So I hope that's okay, and it's all completely free. I've been building this out for the past 3 years, and honestly, you can probably get 90% of the way to learning everything you need for data analytics just on my channel. So now that I've warned you, let's begin.

Number one: and that is learn the data analyst skills. Now there are literally a hundred different things that you can learn for data analytics. You can learn things like Alteryx or a cloud platform or different programming languages, but there are some core skills that I recommend you start out with before kind of branching into some of those other skills.

The number one skill that I always recommend people start with is SQL. SQL is just one of those fundamental skills I think everybody should learn, even if you don't use SQL; you'll use some variation of SQL if your company has a large enough data set. SQL is used to actually query and retrieve data from a database. So if your company collects data, which every company does, they're going to put it somewhere to store it; it's usually stored in a database, and SQL is how you get that data from the database. I think SQL is also fairly easy to learn, which makes it really good when you're just starting out. I have several playlists dedicated to SQL, starting from beginner all the way to advanced, and you can learn all of that for free.

One other reason why I think you should learn SQL first is that a lot of companies interview or have a technical interview during the interview process on SQL. That's something that really caught me off guard when I was first starting out because I thought it was going to be more behavioral; I didn't even know what a technical interview was. So knowing SQL actually became a really important part of interviewing and getting a job as a data analyst.

The second skill that I would learn is a business intelligence tool like Tableau or Power BI. Now there are a ton of different BI tools; I can literally name 10 off the top of my head that I've used throughout my career. But what I will say is that learning something like Tableau or Power BI is pretty transferable to almost all those other BI tools; they're all fairly similar in how they do things and how they show, display the data. You most likely won't have a technical interview asking you about Tableau or Power BI like to build something for them; that usually does not happen. But the combination of SQL, where you can query your data, and then taking that data to build something, that is a really, really great combination to learn right away. I have entire series on both Tableau and Power BI with projects on my channel.

The third skill that I would learn is Excel. Now most people have used Excel; they know what Excel is and how it's used, but it can be used a little bit differently for a data analyst. For example, example, in Excel, a lot of people haven't cleaned data in Excel or built charts and graphs using Excel, and those are things that data analysts would probably do. Excel is also just a fundamental skill that every company is going to expect you to know. So I have an entire playlist dedicated to Excel to actually walk you through how to use it for data analysis.

The fourth skill that I recommend you learn is Python. Now a lot of people will have Python higher up on their list; they only use Python; they don't use SQL or a BI tool; they just do everything in Python. Now Python is a fantastic tool; you can use it to manipulate your data, to create data visualizations, and a ton more like web scraping and regular expression and a hundred different other things. But it can be kind of hard to learn; it took me a long time to really learn the basics very well. That's really the only reason why it is farther back. I feel like SQL and a BI tool are really easy to learn and really pack a big punch, whereas Python can be quite tough to learn in my experience, and you may not use it as often as you would something like SQL or a BI tool. If you're interested in learning Python, I have an entire series dedicated to Python as well as projects that you can build.

Again, I warned you: there's going to be a lot of self-promotion in this video. I have videos on just about every single one of these topics.

The fifth and the last skill that I recommend you learn—and this is the only one that I don't have a series on yet; I will make those—is learning a cloud platform like AWS, Google Cloud Platform, or Azure. There's no denying that these platforms have played a huge impact in how we use data as a whole in the data analyst industry. They can be kind of tough to learn though if you aren't using it hands-on in an actual job. I think that learning a cloud platform is already something that most people should start working towards because in the future, it's only going to become more prevalent.

Now, where can you go and actually learn all of these skills that you need to become a data analyst? Well, the number one place I'd recommend, of course, is my channel. I have free tutorials on all these skills and a lot of other topics, and I think it's just a really great place to start.

The next place that I recommend you looking at is Udemy. I recommend Udemy especially if you're just starting out because it's pretty, pretty cheap. You can buy an entire course, entire SQL course for $10 or $15, and they have courses on every single one of these skills. And I just recently made a video called DIY Data Analyst's Curriculum Using Udemy for Under $75, so you can create an entire curriculum to learn all of these skills for under $75, which is just amazing.

The next place I'm going to recommend you look is Coursera. Now Udemy is fantastic; they have really good instructors and good courses, but as a whole, I find that sometimes Coursera just has more professional or better content. Coursera is a bit more expensive though; you're looking at $59 per month for all of their courses, or you can pay upfront an annual fee of $399. So again, it's just a lot more expensive. I moved to Coursera once I started having a data analyst job and had a bit more money, but when I was first starting out, I just couldn't afford it, so I went to Udemy, and it was a really great place to start.

There's also places like DataCamp and DataQuest that kind of gamify learning, and they're more text-based. So all these other platforms—Udemy, Coursera, and me—they're all video-based, but if you like reading, DataCamp and DataQuest are a lot more text where you can learn it by reading it and doing it.

After you learn all of these skills, the next thing that I recommend you do is actually build projects with those skills. Now what is building a project actually mean? It means taking a skill and then building something out of it that you can then show a potential employer. For example, if you went through and learn Tableau, you go and take a data set, and you could build a visualization and a dashboard in Tableau, and that would be a project. With these projects, you can build something called a portfolio, and I usually call it a portfolio website. A portfolio website is a website that you create where you store all of your projects, and then you can share that with recruiters and hiring managers so that they can see all of your work.

Now, do you absolutely need a portfolio to show employers? No, you don't, but it does help in two different ways. The first thing that it may do is actually help you land the interview. If you have a link on your resume and they click on it, they may see your skills and see your projects and be like, "Man, this person really knows what they're doing; this is exactly what we need."

The second reason that I recommend building projects is because most likely during your interview, you're going to get asked questions like, "How have you used SQL? How have you used Tableau?" And if you don't have any experience in that, you're just going to say, "Well, you know, I've taken courses to learn it." But with a project, you can be a lot more specific. You'll be able to say, "Well, I actually just built out this project in Tableau; I took the data and cleaned it in Excel, and then I put it in Tableau and built out this dashboard, and here are the insights that I found from this data set." It's just a much better answer, and as a hiring manager myself, I can tell you that it is definitely beneficial to build out these projects.

The next step that I recommend you take in becoming a data analyst is building a data analyst resume. The resume, to say the least, is extremely important; it's what's going to actually allow you to land an interview to potentially get a job. Now, if you were like me when I was first starting out, I had a resume; it just had nothing to do with data analytics. So how do you make a data analyst resume if you don't have any experience as a data analyst? Well, you are asking the perfect questions because the very first things that we talked about are what are going to go on your resume: those skills and those projects. If you have no experience or degree, like myself, who has a recreational therapy degree—if you have no background in this, it can be really daunting to kind of display that you know what you're doing and that a company should hire you. So what I usually recommend is, right beneath your contact at the top, you put your skills and your projects that you built out on your resume. Things like work experience and education should go on your resume as well, but just a little bit lower. You want them to see those things before they see that your last work experience was at Domino's and you have a degree in Marine Biology; it's just not relevant to data analysis, and if you put those things at the top, they're probably going to rule you out right away.

The fourth step to become a data analyst is actually applying. You have the skills, you have the projects, you have the resume; now you're ready to start applying for those data analyst jobs. Now there's, there's a lot of different opinions on how you need to go about applying for data analyst jobs, but I'll give you my take on it, and this has been the most successful for me in my career.

The first thing I want to mention is actually what I would not do, which is just blindly apply on Glassdoor, Monster, ZipRecruiter, and all these other platforms to just any data analyst job that you can find. Now I'm not against this; I think you should do that, but I don't think that's the only thing that you should do because the chances of you getting a call back or actually hearing something back are extremely low. To really increase your chance of becoming a data analyst, I highly, highly, highly recommend working with a recruiter. A recruiter is literally someone who is there to help you find a job. Now when I first started out, I didn't understand what a technical recruiter was at all; I was kind of nervous or scared to work with them, but it's actually pretty simple. A company has a position that they want to fill, and they don't want to spend hours and hours and hours to find someone to fill that position, so they hire a recruiter. A recruiter is going to go out and try to find someone to fill that position—AKA you. And so if you go in to talk to that recruiter and they have a position that opens up, they will help you get that interview, and then if you get a job, let's say for $50,000, the company is going to pay that recruiter, let's say 10% of your salary, so they'll give them $5,000. So you don't actually lose or have anything to lose using a recruiter. You can reach out to recruiters in several ways, and I've done every variation, but I'll tell you my most successful way, which was using LinkedIn. There are tens of thousands of recruiters on LinkedIn. I made an entire video of how you can reach out to recruiters and what to say to recruiters on LinkedIn to help you land a job, so be sure to check out that video when you actually get to that point. But you can also just cold email and cold call these recruiting companies, but to me, it's just not as effective as reaching out directly on LinkedIn.

And this is just a bonus one: the last thing that you need to do is accept a job offer. So on step number four, after you apply to those jobs, you do actually have to go in, interview, and then get a job offer, which you will accept. I just thought I'd mention that just in case that was not super clear.

Now that was a lot of stuff. Let's talk about time frames to actually complete all of these things. Now doing all of these things from scratch is going to take a while, but let's break it down by each step and see how long I generally think it's going to take.

Let's start with step number one, which is actually learning the skills. Now, just to be up front, this one probably is going to take the longest for most people. For most people to learn all of these skills, it's going to take around 3 to 4 months. Now if you don't learn a cloud platform and Python, which are the last ones that I recommend, and you just focus on SQL, a BI tool, and Excel, I think you can do that in under 3 months. That is very dependent though on how much time you have to study. That time frame is more for someone who has several hours per day, maybe 3 hours in the end of a night after you go to work; that is someone who has quite a bit of time to dedicate to learning during their week. Of course, that time frame is going to take longer if you don't have as much time to dedicate to learning.

Now let's look at number two, which was creating projects and a portfolio of projects. From my experience, when you're first starting out, it takes a lot longer to actually create these projects; it can take one, one or two weeks per project. I usually recommend people doing three to five projects in their portfolio before they start applying, and since they can take anywhere from 1 to 2 weeks, you're looking at anywhere from 3 to 6 weeks.

The next step was to create a data analyst resume. Now, in my opinion, this one should take the shortest out of every single step here because you're really just kind of reformatting a resume or creating a resume; you're just adding skills, you're adding your projects, and then kind of reformatting it to make it look nice. This should hopefully take under a week, but if you use something like a professional service so they help you build a resume, it could take one to two weeks.

The two last steps, which kind of go hand in hand, are step four and five, which is actually applying for jobs and then landing a job. Now this process can take as little as a month, or it can take as long as 6 months or a year. It really depends on how you're applying, where you're applying, and just the kind of luck that you're having with actually landing interviews. I've seen people who have never had any experience land a job within a month of starting to apply, and it's incredible; it's amazing, but it doesn't happen too often. You're usually looking at around 2 to 4 months on average to land your first data analyst job.

If you put all of those together and kind of average everything out, you're looking at around 6 months total for the entire process. Now I don't want that to discourage you, okay? 2023 is a long year; you have a lot of time, and it doesn't have to take 6 months; you could do it faster; you could do it in 3 months and just prove me wrong. But if you are really focused and you are really driven to become a data analyst this year, I know that you can do it.

Now, to maybe boost your spirits and make you feel a little bit better, I didn't know any of these things when I first started out. I didn't have anyone telling me kind of a plan on what to do; I had to go out and figure all these things out by myself, and it took me almost a year to land my first real data analyst job.

So with all that being said, I hope that this video is helpful. I hope you now have a path on how to become a data analyst this year, and that my channel can be a big part of that. So thank you guys so much for watching; I really appreciate it. If you like this video, be sure to like and subscribe below, and I'll see you in the next video. [Music]

What's going on everybody? My name is Alex Freeberg, and in today's video, we're going to be starting our basics of SQL series. Now in this series, we're going to be going over everything you need just to get started, and then in future videos, we're going to be going over some intermediate concepts and some more advanced concepts, and then in the final series, we're going to be going over some portfolio projects.

In this video in particular, we're going to be downloading SQL Server Studio; we're going to be creating our tables, inserting data into our tables, and in future videos, we're going to actually learn how to query those tables. If you already have SQL Server Management Studio downloaded, you can skip ahead to where we actually create the tables and insert the data into the tables. If you don't care about that at all and you're just looking at a query, I would skip to the next video where we actually start querying the data that we inserted into those tables.

So to download SQL Server Management Studio, we actually have to download two things, and I have both links right here. I'm going to leave those in the descriptions that you guys have those, but this one is to actually download SQL Server Management Studio. So let's go down here; I actually deleted it off my computer so I can walk through this with you guys. So we're going to download that. Let's also go over here; this is actually a server, so we have to download a SQL server, and if you go down right here, there's a free version. Now I don't need the developer version; I'm just going to download the express version; it's actually smaller. So let's…

Download that as well now. Once this is done running, we're going to open it up, and I'll show you what to do next. So it just finished running; let's click on it. All right, so we need to install it. We're going to click yes, and this is going to take a little while. So this popped up; I clicked install, and it's been running for the past couple of minutes. Apparently, I was not recording, so I apologize for that, but that's all I did. So now it's been installed. I'm actually going to pull it up right here, and let's open it up. Now, when it pulls up, it's going to ask you to connect to a server, and that's why we downloaded the SQL Express server. So let's connect to that, and there you go; it's as easy as that.

So now we have SQL Server Management Studio set up, and we are good to go. So the first thing that we need to do is actually create a database. So let's go over here to databases and let's click new database. Let's just do SQL tutorial; keep it simple. And if we click that, it's going to create our database for us. Now, when you open up the database, there's going to be a lot of stuff you really do not need to know. All this really, what we're going to be sticking to is this tables right here. Uh, as of right now, we do not have any tables, so we need to create tables. Now, there's two ways that you can do that. You can click right here, and you can go to new and create table. We're not actually going to do that; we're going to create it using a script or a T-SQL. So we're going to go over here and do new query, and we will get started on actually creating uh the two tables that we're going to be using for all the stuff going forward. All right, so let's get rid of me. You really don't need to be seeing me anymore. Let's get started by doing our very first table, which is going to be our employee demographics table.

So let's start off by saying create table, and we have to name it. So let's do employee demographics and enter. We want to do an open parenthesis. Now we need to specify what our column names are going to be and what the data type is for each column. So let's start off with employee ID, and we want that to be an integer. So that'll be like 1, 2, 3, 4, uh anything numeric. Now we want to do first name, and let's make that varchar(50). If you don't know what these data types are, that's okay; uh, that will probably be covered in a different video. That's not really necessary for this video. Uh, let's do last name; we'll also make that varchar(50). Let's do age; make that an integer. And very last, let's do gender, and we will make that varchar(50) as well. So now we have our very first table. Let's run that, and we'll see if it works. We'll go over here; we'll refresh our tables, and there you go. So we have our very first table. Let's go up here; let's get rid of this one, and now let's create our second table. So we're going to do basically the exact same thing, but we're going to have a little bit different information in it. This is going to be our employee salary table. So let's do create table, and again we need to name it, and enter, and open parenthesis.

So now we're going to do the same thing; we're going to do employee ID; let's make that an integer. Now we want the job title because we want to know what they do, and this one is going to be varchar(50) because we keep it pretty simple. Whoops. And then for our very last one, we're going to do salary, and that will be integer as well. And I'll just do PR here. So let's create this table; let's see if it is there, and there we go. So let's open up one of these tables really quick, see what's in there, see what it looks like. As you can see, we do not have any information in there. Uh, when you create a new table, sometimes when you open it up, you're going to see this. If you want to get rid of that, you just need to do a—I think it's called a hard refresh or something like that—but you can do control shift R. Let's see if it works for me. I just did it. All right, it goes away. So now it recognizes it as a table, so we're good there. Let's go back here, and let's get rid of all this. We've already created our tables. Now we want to insert the data into our tables. So let's see what that looks like. Let's do insert into, and now we need to specify what table we're inserting our data into. So let's start off with employee demographics. Let's do values. So now we have to select what values we're going to put into um into this table. So now we're going to have to do the employee ID. So let's do 101. Then we're going to do first name. So let's do Jim, last name Halpert, and then his age. Let's say he's 30, and he is a male. Now, just for fun, let's execute that. Let's go back to this table right here and execute, and as you can see, all of our information actually went in there. So now we have his employee ID, his first name, his last name, age, and gender. Now we need a lot more information uh for this table in order to actually learn a lot of the concepts of querying the table. So I'm actually going to go through and add a ton more information. I'm not going to bore you through that, but I will show you the final product before I actually hit execute. So stick with me. I'm actually just going to cut to the end where I insert all my stuff down on here, and then if you want that, I'll probably leave it in the description or maybe put it in my GitHub or something so you can easily just go copy and paste that if that's what you want to do. So I'll see you in a few seconds.

All right, so I have all my values right here. I'm actually going to take this one out; I already did that one. But this is our additional information. Let's insert that into our table real quick and go back here and take a look at it, and there you go. This is going to be our core information that we are querying off of uh in future videos. So that table is completely finished. Let's go back here; we're going to get rid of this because now we want to insert our information to our other table. So let's do insert into, and let's do employee, and now we're going to do salary. So let's do values to specify that we're inserting values into there. And in this one, we have employee ID. So again, let's do 101; that's Jim. His job title is salesman, and let's say his salary is $45,000. And let's execute that, and you can't see it, but down here it says it's done. Let's go to that table, and as you can see, that is inserted. I'm going to do the exact same thing as I did before; I am going to fill out all these, and in a second it will be done uh on your side. And then again, I will leave it in the description, or I'm going to put it on my GitHub, and you guys can just copy and paste that if that's what you want to do, or you can write it out, whatever you want to do. All right, just like before, I'm going to get rid of this first one; that is Jim; he is already done. Now let's insert this information. Ed is finished. Let's go back here, and there we go. Now we have both of our tables, and we are good to go for future videos. So thank you so much for sticking all the way through this one. In the next video, we're going to actually begin uh querying the table and learning the select, the from, the where, the group by, and the order by statement. Everything is in these upcoming videos, so stick around, and we will learn all of that together. Thank you so much for joining me. If you like this type of content, be sure to subscribe below, and I'll see you in the next video.

What is going on, everybody? My name is Alex Freeberg, and in today's video, we're going to be going over the select and the from statement. So if you joined us for our last video, we went over creating our tables and inserting data into those tables, and so we have this employee demographics table, and we also have this employee salary table. And today we're going to be walking through the select statement and the from statement on these tables. So here are some of the concepts that we're going to be going over today. Let's just get it started by doing select everything, and let's do this from the employee demographics table. So let's execute this. If we wanted to only show the first names, we can just do first name and run that. And if we want first name and last name, we can just separate that by using a comma, and it will return those. Well, if we want to return all columns and all rows, then all we have to do is use this star. So that's what the star does. Now we have nine rows of data here, and if we only wanted to return, let's say, the top five, we can easily do that, and we can just say top five of everything. Now, the reason this could be useful is say you have a table that has millions of rows in it, and you only want a small sample; you can say select top 1,000, and when you do that, it will only select the top five rows. Now let's get everything back in here really quick because we're going to move on to this distinct feature. So when we use distinct, we're actually saying that we want the unique values in a specific column. So if we say distinct and then let's do employee ID, everything should be returned, so all nine rows should be returned, and that's because every single one of these are unique. Now let's try gender. So there's only going to be two results: the male and the female, and that's because there's only two distinct values in that column. Now let's look at all of our data again. So now we want to look at count. Now count is very simple; all it's going to do is going to show us all the non-null values in a column. So let's look at last name, for example. If we do count of last name, all that's going to give us is a count of nine because we have nine last names. If, for whatever reason, somebody's last name was left out and that was null, then it would have returned maybe eight or seven, depending on how many were actually in there. So if an entire column was null, we—it would be a return to zero. And if you notice, we are not given a column name; that's because this is derived information based off the last name. So if we want to actually give this a name so that that column does not say no column name, we can use this as right here. So once you put as, you can actually name it. So since this is the count of the last name, we'll write last name count; keep it simple. And if we execute that, as you can see, we have last name count right there. So that's how you use that as. Let's look at all of our data again. We want to look at some max, mins, and averages right now, and the only column here where it would be useful to do it on is age, but let's actually go over and let's look at our salary table, and at our salary table we have some really interesting salaries that I think would be a little bit more useful for this information. So let's go over to employee salary. All right, and let's look at this table really quick. So we have our salary. Now we want to look at the maximum salary that is in uh that column, and that is going to be $65,000. Now let's say we wanted to know what the minimum salary was. Let's execute this, and the person who makes the least money is making $36,000. Now, what's the average? What is the average salary for all employees? That's going to be $48,500. So so super easy to use all of these things; they're extremely useful. I use them every single day, so I know that each of these are very, very useful and are definitely among the basics that you have to know. Let's look real quick at everything really quick. So we just learned the select statement, but learning this from statement really quick is also important. Up here, this actually shows us that we're already hitting off the SQL tutorial database, but let's say we change it to master. When we try to run this, it's going to give us an error, and that's because now we're hitting off this database, and this database does not have this table in it. So in order to do this, in order to still hit off that table while up here we're actually hitting off a different table, we can change this information. So the from statement, you have to specify three separate things. The first thing that you need to specify is the database. So let's say we want to hit off the SQL tutorial database. Now we want to select what table we're going to do. This is actually a dbo, so let's put dbo. There's there's a lot that can go into that; um, it's not worth getting into now, but dbo.do, and let's do employee salary. When we execute this, our information comes up, even though up here we're still hitting off the master database. When we specify it right here, then we actually are choosing what database and what table to hit off of, and so it does not matter what it is up here. So that's how you use the from statement. In the next video, we're going to be going over the where statement, and then after that, the group by and order by statement, and that will be the complete basics of SQL tutorial, and then we'll start getting into a little bit more fun stuff, some more advanced concepts, which I think will be really, really exciting for everybody to learn. Thank you guys so much for joining me. I really appreciate it. I hope this has been helpful. If you like this type of content, subscribe below, and I'll see you in the next video. Thanks, and goodbye.

What's going on, everybody? My name is Alex Freeberg, and in this video, we're going to be going over the where statement and SQL. In the very first video, we created our table, inserted data into our table. In the second video, we went over the select and the from statement, and now we are on to the where statements. Now, what does the where statement do? It helps limit the amount of data and specify what data you want returned. We have quite a few concepts that we're going to be covering today. Let's just start out with something really easy. Let's do where first name equals Jim; really simple. So we're selecting everything where our first name equals Jim, and this is our output. So really, really simple. Now let's try where it does not equal. This right here says does not equal Jim, and let's execute that, and as you can see, we have everybody except Jim Halpert in there. So now let's look at the greater than or less than. So in this table, I think the one that we're going to look at is age. So let's look at age, and let's do where it's greater than 30. And when we execute that, we're going to get everyone who is over the age of 30. Now, as you can see, we're not including people who are 30 years old. If we want to include people who actually are 30 years old, we're going to add the equal sign right there. So we should be seeing people who are now 30. So before, Pam and Jim were not in there, and now they are. If we do the exact same thing, let's do less than 32. Here's everyone that's going to be included, but if we want to include the people who are 32 years old, then we are just going to add that equal sign, and now the people who are 32 years old, like Toby and Meredith, are now included. If we want to go even further, we want people who are less than or equal to 32 and who are male, we can say where gender equals male. So now we have two—two things that we are specifying that we need: we need somebody whose age is less than 32, and we need their gender to be male. So let's execute that, and we have four people who meet that criteria. So that's what the and statement does. If we write or, then only one of these criteria has to be correct in order for it to be met. So if we hit execute now, we're saying anybody who's under the age or equal to 32 or their gender equals male. So if we look down here, Michael Scott is actually 35 years old, so he's over 32, but since he is male, he is now included. Let's get rid of everything really quick. I want to look at this like really quick. So let's execute just that, and if you do that, you highlight just that, hit execute, then it uh will only run what you have highlighted. So now let's look at this whole table. Now, when you're using like, you typically are doing this for sometimes numerical, but most of the time you're using it for text information. So if we're looking at this right here, if I'm looking at last names, and let's say I want everybody whose last name starts with s, you can't really do that with anything else. So I'm going to say where it's like, and then I'm going to say s, and after that, I'm going to put a percent sign. That's actually called a wild card, and if I close that off, what this is saying is is I want every last name where it starts with—where it's like—where it only starts with an S. So let's run this really quick. Now we have two people whose last names start with s. Now, if I put a wild card at the beginning, we are now saying where there's an S anywhere in anybody's name. So let's execute this and see what we get. So now, even if the S is like Flenderson towards the end, it still counts. So you can specify multiple things in here as well. So let's say I want it to start with s; that would return Shre and Scott. But now I want something that also has an o in it, so—so it has an S at the beginning, and then somewhere in there there's an O. Now let's execute that, and there's only one person that meets that criteria. So you can do that for multiple things; you can even say o, t, t, and let's execute that, and he's still going to be returned. And if we put c at the back, it's not going to be returned because it follows it in order. So isn't s, o, t, t, c? The c would actually need to go over here. So now we have s, c, o, t, t, and although there's a bunch of wild cards in here, it is going to return Scott. So that is a little bit—a little hint at how you can use like. There is a little bit more that goes into it; you can use it for numerics; um, there's a lot of things that you can use this for, but this is just the basics, how you can use it today, how you get started on using the like. In a nutshell, that is how you use like. And as I said before, you can use like with numerical data as well, but for demonstration purposes, I wanted to use text data. Let's get rid of this really quick. Um, let's look at our entire table, and I wanted to show you how to use null and not null. I can't really show you how to use null because I do not have any null fields. I could easily update this table and make null, but that's in a future video, where it's a little bit more advanced where you can start altering your data. But just for purposes of showing you what null and not null is, let's do where first name is null, and if we see that, is not going to return anything. But if we say is not null, it's going to return everything because nothing in here is null; nothing in this first name column is null. So that's how you use it. Um, there are a lot of use cases where you actually will use null and not null; that will be in future videos, probably in the project section or the portfolio section. We weren't able to show really how to use this super well, but just as a demonstration, that's really all it does; it looks…

At the whole column and whether it is null or not null; that's really all it's used for. This is actually super useful, and you can use it in a ton of situations, but again, for demonstration purposes, that's really all it does. So let's get rid of this. Let's look at "in" really quick. So "in" is kind of like the equal statement, but it's multiple equal statements. So let's say we want to say "where first name equals 'Gy'," and then we were like, "wait, we also want to include Michael Scott." So then we would have to write "and where first name equals," and then we would do "Michael," and then etc., etc., for anybody that we wanted to include. But if we said "in," we could do an open parenthesis, and then we can say "Gy," we can say "Michael," and we can say as many people as we want going down the road, just separating it by commas. And if we had executed, everything would be returned. So it really is just a condensed way to say "equal" for multiple things. So that is the "where" statement. I think the "where" statement can get extremely complex, but this really is highlighting the basics. So if you can learn all of these concepts, you will absolutely have the basics down and will be set to go over some more intermediate and more advanced things with the "where" statement later on.

In the next video, we're going to be going over the "group by" and the "order by," and then we are done with the SQL Basics. And then you can practice and work your way up into my intermediate-level videos, which are going to be coming out very shortly after these videos. Thank you guys so much for joining me. If you like this tutorial series, be sure to subscribe below, and I'll see you in the next video.

Going on, everybody. My name is Alex Freeberg, and in today's video, we're going to be going over the "group by" and the "order by" statements. In previous videos, we created tables; we went over "select," "from," and the "where," and now we are at the very end of our SQL basic series. If you stayed with us for the whole time, hopefully, you have learned a lot and learned the basics of SQL. In future videos, we're going to be going over intermediate and even more advanced concepts and even going through portfolio projects that you can use to put on your resume. If you like this type of content, be sure to subscribe below, but let's get into it for today.

The "group by" statement is similar to "distinct" in the "select" statement in that it's going to show the unique values in a column. The difference is, is if we say "distinct gender," what's going to be returned is the very first unique value of "female" and the very first unique value of "male." But if we say "gender" and we say "group by gender," it's only going to return two values, but in these two values, we actually have all the males rolled up into this one row and all the females rolled up into this one row. Now let me further show you what that means. If I say "count of gender," now you can see that this whole time there were six males in this one row and there were three females in this one row. So with a "distinct," it really is only showing us what value is in there that's unique, but with the "group by," it's showing us what the unique value is, but it's also rolling them all up into one column that we can use it for other things.

Now, real quick, I want to be able to see both of these at the same time, so let's just put this up here and let's run this so we can actually see both. Now let's add "age" to this statement down here or this query, and let's only run this one, and I want to show you what happens and why it happens. We're now looking at "gender," "age," and then the "count of gender." So if we look down here, we only have one male who is 29; we have one male who is female that's age 30, and so on and so forth. So none of these people are both the same gender and the same age. If, for example, we had two or three people who were male and who were 30 years old, then we would have a two or a three over here. So this count is actually being counted at each row that's being returned. So for our data that we have today, this isn't a fantastic example, cuz it really split it out there, any that were the same. But as you can see, you can put multiple columns as long as you put multiple down here.

Now, why did we not have to put this "count gender" down here in this "group by"? That's because this "count gender" is actually a derived field or derived column; it's derived based off the "gender" column. So it's technically not a real column that's in the table; it's one that we're creating that's fictional, uh, per se. So the "age" and the "gender" are actual fields or actual columns that are in our table; they have to be down here. And like I said before, it's the comparison to that "distinct" in the "select" statement because we're looking at the distinct of "gender" and "age." So we're saying "distinct" across multiple columns, both "gender" and "age." Now, as we had it before, we were only looking at "gender"; it's going to roll all of those up into just "male" and "female." But if we want to add more, we can easily add more in this "group by" statement. We can still do things like "where age is greater than 31"; we can still do those things. So let's execute this, and our numbers are going to change. Now we're doing it based off "gender," and we're looking at the count of people whose age is greater than 31, which is smaller than before.

Now let's look at "order by." I'll do it down here really quick for demonstration, but I am eventually going to come up here and use it because I think it'll be a little bit better to completely round out this query down here. Let me give this a name; let's do "count of gender," and then let's come down here and let's "order by," uh, let's "order by count gender," and when we run that, it's going to do 1, 3, and that's because as a default, SQL has an ascending feature, which is going to be smallest to largest going down. If we want to change that, we can change it to "descending"; that's going to be largest to smallest. So now we have 3, 1. And if we want to do it based off "gender" and we do it "descending," now we have Z to A, and so that's going to be "male," "female." And if we get rid of that, it's going to do the the default ascending, and let's see what that brings: "female," "male." Now, for what we're trying to do, let's look at this large table, so I think it's going to be a little bit more descriptive or a little bit better visually. Let's do "order by," and let's do "age." Let's run this, and it's going to order smallest to largest. If we do "descending," it's going to do largest to smallest. Now you don't only have to do just one thing; you can do multiple columns. So if I wanted to do "age" and then "gender," I can do that as well. So let's do "gender," and let's run that. So now we have the "age," but under the "age," we also have it ordered by "female," and that's an ascending order, so A, B, C, D, F; so "females" first; so it's going to be "female" first, and then it's going to be "male," and again "female" and "male." Now we don't have to just let it be ascending for each one. If I wanted to do it reverse in this column, I can do "descending." Now let's run that, and when we have 30, now "male" is first and "female" second. And if I wanted to do that over here, I can do "descending," and now we have them both descending, so it's going to go top to bottom, and we have 32; it's going to be "male," 32, "female." So you can specify lots of different things in here, and we don't actually have to use column names; we could just use numbers. So if I wanted to do 1, 2, 3, 4, 5, I could. But let's try to replicate the exact same thing before. This would be column 1, 2, 3, 4. So let's do "where 4 descending," and then let's do "5 descending," and if we execute that, it's going to give us the exact same result as if we actually put in the column name. And I, I do use this a lot; oftentimes, I don't use the column name; I just, if it's a small table, I'll just use the number. So in my actual queries, I do this a lot where I just use the number instead of the column name.

So that is the "group by" and the "order by" statement, and if you have walked through my previous videos, you should be completely done with the basics of SQL. So congratulations. The next thing to do is really just practice the basics because the basics are what you're going to be using day in day out. And so what I would recommend is create a few more tables, query those tables, try to think of use cases and what you would actually want to know from that information. After that, I would move on to my intermediate videos if those are already out, and then I would move on to my advanced videos. Those are going to go over some more challenging topics, but things that would be very useful for anybody to know. In my next video, I'm going to be going over intermediate SQL topics, things like joins and subqueries and a ton more. So if I already have posted those, be sure to go check those out on my page, and if I haven't, I hope to have those up soon. Thank you, thank you guys so much for watching; I really appreciate it. If you learned anything in this basics of SQL series, be sure to subscribe below, and I'll see you in the next video.

What's going on, everybody? My name is Alex Freeberg, and today we're going to be starting our intermediate SQL series. If you joined us for our last series, we walked through the basics of SQL, which is everything you needed just to get started, and in this series, we're going to be walking through some intermediate concepts to really take your skills up to the next level. Now, today we're going to be walking through joins, but let me show you what you can expect from the entire series for this intermediate course. So we're going walking through joins today, and then in future videos, we're walking through unions, case statements, updating and deleting data, Partition by, data types, aliasing, creating views, having versus the "group by" statement, the "get date" function, primary care of your foreign key, and then we're going to have an advanced course, and this is not set in stone yet, but these are some of the things that I think I will be going through or walking through: we're going through CTEs, CIS tables or system tables, subqueries, temp tables, string functions, regular expression, store procedures, and then importing and exporting data. So with all that being said, let's get into it.

All right, now let's get rid of me because we do not need to be seeing me for the rest of the series. At the very top here are some of the things that we're going to be going through today, which are inner joins and then outer joins, and in the outer joins we have a few different styles or a few different types of outer joins. Now a join is a way to combine multiple tables into a single output. For now, we're going to be using the employee demographics and the employee salary table. So let's get a look at both of these tables and see what's in them. In our employee demographics table, we have employee ID, first name, last name, age, and gender, and then down here in our employee salary table, we have employee ID, job title, and salary. If you notice, they have a similar column, and that's going to be the employee ID. Now when you're doing a join, you have to do this based off a similar column, and typically you want it to be a unique field. So we're going to be using the employee ID from both tables to join these tables together to create one output. So let's get rid of this real quick and let's start building our query to join these two tables together. So the first thing we're going to do is an inner join. So let's do "select everything," and let's do it from "SQLtutorial.db.employee_demographics," and let's do "join." We can also say "inner join," but "join" by default is going to say "inner," and we're going to do "SQLtutorial.db.employee_salary." Now we have to join them together, which is what we talked about earlier, and we're going to be doing that based off the employee ID. So for that, we have to say "on," and then we're going to say "employee_demographics.employee_ID is equal to employee_salary.employee_ID." So let's run this real quick and take a look at the output, and let me pull this up real quick. So what we are looking at is actually both tables combined; we have the employee ID, first name, last name, age, gender, and then here's the salary, employee ID, job title, salary. Now an "inner join" is really only going to show everything that is the same. So in both tables there are employee IDs of 10001 all the way down to 10009, but if you notice there is data that is missing. Real quick, let's go down to this graphic and let's look at this "inner join." An "inner join" is going to show everything that is common or overlapping between table A and table B. So what we are looking at here is exactly that; we're only looking at the things that are similar based off this employee ID in both tables.

Now let's change this "join" to a "full outer join," and let's run this and see what we get. Now if you notice the output is very different. So let's take a look at it and see why it's so different. If you notice, everything down till here is the exact same; so employees 101 down to 1009 are exactly the same, but once we get down to row 10, it starts to get very different. Now we are joining these tables based off the employee ID. So for example, right here, Ryan Howard has an employee ID of 101, but as you can see in this table for salaries, there is no 101 employee ID, so it has nothing to link it to. So because of that, it fills in everything as null because it has nothing to match on this table, and vice versa. In the employee salary table, there's a person in here that's a Salesman, and there's no employee ID at all, which means all this information is going to be null. And we can see that in this diagram right here. So this is the "full outer join" right here, and what it is saying is we are going to show everything from table A and table B, regardless of if it has a match based on what we were joining them on. So even if table A has an employee ID, but there's no employee ID in table B, we're still going to show it, and vice versa.

So now let's look at a "left outer join." A "left outer join" is going to take the left table and say we want everything from the left table and everything that's overlapping, but if it's only in the right table, we do not want it. Now what is the left and the right table? The left table is going to be our first table that we use; our right table is going to be the second table that we use. So we're going to look at everything in the employee demographics table, regardless of whether or not it has a match on the employee ID in the employee salary table. So this is what that looks like. So as you can see, this is our entire table for employee demographics, and down here we have three that have information in the employee demographics table but have absolutely no information in any of the employee salary table because there's nothing to match it on. So this 101 is not in this table; this 13 is not in this table; and this one does not even have an employee ID, so we're not going to have a match at all. And if we change that to the right, you'll see the exact opposite; it's going to show us everything in the employee salary table. So now we have all of our information right here from the employee salary table, and if it doesn't match in this table, it's just going to give nulls. So down here we have 1,0, and obviously there's not going to be anything associated with that because there's no 10,0 in the employee demographics table. And for this one, we have a Salesman with no employee ID, and since there's no employee ID to tie it to this demographics table, we're going to have nothing. And we can see that in the diagram right here. So for the "left outer join," we're looking at everything in table A, which is our demographics table, and in our "right outer join," looking at everything at table B, which is our salary table.

Now let's pull this down a little bit. So so far we've only been using the "select star," so we've been selecting everything, and I only did that just for demonstration purposes, but you most likely would not be doing this when you actually use these joins. What you're probably going to want to do is select exactly what columns you want in your output. So for example, let's do "employee ID," let's do "first name," "last name," and let's do "job title," and let's do "salary," and let's try to run that real quick. And as you can see, it is not going to work. Now why is that not working? It's not working because we have two fields, one in each of these tables, and we have to specify what "employee ID" we want because that is going to drastically change what our output is. So we have an "employee ID" in this table and in this table; which one do we want to use? So for this demonstration, let's use "employee_demographics.employee_ID," and let's actually just do an "inner join" because it's easier for the output. Now let's run this and see what we get. So as you can see, we now have the "employee ID," "first name," "last name," "job title," and "salary." Now we're doing this with an "inner join" based off the "employee ID" from the "employee_demographics" table, but if we use the "employee_salary" table, it should give us the exact same output, and that's cuz we're using an "inner join," and an "inner join" is only going to show us everything that overlaps between both tables. But now let's try a "right outer join," and let's run this. Now we're using this "employee ID" from our "employee_salary" table, and since we're doing a "right outer join," we're going to get all the information from our "employee_salary" table, and it does not have to be in our left table, which is our "employee_demographics" table. So if you look at the information down here, this 110 is in the "employee_salary" table, but it's in this position because that's what we're looking at in our "select" statement, and then over here we have our salary, and since we have information right here, which is in our "employee_salary" table, but there is no employee employee ID, our "employee ID" is null. Now let's change this to look at the "employee_demographics.employee_ID" and execute it. As you can see, that 110 is gone; now we just have this information right down here, and we didn't have the "employee ID" for either of these, so it's going to show it regardless, and that's again because we have a "right outer join," and that's why we have no "employee ID" down here.

Now let's do a "left join," and it's basically going to do the opposite of what we just looked at. Now we're looking at everything from our left table, regardless of if it's in our right table, and so our left table is our "employee_demographics" table, and we are looking at our "employee_demographics.ID." So with the "employee_demographics.ID," it's going to show us the first name and the last name, which is everything in our left table, our "employee_demographics" table, and since for these IDs or lack of IDs, it's just going to give us NULLs in all of these places. If I change it right up here to the "employee_salary.employee_ID" and I execute it, because we're showing everything from our left table, which is our "employee_demographics" table, we are still going to see our names, but since we're using the "employee ID" from our right table now, we're just going to have blanks in this information and this information.

Now let's look at a use case for these joins. Let's say Robert California is pressuring Michael Scott to meet his quarterly quota, and Michael Scott is almost

There, he needs like a thousand more dollars. And he comes up with the genius idea to deduct pay from the highest-paid employee at his branch besides himself. So how does he go about doing this and identifying the person that makes the most money? Well, of course, he's going to come to SQL first. So we actually want to look at a full outer join real quick, and let's just look at everything. So here's what we have: we have the employee ID, first name, last name, age, gender, employee ID, job title, and salary. Now, what information do we need to know to get the information that Michael Scott needs? Well, we need the employee ID; we want the first name and last name. So let's write all that real quick: so employee ID, we need first name, name, we need last name, and then we're also going to need the salary, cuz we need to know who is the highest-paid employee. So now let's do an inner join because we really only want to look at the employee IDs where we know what their name is and their salary is. And let's do this based off the employee demographics table; it really doesn't matter for an inner join, but let's do that real quick. So let's look at this: so we have our employee ID, we have our first name, our last name, and our salary, and we want to do it where it's not Michael Scott. And that's because Michael doesn't want to take away his own money; he wants to take away his employees' money. So let's do where first name does not equal Michael, and he knows that he's the only one that is not named Michael. So now we have our list, and let's do order by, and let's do salary, and let's execute this, and let's do descending so that we can get at the very top. And this is tough, tough news for Dwight Schrute because it looks like he is the highest-paid employee besides Michael, and so it looks like he is going to get a cut in his pay this quarter so that Michael can meet his quota. So that's just one use case. Let's look at one more use case. Let's start out by getting rid of this and looking at everything again.

For our next use case, Kevin Malone, who is an accountant, thinks that he may have made a mistake when looking at the average salary for our salesmen. Now, Angela Martin is very good at SQL, and so what she is going to do is she wants to go in and calculate the average salary for our salesmen. So let's try to get that information. So all we're going to need is the job title and the salary. So let's come up here and let's get job title and let's get salary, and let's look at this. And now we only want to look at where the job title is equal to salesman. Now, the very last thing we want to do is we want to say we want the average of salary. Now, since we're going to need to do a group by, we're going to have to get rid of this salary and just take job title, write down here, and do group by job title. So we're going to have job title and then the average salary, and there you go. We have the salesman, and the average salary is 52,000. So Angela now knows to go back and fix what Kevin made a mistake on. So that's how you use joins. I will includ include this image in the description so you can go and look that up yourself if you are curious and want to look at that. That really helped me out when I was first getting started to kind of conceptualize and understand what kind of data I was pulling based on what join I was using. So I hope that was useful to you as well. In the very next video, we're going to be looking at the union. So if that is posted, be sure to check that out next. Thank you guys so much for joining me. I really appreciate it. If you like this type of content or got anything out of it today, be sure to smash the like button, smash the Subscribe button, and I'll see see in the next video.

What's going on everybody? My name is Alex Freeberg. In today's video, we're going to be looking at unions. Now, in the very last video, we walked through joins, and I thought it was appropriate to look at unions next because unions and joins are somewhat similar or closely related. And that's because in both instances they're combining two tables to create one output. Now, what's the difference? The difference is that a join combines both tables based off a common column, and in last video that was the employee ID. So in both tables we had an employee ID, and when you're selecting your data you have to choose either to only select one employee ID or you can choose both employee IDs, but they're in separate columns. And with a union, you're actually able to select all the data from both tables and put it into one output where all the data is in each column and not separate it out, and you don't have to choose which table you're choosing it from. Now that may not have made 100% sense, but let's look at it real quick in stages. So let's go down here and let's actually join this table together and see what we get. Now, the two tables that we're looking at is employee demographics and warehouse employee demographics. So over here we have our employee demographics information, and then over here or actually down here we have our warehouse employee demographics. Now, right now I'm doing a full outer join, so we're looking at all the data. And if we were to pull this into an Excel spreadsheet, we could just copy this and paste it over here, and we would be good to go. And that's because we have all the same columns: first name, last name, age, gender, first name, last name, age, gender. But if we tried to combine this in a query where we have this information right here, it wouldn't work; we cannot get it in the same column. And that's where a union comes into play. So let's go back up here and let's actually run both of these. Now, as you can see, they have the exact same columns, and that makes it super easy for what we're about to do. All we're going to do is between these two queries, which are completely separate right now, all we're going to do is write Union. So let's run just this. Now, because of the Union, you can look down here, and the information that used to be in the other table, which were in separate columns, are now added down below in the exact same order. Now, Daryl Philbin was actually in both tables, and the reason he isn't showing up multiple times is because this Union is actually taking out and removing the duplicates, kind of like a distinct statement. Now, there's actually another thing called Union all, and if we do Union all, it is going to show us all of the information regardless if it is a duplicate or not. So let's run that real quick, and they they are both there, but let's order by, and let's do employee ID. So now let's run it, and as you can see right here, these are exact duplicates, and so the union got rid of it because they were the exact same, but the union all kept it in because it is showing just the data as is. Now let's get rid of this Union all because the only reason why it works so well is because those two tables were exact same; they were employee ID, first name, last name, age, gender, so they're basically the same tables just with different information, so it made it really easy. But we have another table, employee uh salary, and let's look at these two tables. So these two tables are obviously very different; they hold different information. Now we would still be able to combine them. So let's do employee ID, first name, and let's do age. Now down here on the employee salary table we will do employee ID, job title, and salary. Now let's use a union really quick and run this one, and it is still going to work. Now why does this work? Well, first off, the the reason it's working is because these data types are the exact same or at least similar: so text and text, age which is an integer, salary which is an integer; it has the same amount of columns, so three and three. So we have employee ID, first name, and age, and it's taking that from the first select statement, and it's still using a union to take the data from the second select statement, so it's still inserting this information. Now this is not what you want to do because right here we have first name, and it's salesman, salesman, and then our age, we have 30, 45,000, and 45,000 is obviously not an age. So you want to be careful when you're using a union to combine two separate tables and make sure that the data you're selecting is the same. In the very next video, we're going to be walking through case statements. Thank you guys so much for joining me. I really appreciate it. If you like this type of content, be sure to subscribe below, and I'll see you in the next video.

What is going on everybody? My name is Alex Freeberg, and today we're going to be walking through case statements in SQL. A case statement allows you to specify a condition, and then it also allows you to specify what you want returned when that condition is met. So we're going to be using this employee demographics table that we're looking at right here. We're going to walk through the syntax of how to create a case statement, and then we're going to actually go into some use cases at the end. So let's start off by specifying what columns we want. Let's say we want the first name, we want the last name, and we want want the age. Now let's just get that information. Now, for our case statement, we're going to be using this age column, so we actually want the age to be in there. So let's specify where age is not null and run that. So now we have a pretty good look at it, and let's just order by age just to clean it up a little bit. So now let's start building our case statement. So we're going to say case, and then we want to say when. Now we need to specify what condition we want to look for. So let's do when age is greater than 30, then then what do we want to be returned? So we want to return that they are old. Else, so that means anything that is not over the age of 30, we want to return young, and then you need to specify that you're done with the case statement, and so you will write end at the very bottom. So this is our first case statement. Let's run it and see what we get. So as you can see, a new column was created, and if the person is over the age of 30, so 31 and up, they are given old, and if they're not over the age of 30, they are given young. Now we can do as many when and then statements as we want. So if we want to, we can also do when the age is between 27 and 30, then we want to return young, and anyone else we're going to call a baby. So now we have Ryan Howard as the baby; anyone between 27 and 30, they're considered young, and anyone over the age of 30 is old. Now, something to note is that the very first condition that is met is going to be returned. So if there are multiple conditions that meet the criteria, only the very first one is going to be return returned. And let's demonstrate that real quick. So if the age equals 38, then return Stanley, because that is Stanley uh, and let's execute this real quick. So right here I'm specifying that if it's 38, it should return Stanley, but he is right here, and it still says old. And that's because this condition was already met. Now, if we were to put this right here, it should work correctly. And let's try it out. So now, because this condition is met first, it is going to return Stanley down here. So now let's get into our first use case. Let's start off by copying this and then commenting it out. I only did that because I don't want to rewrite it because I'm lazy. Uh, let's get rid of that and let's look at this real quick. We are going to join on another table that we have really fast um that's going to be SQL tutorial. If you watched my other videos, then you know this table, and we're going to do that on employee demographics.employee ID is equal to employee salary.employee ID. Okay, so let's just look at everything in these tables real quick. Now we are going to be focusing on the job title in the salary column, but we want their first name and last name as well. So let's start building that out. Let's do first name, last name, job title, and salary, and let's look at this real quick. So now we have our employees, and here is the situation: we had a fantastic year this year selling paper, and corporate has allowed Michael Scott to give out a yearly raise to every single employee, but not every employee is going to get the same raise because our salesmen are genuinely the people who made us our money, and they're going to get the biggest raises. Well, other people really aren't going to get that big of a raise. So now let's go through and create a case statement to calculate what their salary will be after they get their raise. So let's start off by saying case and when, and we want it to say when job title is equal to salesman, so when they are a salesman, what do we want to happen? So this is where the calculation occurs. So we're going to take their salary, and then we're going to add their salary times how much their raise is going to be. So the salesman did really really well, and we want to give them a 10% raise this year. Now, when their job title is equal to accountant, then and we'll take their salary, we will give them let's give them a 5% raise, still very generous there. We we go. And when the job title is equal to HR, then it's going to be the salary plus the salary times, and then we're going to do 0.01, all right. And else, we are just going to do salary plus salary oops let's do parentheses times, and let's just give everyone else a 3% raise, and then we'll write end. Now let's take a look at our results. So here's what we have so far: we have our first name, our last name, our job title, and our salary, that is our current salary, and then we're going to have our salary after we get our raise. So I'm going to actually write that up here. So let's do as salary after raise, and let's execute that. So let's look at these raises real quick. So we have 45,000, and since he is a salesman, he gets a 10% raise, which is a raise of $4,500. So 45,000 plus $4,500 is $49,500, and as you can see down here, we have HR who is making $50,000, and now he is making $5,050. So everybody got a raise. So that is our case statement. I hope that was helpful. I find myself using the case statement a lot when I'm wanting to categorize things or label things, and that's kind of what we did in the first example, and you can even do calculations like we did in this use case. So I hope that was helpful. Thank you guys so much for watching. I really appreciate it. If you learned anything from this video, be sure to like and subscribe below, and I'll see you in the next video.

What is going on everybody? My name is Alex Freeberg, and today we're going to be looking at updating and deleting data in a table. Now, what's the difference between inserting data into a table and updating data? Insert into is going to create a new row in your table, while updating is going to alter a pre-existing row, while deleting is going to specify what rows you want to remove from your table. So let's get going with the updating. So down here, Holly Flax does not have an employee ID, age, or gender. Now we want to update this table to give her that information. So let's do update. Now we need to specify what table we are going to be hitting off of. So let's do SQL tutorial.db.employee demographics. So now we're going to use something called set, and set is going to specify what column and what value you actually want to insert into that cell. So let's set her employee ID equal to, and it's going to be 112. And we have to specify which one to do this to because if we ran just this, is going to set every single employee ID to 112 because we haven't specified that we only want Holly Flax's row to be updated. So now we have to specify where first name is equal to Holly and last name is equal to Flax. So now let's run this and see what we get. So one row has been affected. Let's see what we got, and there we go. As you can see, the employee ID was updated exactly how we specified it right here. So we also want to update age and gender, and let's do that in the same query. So let's set the age equal to 31, and instead of using and, we actually need to use a comma. So let's say age equal to 31, comma gender is going to be equal to female, and let's write this and see what we get. There you go. Now let's look at our table, and as you can see, it was updated to 31 and female.

So, very easy, very easy to specify what you want. Often times, uh, tables like this will have a unique key, like employee ID is our unique key in this table. So I could easily just say, uh, where the employee ID is equal to, and then you know, 102. So it's an easy way, way to specify what employee you're trying to update.

So now let's look at the delete statement. The delete statement is going to remove an entire row from our table. So let's do delete, and we actually need to say from, and we have to specify what table we want to be removing this information from. So let's do SQLtutorial.db.employeedemographics, and now we need to specify what row we want to remove. So let's do where employee ID is equal to, and let's choose a completely random employee ID, 105. So let's run this and see what happens. So one row is affected. Let's look at our table, and as you can see, 105 is now gone.

Now you have to be very careful when you use the delete statement, because once you run it, you cannot get that data back. There's no way to reverse a delete statement. So if I had gotten rid of this where statement and I ran this, it would delete everything from the entire table, and you could not get that data back. So a little trick that I use before I actually run a delete statement is I make it a select statement, because you're going to select everything where the employee ID is equal to, let's just do 104. And now when you run this, you are going to see exactly what you will be deleting. And now we know that Angela Martin, that entire row, is going to be gone. If I hadn't done that and I just went like this and I wrote delete and I only had this running, I would not know that this information is going to be the only one that's gone. Maybe I made a mistake down here, maybe I accidentally put something in there that wasn't supposed to be in there, and now I'm deleting much more than I thought I was actually going to delete. So using the select statement can be a very good safeguard against accidentally deleting data that you do not want to delete. So that is update and delete. Thank you guys so much for watching. I really appreciate it. If you like this video, be sure to subscribe below, and I'll see you in the next video.

What's going, going on everybody? My name is Alex Free, and today we're going to be talking about aliasing. Now, all aliasing really is is temporarily changing the column name or the table name in your script, and it's not really going to impact your output at all. Aliasing is really used for the readability of your script, so that if you hand this off to somebody, or somebody comes behind you and starts working on this, they can more easily understand it. And it may not sound super useful, especially for small scripts like what we have on the screen, but when you start getting to larger scripts where you have six, seven, or eight joins and you're selecting 10 different column names, it actually is very useful and very important. So let's get into how that actually works, and then I'll have an example later of how we can use aliasing with a little bit of a larger query.

So in this table, let's select first name and execute. What we want to do is just write as and let's do FN name. And all that's going to do is it's going to rename this column from first name, which it was originally named, to FN name. Now you can use as, but you can also just get rid of that and do it exactly how I have it, and it's still going to work perfectly. You can either use the as or you can not use it. I typically don't; I just put a space in between the actual column and the alias.

Now let's look at an example of how this might actually be useful. So we have a first name and a last name in this column. So what we're going to do is actually combine those. So let's do plus and let's add a space in there, and let's do a plus and let's do last name. So this is going to take the first name, add a space, and then do the last name, and we're going to do that as, and let's do full name, and let's execute this. So now we have a column called full name, which is our alias. So we've combined the first name and the last name column into one single column, and we've renamed it full name. If we had not used this alias at all, it would have just said this, which is no column name at all. We don't typically want that when we have an output; we want to give this column a name so that somebody who's actually looking at the script or who's looking at the output of the script actually understands what is contained within this column. So for that, we're just going to keep it as full name.

Now another time that you're often going to use aliasing in the select statement is when you're using aggregate functions. So in this table we have age. So let's pull that up really quick. So we have age right here, and let's actually just do the average age. And when we execute this, we're going to get no column name and 31. So we want to do is give it average age, and when we do that we now have a column name. And again, you want to have a column name in case someone comes up behind you and is reading the script so that they understand what this column is being used for.

Now that we've looked at aliasing column names, let's look at aliasing table names. It basically is the exact same thing; uh, we're just going to write as and let's do demo for demographics, and let's do demo. and it's going to give us all of our options, and we'll do employee ID. So when you alias in a table name when you are selecting in the select statement, you actually need to preface your column name with a table name or the table alias dot, and then employee ID. And this is extremely important to do, especially when you have a lot of joins that you're doing or you're selecting a lot of columns when you have several joins, because it can get very, very messy quick. So let's actually join this to employees salary and let's do that on demo.employee ID is equal to s.employee ID. So now let's do demo.employee ID comma s. and let's do salary.

So looking at the script now is very clean; it is very easy to understand, and that is what's so important with aliasing. If, for example, we took this off, every time we wanted to reference this table we would have to put the entire table name, and putting the entire table name is correct; it just is very cumbersome and does not look clean at all. And so using something like demo as an alias makes it a lot more easily readable and a lot more manageable when you're looking at it when you have a very long script. Let's look at this query where we're joining together three separate tables, and after each table we have an alias: for employee demographics we have a, employee salary we have b, and warehouse employee demographics we have c. Now unfortunately, I have seen a lot of scripts that look exactly like this, and this is what you do not want to do. You do not want to use your aliasing to just write an a, a, b, or a c; that is very frowned upon when writing queries because it really doesn't give any context to what the table that you're referencing is, and it gets really confusing as this query continues to grow and as you add more columns to your select statement; it makes it more difficult to understand where those columns are coming from. And so when I'm reading that, I say select a.employee ID, okay, what's a? A is employee demographics. So you really do not want to do that.

Now let's look at an example of what it should look like. So for employee demographics, instead of having an alias of a, I used demo for demographics; for employee salary I used s; and for warehouse employee demographics I used where. Now this is not perfect by any means, but in the select statement, if you're just glancing at it, you can easily understand which columns are coming from which tables. So when I look at employee ID, I know that's coming from employee demographics, cuz I have demo as the alias, so it's a lot easier to understand. And when you hand this query off to somebody, it is going to be a lot easier for them to read through it and understand where those columns and those table names are coming from, and so they will appreciate that in the long run. So that is all I got; that is aliasing. Again, not a super tough subject, but a really important one to understand, especially as you start working in teams and as you start creating more and more complex queries. You want to have it more organized and more easily readable, and so it may not come into play with those really simple queries, but again, as you build out those more complex queries, this becomes very useful. I really hope you enjoyed this video; if you did, be sure to comment and subscribe below. Thank you so much for watching, and I'll see you in the next video.

What's going on, everybody? Welcome back to another intermediate SQL tutorial. Today we're going to be covering PARTITION BY. Now, PARTITION BY is often compared to the GROUP BY statement. The GROUP BY statement is a little bit different; the GROUP BY statement is going to reduce the number of rows in our output by actually rolling them up and then calculating the sums or averages for each group, whereas PARTITION BY actually divides the result set into partitions and changes how the window function is calculated. And so the PARTITION BY doesn't actually reduce the number of rows returned in our output. Let's get started to look at the actual syntax of how to use PARTITION BY, and then we'll compare it to the GROUP BY statement later just to see the differences between the two. We're going to be using these two tables on our left over here, so I'm going to pull those up really quick. So let's run this and let's look at the two, these two tables, side by, well, one underneath the other really quick. So what we're going to be using to demonstrate these partitioned by is this gender column as well as this salary column, and so we just need to join these two tables together on the employee ID, and then we'll go from there. Now I'm not going to bore you with that; I'm going to skip ahead, and we'll actually look at how to use this partition by. So I've joined these two tables together, and this is our output, but we don't want every single column. I'm going to start selecting some of these columns, and then we'll start using this partition by and see what the output looks like after that. All right, so let's go right up here; let's choose the first name, let's do the last name, we'll do gender, and let's do salary. And now we want to identify how many male and female employees we actually have, and so we're going to say count of gender, and this is going to be over, and now we're going to do our partition by, and we're also going to partition that by the gender as total gender. Now I'm going to come back to why we did each part, but I want to see the output first, and then we come back to why we wrote it this way. So let's just do this really quick. So it's going to be a little bit different than what you typically would expect in a group by statement. The group by is going to roll everything up, and you typically wouldn't have like a first name, last name in a group by statement because it would be very hard to roll all those things up into those individual columns and to reduce the number of columns that are in your output. And so in our output we can see Pam Beasley; she's a female; she makes $36,000 as a salary; and there are three total women that work alongside her in this employee demographics table. And so in our total gender column over here, this is where we use the partition by, and if we used a group by statement to get this kind of information, all we would be able to do to get this information in a group by statement is say select gender, count of gender, and then group by the gender down below underneath the join. So because we're using the partition by, we're able to isolate just one column that we want to perform our aggregate function on, and so we're able to add things like the first name and last name columns, even though we aren't trying to include that in any partition or group by statement yet; we're still able to add the aggregate function to each individual row while still maintaining those other columns. Let's take this entire query and let's basically just transform it into a group by statement, and we'll see kind of what that looks like and what the difference is. So all I'm going to do is get rid of all this; I'm going to copy all of this, and I'm going to say group by, and I'm going to do that because we have to use all these columns in our group by statement. So let's execute this, and as you can tell, we are not able to see the output for the aggregate function that we were hoping for. If we wanted to get the same output that we had before, where we're showing three for females and six for males, what we'd have to do is get rid of this first and last name and the salary and do the same thing in the group by statement. And so let me get rid of these really quick and run this. And so what the PARTITION BY is doing is basically taking this query right here and sticking it on one line in the select statement. And so I hope now you can see how valuable the PARTITION BY can be if used correctly. Thank you guys so much for watching; I really appreciate it. If you like this video, be sure to like and subscribe below, and I'll see you in the next video.

What's going on, everybody? Welcome back to another SQL tutorial. Today we're going to be talking about CTE. A CTE is a common table expression, and it's a named temporary result set which is used to manipulate the complex subqueries data. Now this only exists within the scope of the statement that we were about to write; once we cancel out of this query, it's like it never existed. A CTE is also only created in memory rather than a tempdb file like a temp table would be, but in general a CTE acts very much like a subquery, and so if you know how to do subqueries, you should be able to pick up on CTE fairly easily. So let's get started writing our very first CTE, and we're going to come down here and we're going to say with, and we're going to write CTE employee, and we're going to say as, and this is where everything's going to start. Now CTEs are sometimes called with queries; I've never personally used that, but I've seen it called that online, but that's because it uses this with statement right at the very beginning. So now we have with CTE employee as, then we have an open parenthesis, and now we have to construct our select statement, and this is kind of where we build out our quote-unquote subquery. And so I'm going to take in a select statement that I actually used in a previous video where we're using the partition by, and so I'm going to put that in there and I'm kind of walk us through what that does and how we're going to use this. So I'm going to paste this down right here, and I'm actually going to go like this just to make it look a little nicer, and then I'm going to close the parentheses at the end. So now we have our CTE in place, and as you can see, it is basically just a select statement within the with CTE employee as, and what this is going to do is going to take the first name, last name, gender, and salary, and then it's going to take this aggregate function with the partition by, aggregate function with the partition by, and it's going to place it to where we can now query off of this data. So it's putting it basically in a temporary place where we can then go and grab that data. So all we're going to do at the very bottom is we're going to say select everything, and we can do that from CTE employee. So let's run this entire thing and see what we get. So as you can see, this select everything from CTE employee, we are selecting everything from this select statement. And so this feels a lot like a temp table; we're actually querying off of a temp table, but it actually acts a lot more like a subquery. Now we don't have to select everything; we can just do first name and let's do average salary, and when we run this we'll just get those two columns, and we don't have to go through and actually write this out each time; it's just in this CTE for us. So it does all the heavy lift within the CTE, and then we can just query off of what we want. Now something to note is that the CTE is not stored anywhere, and so it's not stored in some temp database somewhere. If I try to run just this by itself, it is not going to work. So let's try that out really quick, and we should get an error, and that's because each time we run this query is actually creating the CTE again, and so it's not being saved anywhere, and so each time we run it we have to run it with the entire CTE. Another thing to note is you actually have to put the select statement right after the CTE. If I try to go down here and say select everything from, uh, let's do CTE employees, it doesn't actually work; it's not going to come up at all, and that's because it only is going to work with the select statement directly after the actual CTE that you've created. I hope this was helpful, and I hope that you understand how to use a CTE a little bit better. Again, you don't have to go super complicated with the select statement within your CTE; it can be very, very simple. I just wanted to demonstrate that you can use aggregate functions within your CTE and then just query off of those without having to do the aggregate function again, which I find is very, very useful. Again, thank you for watching. If you like this video, be sure to like and subscribe below, and I'll see you in the next video.

What's going on, everybody? Welcome back to another SQL tutorial. Today we are looking at temp tables, and if you can guess it based off of the name, they're kind of like temporary tables, and we create them very much the same way. We're going to do create table; um, it's just a little bit different, and you can hit off of this temp table multiple times, which you cannot do with something like a CTE or a subquery where you can only use it one time or with a subquery you need to write it multiple times within a query. And so these temp tables are extremely useful; I'm going to kind of talk about how you can use them as we're going throughout this video, but let's get started right away with actually creating one, looking at it, inserting some data, and and and kind of showing you how temp tables work and what we can do with them. So, uh, we're going to start off with create table, much like a regular table is created; the only difference is we're going to do this pound sign, and then we're going to do #tempcore employee. So literally the only difference between a regular table and a temp table is this right here at the very beginning, this pound sign. So, uh, let's just start by doing employee ID; we make that an integer; we'll do job title, and we'll make that a varchar(100); and then we'll do salary, and let's make that an integer. And so now we have our temp table; uh, let's go ahead and create it. So now we have our temp table created, and so we can look at it really quick. So let's select everything from and we'll do #temp employee. So let's take a look; it's completely empty, um, and we can insert data very much the same way we'd insert data into a regular table. So let's start doing that. Let's do insert into and we'll do #temp employee and we'll do values and let's just do something really quick because I'm going to get to a little bit more interesting stuff in a second. Oops.

We'll make this person HR; that's their job title. Then, for salary, we'll give them 45,000 and close it off. So let's run this and let's select everything again and see what's in there. Perfect. So we were able to insert data into this temp table. And again, we we don't have to create this every single time; we um um or we don't have to run this every single time we need to hit off of it, like we did a CTE if you watch my previous video. And this one, we can just run it, and it sits there. So, again, it feels very much like a real table. And I'm going to get to a little bit of the nuances of of the and the differences between a regular table and a temp table in a second, but let's really quickly—um—we want more data in there. You don't have to just um do it value by value; we can also just do um uh where we select all of the data from a specific table and insert that into a temp table. And that is really quickly, you know how I do it most of the time; most of the time I'm not inserting values; um I am, you know, taking a large table and taking a subset of that and then sticking it into a temp table. So let's look at this really quick and and run that. So now we took all of the data from employee salary, and then we just stuck it into this table. And really quickly, this is one of the big uses of a temp table. We had, let let's say for example, that this employee salary table had a billion rows or or or just an extremely large number, and we were trying to uh, you know, hit a somewhat complex query off of it where we're using joins and we're using, maybe some window functions or different things, you know, it would take a very long time to hit off of this. But what we can do is we could insert that data into this temp table, and then we can hit off the temp table, and it already has that sub uh that subsection of data that we're wanting to use for all of our later queries. So really quickly, that's kind of um kind of a use case for that.

So let's go down here; we're going to kind of create another one, and this one's going to be a little bit more advanced; a little bit of how I would actually use a temp table. Above was just kind of showing the basic syntax, how you kind of put data into it, you know, kind of how it's used. Now I'm going to show you kind of how I would actually use it. So let's do CREATE TABLE uh let's do temp oops CREATE TABLE uh let's do temp uh employee2, and then let's do open parentheses, and we'll do job title, and we'll make that a VARCHAR(50), and then we can do employees_per_job; we'll make that an integer. Now we need average_age; make that an integer, and the very last one will be average_salary; I'll make that an integer as well. And let's run this. Oops. So we have our second table. Now we want to insert data into this one, so we're just going to do INSERT INTO and we'll do temp employee2, and for this one I'm going to take a query that we used in a previous video, and so I'm just going to copy and paste that to save time, uh and then we'll keep on moving from there. All right, so I'm just going to paste that in; we will run this, and really all it's doing is from this these tables; it's taking the job title; we're getting a count on the job title, average age, average salary, and that is it. Um so let's see if that worked, which it looks like it did, but you know let's actually take a look at the [Music] data. And so now we have this subsection of data from this join above, and what this is going to do is is whenever we want to run this, we don't have to run it on these two tables and create the join and then do the calculations, which takes time. What it's going to do is it's going to take this these exact values and place this into this temporary table, and if we want to run further calculations on these values, we can easily do that in a fraction of the time instead of having to run this every single time, which will take up so much uh uh processing power, and it will reduce your runtime dramatically when you're placing this data in this temp table and hitting off of that instead of all these joins and everything above. A lot of times these temp tables are used in stored procedures. Now, if you haven't learned about stored procedures or used stored procedures at all, you know that's okay; I still want to show you something that might be useful, um although this is used a ton in stored procedures.

So, for example, let's say we have a stored procedure set up; we run the stored procedure, and we get an output, and you know we, for whatever reason, want to run it again, and when we run it again, uh we get this error, and you know this temp table lives somewhere; it it doesn't live in an actual in the actual database, uh but it lives somewhere, and so when we run it again, we get an error because there's already a temp table created. One trick or one little tip that I would give is doing something like this, saying DROP TABLE oops I don't know why I did so many spaces DROP TABLE IF EXISTS and we'll do temp employee2 just like that. Now what this is going to do is when you're running that stored procedure over and over and over again, you're getting error or whatever for whatever reason you need to run it multiple times; every time that you run it, it's going to encounter this, and so if that already exists, it is going to delete that table and then allow you to create it again. And this is just a really good thing to do. So now if you see down below, I can run this time and time and time again, and it is going to work every single time because it is checking to see if that exists, and if it does, it deletes it, and then I can create again. And so that is just a helpful tip if you're going to try to use this; I highly recommend adding that to your query just to make sure things run smoothly. I know there is a lot more that can go into temp tables, a lot more of the technical aspects or the DBA stuff; um obviously I just want to teach you how to use it and what you might use it for and how to actually write it out, but you know there are a lot more things that you can do research on about processing speed and storage, but unless you are something like a DBA, you probably don't need to worry about those things. And so if you are a DBA, I do recommend looking into those things, making sure you understand how that works, how this data is stored, uh so that when people use them or you are using them, you know what's going on in the background. But for getting up and running with temp tables, I hope that this was helpful. Thank you guys so much for watching; I really appreciate it. If you like this video, be sure to like and subscribe below, and I'll see you in the next [Music] video.

What's going on everybody? Welcome back to another SQL tutorial. Today we're going to be looking at string functions; some of the things that we're going to be looking at are things like TRIM, REPLACE, SUBSTRING, and UPPER and LOWER. Uh, we're going to create a new table, insert a little bit of bad data into it, and then we're going to be using that to work on our string functions today. So I already have this set up right here; um I'm going to put this in the GitHub that you can just download this; you don't have to, you know, type this out manually. So go look in the description if you know you just want to get that off the GitHub and download that and copy and paste it; save you a little bit of time. But let's go ahead and run this really quick, and as you can see in this table, we have uh our data right here. Give me one second. So in this employee_errors table, basically what we have, actually let me pull this back up; basically what we have is in this first one, we have here we go; we have some uh basically blank spaces on the right side; the second one, some blank spaces on the left side; uh we also have Jimbo, which is an error because his name is Jim, um and Halbert because his name is actually Halbert, um and then for Toby, for whatever reason that o is capitalized, and then uh Michael got in here and added this extra part, so we're going to have to figure out a way to take that out when we're doing our query, and that'll come in a little bit later, I think in the substring section. So let's get into it right away; let's start using uh our LTRIM and RTRIM. We're going to kind of go through each one um pretty quickly; hopefully I'm not not trying to make this a super long video because we got a lot of things to get through in this one video, uh so I'm going to go through the TRIM, RTRIM, and LTRIM. Let's look at uh the employee_ID because that's the one where we have some blank spaces on the right and the left side; the left side you'll be able to obviously you're going to see that one much easier, but uh let's start walking through this. So let's do SELECT employee_ID, and before we get any further, let me just get the employee_errors on here so we can um so that we can see everything as it comes up. So we're just going to do TRIM and then type in the column that we want to uh take these blank spaces out of; that's where the TRIM does the TRIM; gets rid of blank spaces on either the front or the back or or the left on the right side, so on both sides; that's what TRIM does, and we'll say AS ID_trim. So let's run this one really quick, and as you can see, this is our regular employee_ID, and so you know you can't visually see it as easily on this first one, but there are blank spaces after this 101, and we got rid of those, and then there were blank spaces before the 102, and we got rid of those. Now I'm just going to copy this uh two times because it's basically the exact same thing, but uh I'm going to show you them all at the same time. So it's the exact same thing except LTRIM and RTRIM, uh and let's take a look at all these at the same time, and let me pull it up. So in the, me see if I can get these all in here. Okay, in the TRIM, it got rid of both the left and the right side, so all of these were fixed in the employee_ID. For the LTRIM, we're only going to be getting rid of this one; this one still has um blank spaces on it, and when we do the RTRIM, we're only going to get rid of the stuff on the right side, so this one doesn't change because this is on the left-hand side where the blank spaces are, so this one was fixed again; not super visual, so you can't really see it, but that one is fixed. Uh let's move on to the next part, uh which is using REPLACE. So for this one, we're going to be looking at the last name. So let's go back up really quick to the employee_errors; as you can tell, the last name um the biggest one where we kind of want to take something out of because we don't want that um that -fired still in there; we're going to replace that. And so let's look at how to do that. Um let me just copy this real quick and get rid of this top part. Um so we're going to do the last name, so let's just start off with our last name um and then just as a baseline so we can see what it looks like before, and then we'll do REPLACE, and all we're going to specify is the column that we want uh to do the replacing in; we're going to specify the value that we want to replace; so in this it's going to be -fired; oops, got a little aggressive on that one; -fired, and we're going to indicate what we want to replace it with. Now I'm just going to replace it with blank, um and we can say AS last_name_fixed. So let's see what this looks like really quick, and it looks like it worked. So in this last name, it originally had Flenderson-fired, and when we replaced it and we took that -fired and replaced it with basically nothing, uh it then fixed it, and so now it looks correct. All right, let's move on to the next one; I think this one might be um the the longest one to write, but that is the SUBSTRING, um and let me take this real quick, trying to save us some time. So SUBSTRING is very is very very unique; you can specify um in a either a number or a string; you can specify the place that you want to start, and then you can also specify how many characters you want to go out um and and and it pulls that in. So just as a really quick example, um and then I'm going to show you kind of a use case for this one that I think is pretty cool that um you know maybe let me see so that maybe that you'd find useful. So I'm going to do first_name, and then I'm just going to do 1, 3, so it's going to take the first_name; it's going to start at the very first um very first letter or number, and it's going to go forward three spaces or three spots spots. So let's just take a look at what that looks like. So for our table, it's going to take Jim, Pam, and To or or Toby for Toby, um and so it's only going to take the the first three because you're starting at number one. Now what if we started at three? So we do 3, 3; it's going to go to the third um digit or or third letter, and then it's going to go forward three, so you kind of get a sense of how this works. Now I'm going to show you something that I think is very interesting that I think you guys will also find interesting; let me fix that CU I just messed it up. So if you've ever heard of something called fuzzy matching; now if you don't know what fuzzy matching is, I'll give you an example; let's say in one table my name is Alex, and in another table my name is Alexander; if we tried to join those two together based off of my name, they will not join because one is Alex and one is Alexander; there's not they're not an exact match, but for if I take the SUBSTRING and start position one and move forward four characters, it's going to take Alex from both, and then it will match them together uh and say that they are the same, so that you know it may not be perfect; that's why it's called a fuzzy match because it can work for a large majority of the time, but it's not going to work every single time. And so I want to show you how we can use this here um really quick; I need to join this to um the demographics table, so I'm going to do that really quick; bear with me for just one second. Let's try to make this at least look somewhat good. So what I'm going to do is I'm going to start off by saying um let's tie it to the first_name; let's do whoops let's do er.first_name = demographics.first_name. Okay, so I want to see and I'm just going to do first_name for er and let's do dm.first_name. So let's see what comes up when we do it like this. So the only one that is going to work is Toby, and that's because even though it has a capital O, it's still going to take it, um so you know we want to get all of them to match, and we can do that, but it's going to be um a little bit of a different way than maybe is perfect, but that's why they call it fuzzy matching. So we're going to use SUBSTRING on this, so I'm going to say SUBSTRING oops let me that right. So I'm going to say SUBSTRING and we're going to go 1, 3, so starting at the first position and going forward with three, and we're going to do the exact same thing on the oops SUBSTRING; it'd be great if I could spell that correctly; we're going to do the exact same thing, so 1 and 3, so we are actually going to take this, give me a second, missed that; we're going to take this up here, and we're just going to go like that, and I why did I copy it with the error? Okay, so let's run this really quickly, and as you can see, it is now going to match all of them, and you can do this on a lot of different things. Typically when I'm doing a fuzzy match like this, I'm not just going to do it on a first_name, right, because if every there can be a ton of people named JY, you know, we want to do it on uh and and real quick let me actually show you um what the originals looked like just to make sure I hit the the point across, um and that is going to be first_name and come. All right, so real quick, let's actually look at this. So it originally was Jimbo, Pamela, and Toby; in this one was Jim, Pam, and Toby. And so when we just took the first three because it was Jimbo, it then becomes Jim; it was Pamela, it becomes Pam; now it matches, and so that's what that's kind of the example that we're going for. Like I was saying, I typically will not just filter on a first_name because there's going to be a ton of people named Alex or Jim or or or you know Henry or whatever; you're going to do this on many different things, so would be doing it on things like uh if I'm trying to do a fuzzy match on a person, I do it on their gender to make sure that their gender is the same, um and I wouldn't probably need to use a SUBSTRING for that, but just to kind of give you a little bit more information; I need to do it on the last_name, um so I need to use that SUBSTRING again, and I would probably do it on the age oops the what am I doing come on the age and the date_of_birth. Okay, so all of those things; if you if you fuzzy match on the first_name and the last_name and then the gender, the age, and the date_of_birth are all the same, then you can typically get a very high accuracy in matching people across tables whether or not you have, you know, this is an example if you don't have like an employee_ID, which is what we do have, but take for example we were not given that; this is a way to match them using substrings. Let's move on to UPPER and LOWER. All UPPER and LOWER is going to do is basically take all the characters in the the text and make them either upper or make them lower, so it's very self-explanatory. Uh let me copy this up here, and we will get going on this one. Uh let's just look at the first_name, um specifically we're going to be looking at Toby right here. So let's do first_name, let's do uh LOWER, and all we have to do is put in the column that we want to do, so this is our original first_name, and it then takes every single uh string that is in here or every single I guess character and and it makes it lowercase; that's all it does, uh and it is the exact opposite when we do UPPER. So we can now take take a look at this one, and now everything's going to be capitalized. So there is a lot that you can do with these string functions, and this is not all the string functions that there are; there are a lot more, but I would say that these are the more popular, more useful ones that I typically use on a regular basis, and so I hope that this has been helpful; I hope that you learned something from this; if

You did be sure to like and subscribe below. I have a lot more videos coming out with tutorials on everything from SQL, Python, Tableau, and Excel. Thank you so much for joining me. I appreciate it, and I will see you in the next [Music] video.

What's going on, everybody? Welcome back to another SQL tutorial. Today we are talking about stored procedures. Now, what is a stored procedure? A stored procedure is a group of SQL statements that has been created and then stored in that database. A stored procedure can accept input parameters, and we will be looking at that today. But that means that a single stored procedure can be used over the network by several different users, and we can all be using different input data. A stored procedure will also reduce network traffic and increase the performance. And lastly, if we modify that stored procedure, everyone who uses that stored procedure in the future will also get that update.

Let's start writing out the store procedure so we can look at the syntax. We'll start off very simple, and then in the next one we'll get a little bit more complicated. So the very first thing that you need to write is CREATE and then PROCEDURE, and after that you're going to name it. So let's just call this one TEST, and all you're going to say is AS, and then you're going to write your query. And so let's just do SELECT everything FROM employee_demographics. And that is it. We have created our very first stored procedure. Of course, this is super, super simple, but let's execute this really quick and take a look at it. So it says that the commands completed successfully. Let's go over to our SQL tutorial. We're going to go over to programmability, store procedures, and it is not showing up there. What we need to do is we need to refresh our store procedures. We're just going to go right here; we're going to click refresh, and then there is our store procedure.

Now, how do you actually use the store procedure that we just created? So let's go right down here and let's say EXEC, which means execute, and then all we're going to say is TEST, and we're going to run this, and there we go. So all we put in this store procedure was a SELECT statement, and so when we actually rerun the store procedure, it returned our SELECT statement.

Now let's go down here, and we're going to make it a little bit more complicated. We're going to do the exact same thing: CREATE PROCEDURE. Make sure I spelled that right, and let's call this TEMP_EMPLOYEE. So if you remember from a previous video, we worked on temp tables, and we created our temp tables, then inserted data into that. We are going to add that to this stored procedure so we can see the difference between a simple query versus a little bit more complicated query. So I'm going to say AS, and then I'm going to insert that in here. Now what this is doing is I'm creating a table, and then right down here I'm inserting into that table. Now, if I create this store procedure and then execute it, nothing is actually going to be returned. It will insert the data into that temp table, but since I don't have a SELECT statement in this procedure, nothing will be returned. So let's write SELECT everything, and we'll just do FROM, and this is TEMP_EMPLOYEE, and right here. And so now let's create our store procedure. So that created successfully. Let's refresh over here and let's execute this. So let's just go down right here and say EXECUTE, and it's going to be TEMP_EMPLOYEE, and now we will execute this, and there is our output.

Now, really quick, let's go into TEMP_EMPLOYEE, and we actually want to change this store procedure. So we're going to go over to modify. So when we modify it, a few things are going to show up on your screen. The first thing that you're going to see is it says USE SQL_tutorial; so it's just specifying the database. The next two things you may not be as familiar with: it's SET ANSI_NULLS ON and then SET QUOTED_IDENTIFIER ON. If you don't know what these are, it's not super important. The first one just talks about how it deals with NULLs when you're using the WHERE statement, and then the quoted identifier just talks about how it uses quotes in the actual query itself. Again, not super important, but they have those automatically turned on. Let's go down a little bit further, and we're going to look at the ALTER PROCEDURE. So we created our store procedure, but now we want to alter it. So this is the ALTER PROCEDURE, and we are going to add a parameter to this. So what the parameter is going to allow us to do is when we're actually executing the store procedure, we can specify an input into that store procedure so that we get a specific result back, and I'm going to show you what I mean by that in just a second. But let's actually add our input, and we're going to say @, we're going to say JOB_TITLE, and we need to specify the data type that that is going to be. So let's just say NVARCHAR(100). I know below it says VARCHAR(100), but that's um not extremely important. So this is going to be our input, so we need to go down here and say WHERE JOB_TITLE = @JOB_TITLE. So when we actually are executing this and we say the JOB_TITLE is equal to, let's say ACCOUNTANT, this is going to become ACCOUNTANT, and it's going to give us our results based off of it being an ACCOUNTANT. So let's go over here, and we are going to click this EXECUTE TEMP_EMPLOYEE, which we just modified, and when we run it, we're going to get an error because it is now expecting us to include our parameter of JOB_TITLE. So what we need to do is we need to say @JOB_TITLE = 'Salesman'. Now let's try running this one and see what we get. And so there is our output. If we go back here, I just wanted to show you really quick: we do not have to put this JOB_TITLE right here. You can put this anywhere in the query and use it however you want. That's how parameters work, and that's why parameters are so useful, and you can use multiple parameters for one store procedure. So you don't have to just limit yourself to one or none; you can put as many as you really like.

So I hope that this video is helpful and that you understand stored procedures just a little bit better. Thank you guys so much for watching. I really appreciate it. If you like this video, be sure to like and subscribe below, and I'll see you in the next [Music] video.

What's going on, everybody? Welcome back to another SQL tutorial. Today we are going to be talking about subqueries. Now, subqueries are often called inner queries or nested queries, and they're basically a query within a query. A subquery is used to return data that will be used in the main query or the outer query as a condition to specify the data that we want retrieved. You can use subqueries almost anywhere. You can use it in the SELECT part of a query, the FROM, the WHERE. You can also use it in INSERT, UPDATE, and DELETE statements, but in today's tutorial we're only going to be looking at the SELECT, the FROM, and the WHERE statements, and you should get a pretty good idea of how to use it in those other statements.

All right. Now I'm going to paste on screen basically what we're going to be walking through today, but really quick let's just take a look at the table that we're actually be working in, and that is going to be from the employee_salary table, and I just want to show you the data that we're going to be working with before we actually get into it. So we have an employee_ID, we have a job_title, and then we have a salary. So really quick, I'm going to show you what it looks like to have a subquery in the SELECT statement. So let's go down here really quick, and what we're going to try to do is kind of do something like a window function but without actually having to do the window function, um, and so we're going to do this with a subquery. So I'm going to SELECT, and really quick, actually let me copy this. So we're going to do employee_ID. There we go. We're going to do salary, and now we can start building our subquery. So we need to do an open parenthesis, and I'm just going to copy this really quick because we're going to be doing it off of that table. So we're going to say SELECT, and then I'll paste that and close it as well. But what we want to do is we want to say AVG(salary). Now what this is going to do is it is literally going to run this, and let's run this really quick. It is going to run this and is going to show that the average salary for all the employees is $40,799. So we are looking at the average salary for every employee. So when we run this, it is going to give us the employee_ID, the salary, and then in the very last one is going to show the average salary for every employee. Now it doesn't have a column header, so or or a column name, so let's give it, um, let's say AS all_average_salary, and we'll run that one more time just to make it look a little prettier. Um, you can also do this in PARTITION BY, but I'm going to super quickly, just really quickly write this out, um, it should take no time at all, and then I'm going to show you why we can't do this without the subquery, why you aren't able to do this with a GROUP BY. So really quickly, let me copy this. I'm going to put it right down here, and we're going to say AVG(salary) OVER (), whoops, and we can get rid of all this, and we can say OVER (), and we're not going to partition it by anything, but let's run both these at the same time, and you'll see that they're the exact same outputs. And so it's just a different way of doing it in this example, but it really is just to show a comparison of how you might be able to use a subquery in the SELECT statement.

Now you might be wondering why GROUP BY does not work for this. Uh, really quickly, I'm going to write this out, and let's get rid of that, and we'll say GROUP BY, whoops, let me at least try to write it correctly: GROUP BY, and we'll do employee_ID, and we also have to do salary, and then we'll say ORDER BY 1, 2. So let's run this, and as you can see, since we have to use the GROUP BY, it groups by both the employee_ID and the salary, and so we're not going to be able to get that all_average_salary that we're looking for that we can get in the PARTITION BY and also the subquery in the SELECT statement.

Now I'm going to show you the subquery in the FROM statement. So let's just get rid of that really quick, and let's say SELECT everything FROM, and we're going to do an open parenthesis here, and here is where we're going to write our subquery. So if you have watched previous videos where I've done uh tutorials on the CTE or tutorial on the temp tables, this is one that is very much like those except I think a little bit less efficient when I'm doing something where I'm creating a table and then querying off of it, which is what we're about to do. I much prefer a CTE or a temp table. Subqueries tend to be a little bit slow compared to a temp table or a CTE. I tend to use temp tables a lot more because you can reuse them over and over, whereas a subquery you cannot; you have to write it out each time. So really quickly, I'm going to show you how it's done, although I don't really recommend using this method. Really quickly, let's go up here, and let's steal this PARTITION BY. Really quick, this will be our subquery, uh, and let's paste this in here. I'm going to make this look a little nicer just so you can visualize it a little bit easier. Um, so really quick, what this is going to do is it is first going to run this and create this table, again much like a temp table or a CTE. So let's execute this really quick. It's going to create this table, and then it's going to allow us to query off of it. So I can actually say, um, and let me give kind of kind of an alias to this: a.employee_ID and then let's say all_average_salary. So now I can take um columns from this inner query if I want to and just select those or I can select everything and return that entire table. Again, I much prefer a temp table or a CTE for this type of situation, but as an example, I just wanted to show you how it works.

Now let's go down to the subquery in the WHERE statement. But really quick, I just steal this query so I don't have to rewrite everything, and let's get rid of this really quick and add back the job_title. All right, so let's look at this really quick. So we have our table that we've been using: our employee_ID, job_title, salary. So for this example, we only want to return employees if they're over the age of 30, and as you can see in this table, there is no age column that is in the employee_demographics table. Now, if we wanted, we could join to that table and get that information, or we could use a subquery. And so for this example, we are going to be using a subquery. So let's go right down here and say WHERE employee_ID IN, and we'll do an open parenthesis, and now this is where we are going to build out the subquery. So just for visual purposes, I'm going to go right here. I'm going to say SELECT employee_ID FROM employee_demographics, and close the parenthesis. So we're going to try to select something in this subquery that will then identify the employee_IDs that are over the age of 30. So really quickly, let's take a look at this table. So right now we have the entire table selected, so we have the employee_ID, first_name, last_name, age, and gender. So in this subquery, the only thing that should be returned is the employee_ID, and in fact, in your subquery, you can only have one column selected. So I can't select everything; I have to specify one column, and that's a little bit different than how we did it in in this FROM statement where we were basically able to select the entire table, and then in the SELECT statement specify what columns we wanted. In the WHERE statement, we can't do that. So we want to return the employee_ID, and we also want to say WHERE the age is greater than 30. So let's run this really quick and see if it works. As you can see in the results, these are the employees who are over the age of 30. Now, if you wanted to display the age as a column in this output, you would have to join to that table and then put that column or that field in the SELECT statement, but in a lot of situations you won't actually want or need to do that, and so a subquery can be a really good option in these scenarios. With that being said, this is the last video in the advanced SQL tutorials. I hope that this series has been helpful and that you learned something along the way. Thank you so much for joining me. I really appreciate it. If you like this video, be sure to like and subscribe below, and I'll see you in the next video. [Music]

What is going on, everybody? Welcome back to another video. Today we are starting our data analyst portfolio project [Music] series. Now, before we jump into our first project, I wanted to talk with you for just a second so that we're all on the same page. First thing is that there are going to be four projects. The first one is going to be SQL, and we're doing a lot of data exploration, and we'll be setting up a lot of our data to visualize it in Tableau. Tableau is going to be our second project. In our third project, again we're going back to SQL, but we're going to be doing a lot more of the ETL process, so a lot more of the data cleaning. I did that one as the third project because I think it's going to be a little bit more advanced than this first project. I tried to make it as beginner-friendly as possible, so even if you are a complete beginner, as long as you've walked through, uh, you know, the tutorial that I have made on my channel, you should be pretty good. And then the fourth and the final project will be with Python. We'll be using a lot of pandas, doing a little bit of data cleaning, and then doing visualizations as well. As I said just a second ago, I'm trying to make this as beginner-friendly as I possibly can. The whole point of the series is that if you are trying to apply for a data analyst job, by the end of the series you should have an entire portfolio, or at least a really good start at a portfolio, to show a potential employer. I give you full permission to copy every script, every query, line for line, if that is what you want to do and create your own portfolio. I am totally fine with that, but I will encourage you, and I'm sure I'll say this throughout the video, I encourage you to try to think of your own queries, try to think of your own insights, and your own things that you can do to make this portfolio project unique. With that being said, I'm super excited to get started on this with you guys, so let's jump over to my screen and get started on our very first project.

All right, so now that we are on my screen, we are going to get started on this project. We're going to download the data set, we are going to format it just a little bit in Excel, and then we're going to get into SQL where we will start querying it. I will say that I think this is going to be a very long video. I'm hoping to keep it under an hour and a half. I may separate this into two videos depending on how long it runs, um, but you know, I I will do my best to keep it short, but we have a lot to get through. I'm going to basically do no cuts. I'm I'm that's my goal is to do no cuts um in this because I want to walk you through each step of the process so that you understand everything that's going on, and I I you don't get lost at some point, um, but I think this is probably the best way to do it. We'll see. The very first thing we're going to do is download our data set. So you know, as we're looking at this, there's an option right here to download the data set. I don't recommend that one, um, you can, it just won't give you all the information that I personally want, which is go back to like the very beginning. Um, if you go down right here to the very first graph, um, you can actually push this back and then download it, and what this will do is it will go back to I think January 1st of 2020. So let's open this one up, um, and when we get in here, we're going to reformat it just a little bit. It's nothing too complicated, I hope, um, I'm just going to double click here. Actually, let me let me go up here and filter just in case we want to filter anything. So, um, what we have here is a ton of information on COVID, I mean just a ton, and it goes back to early 2020. I believe it does go back to the first of 2020. So really quick, a really brief introduction of what kind of data is in here: we have total cases, new cases, um, total deaths, new deaths. We use those quite a bit in the the queries that are coming up. Um, if we go way over here, we have total vaccinations, people vaccinated, um, and then over here a little bit farther, we have population. That's the main stuff we're going to be working with today. As you can see, there's so many other things in here. I mean, you can use this if you want to go back and do more stuff on this. I highly recommend it. There's such, you know, there's so such unique data in here about smokers and diabetes and like all this random stuff that I did not do a deep dive in. I mean, I could I could spend, you know, a month just like looking…

At this data set, and and getting really interesting stuff from it. Um, but I'm not going to do that. I wanted to do this faster than, uh, two months to to complete what we're going to do. Um, is we're going to go back over here; we're going to take this population, and we're going to click on this, as, and we're going to click Ctrl X. And that's going to cut it. We're going to go back to the very beginning, and we're going to place it right here, and we're going to right-click and say insert cut cells.

Now, why are we doing this? Because I've already done this entire project, um, and if you don't do this, you're going to do a join with every single query you do, which if you want to do that, keep it there and then just, you know, change your query for for that. I did it like this because I wanted to show joins later on. I wanted to keep it kind of simple at the beginning, um, and then work my way to a little bit more advanced things, which you will see. Um, it gets, you know, semi-advanced, but not too much, I promise. Um, just stick with me. Let's go back over here; we're going to go to, uh, actually double A, and then we're going to click Ctrl Shift right key. That's going to select everything over here, and we're going to literally delete it. Okay, this is going to be our first table over here, so everything you see over here is our first table, um, and we're going to save that. So let's save as; I'm just going to keep it in my downloads as, and let's do covid deaths. So that has our death information. The next one is going to include our, um, vaccination information, which is what we're going to join on, and then, um, we're going to do that later. So let's let's hit Ctrl Z; that's going to bring it back. Now let's select on Z and go all the way to E, and we're going to do the same thing; we're going to delete this. Looks like there's no data, but I promise there is later on the vaccinations, um, like total vaccinations. If we go down, um, you can see that that starts on in February, the very end of February in 2021. That's because vaccinations are, you know, didn't come out till recently. Now let's save this file, and we're going to save as; instead of covid deaths, we'll do Co vaccinations. All right, now let's save that. So now we have our two excels that we want; we need to get them into SQL. We're going to go over to SQL, and we're going to create a portfolio project database. I've already done this; all you have to do, though, is right-click, click new database, type in portfolio project, and then click okay, and it will create your database for you. Um, if you open up the tables, it should be empty, and that's where we're going to put these two Excel files.

Now, uh, I had a ton of trouble actually importing these excels. Um, I mean, I tried everything, and I eventually just went down a rabbit hole of how to get these in. I don't know if it's me or or what, but I could not figure out how to do it. If you go to portfolio project, you hit tasks, and you hit import data; that may do it for you, and it may work. Um, it did not work for me; uh, it just it kept giving me errors. So what I would recommend you do right off the bat, just to make sure that we're doing the same thing, um, and you can do it that way if you want. I went over here to start; um, again, I'm on a Windows, and I went down to Microsoft SQL Server 2019 and clicked Import and Export. Looks the same, but for whatever reason, it it all the research I did; it has to do with the 32-bit versus the 64-bit. When you do it this way, it goes to the 64-bit, and it is able to import the data. If you do it the other way, it was doing it the 32-bit version and gives you an error. I don't understand it; don't ask me. That's that's the re that's I mean, I went down a huge rabbit hole, but this one works. So let's go over here, and this is going to be our data source; where is the data coming from? It's an Excel file, so let's do that. Let's browse, and let's go over to my downloads. I thought I saved it in downloads; uh, maybe because it's an Excel workbook; what was I saving before? Oh, that's a CSV. Okay, something important to note is we're doing an Excel and not a CSV; you're going to get the same error. I'm just doing it live, and I'm making myself look stupid, so, um, we're going to save it, but instead of a CSV, we're going to save it as an Excel workbook. So let's save that. Um, now we have to go back to how it was right here, um, the same way, and we're going to file, save as, and let's do this is now covid deaths and save it as a workbook. Now we have them. Now let's go back. Um, now we have our covid deaths and our covid vaccinations. Let's do our deaths first. Um, let me get back right here, so it looks kind of more normal. Um, so we have our Excel file; we have our covid deaths. Let's go next, and now we have to say where we're going to place it; where's our destination? So we're going to click over here and go down to SQL Server native client 11.0. I want to say this is something that I messed up, and it took me like 45 minutes to figure out; it was the stupidest mistake. Um, it's going to auto-populate a server name, and I never checked to confirm that this was my server name, and so I couldn't figure out why I wasn't able to insert this into my portfolio project, uh, database. That's because mine is 01; I created two different servers, um, intentionally, and for whatever reason, I forgot that, and so all I have to do is add 01 over here. So just make sure yours is is the same thing. Click portfolio project, click next. Yes, we're want to copy the data; should auto-populate; if it doesn't, if it gives you like multiple, you can always, uh, check mark on the one that you think is the right one; it should be the first one. We'll click next; we'll just click finish. I'm sure it says run immediately; we'll click finish and finish. Now, while this is running, um, there should be around 89,000; that's how it was like a week ago when I started it; maybe a little more now because there's extra days. Um, with that being said, you know, there's going to be a good-sized amount of data. Um, we're about to do a lot of different things; we're going to start at the very basics of just like querying the table, like super simple, um, and then we're going to go into things like joins, CTEs, temp tables, creating views. Um, the whole purpose of what we're about to do is not to it's not to keep it too simple. Um, I want to showcase to a potential employer, right, that you can do more advanced advanced things. So I'm going to probably do; I mean, I'm I'm looking at because I have already done this entire project individually; I mean, we've probably got like 15 to 20 queries here. You don't have to do all of them. Um, I'm going to walk through all of them, and you can choose which ones you want, but you don't have to do all of them; it is quite a few, so just know that. So there's 85,000 right here; that's fantastic. Uh, it won't show up immediately; you need to refresh it, uh, and there we go. So that's our covid vaccinations. U let's get rid of this so we just have Co vaccinations. Um, I thought that was our covid deaths one, but maybe I'm wrong. Um, but let's do the exact same thing down here, and we will import and say next; we're going to go down to Excel and browse, and now we want to do the covid deaths. Apparently, last time we did the vaccinations, which, um, I actually actually, you know what, I bet what it did was it took yeah, it took this right here as Co vaccinations, but that was the deaths one as it saved. So, uh, forget that. Let's go right here; let's do the Co vaccinations; it just has the same sheet name. Uh, so sorry for the confusion; destination is going to be the exact same place; it's going to be SQL Server native client; let's add that 01, and let's click refresh, portfolio project, next, next. Um, like I said before, if it does this, just click the first one; it's going to be Co vaccinations; it did that for the covid deaths; that's because I made the mistake earlier. I hope you I hope when you're watching this, you aren't super confused. Um, the whole point: make two tables or make two excels; one should be covid deaths; one should be Co vaccinations; upload them and then rename them, in a nutshell. U so we have the same amount; uh, let's refresh this; this one is actually the Co vaccinations; this one is covid deaths. I'm telling you this stuff is it's confuses me sometimes, to be honest. Um, but we're going to query this really quick to make sure we act are actually doing, um, what we're supposed to be doing. So let's do select everything from, um, and let's do portfolio project, and you can do dbo or you can do dot dot; I tend to just do that because it's easier. Um, let's look at this one; make sure it's the right table. So we have total cases, new cases; perfect. Um, and let's order on let's do three, comma four, just to make sure or order by, of course, just to make sure that we have all everything that we're looking for. So this looks right; this looks like our Excel. Let's copy this; let's go down here; we're going to do covid vaccinations, and let's run this one; make sure the second one came in correctly as well. So perfect. So we have our two tables; this is fantastic news, um, and now we can get going. Um, we can keep this one; I'm gonna comment it out in case, you know, we want to come back to it. Um, I'm going to really quick again right here; I have another laptop; I have already done this whole project, so I'm just using it as a guideline to know kind of what I'm doing next so that I don't waste everyone's time. Um, so really quickly, let's just let's select the data that we are going to be using. You don't have to use these comments; I will say that I'm going to specify; I'm going to say, hey, this comment is something I would keep in your portfolio project; I'm going to add a bunch of extra stuff that is not needed, um, just for your purpose, but when you are creating your portfolio project, you shouldn't be adding some of the things that I'm going to be commenting, um, on. So we're going to do, um, or actually let's do really quick; let's copy this so that it kind of knows what we're doing. So let's select the location, uh, the date, the to total cases, the new cases, the [Music] total deaths, and then population.

Now, where we're at, I'm going to turn off my camera because it's going to get it's going to start getting in the way, to be honest; I don't want it to interfere with your ability to see what we're doing on screen. So it's been great seeing you guys; I'm going to turn this off, and we will continue from here. All right, that should be turned off. So let's keep running. So this is what we're doing; let's actually let's keep this going because I I don't like things not being organized. Um, so we have our location; oh no, we want to do one, two; we want to do it based off the location and the date; makes things everything easier, I promise you. So we're going to be the first one's obviously Afghanistan; here's our date; we have our total cases, our new cases, total deaths, and population. So really quick, I'm just going to scroll down just a second. Um, they started having, you know, the the total deaths; it's um, it started about a month after they got their first case, it looks like, and then it just like ramps up a lot, um, and we're going to be diving into all these numbers, what they mean, how to you can do some really simple calculations on them, um, but really quickly, we're just going to do again a super simple calculation, um, and one that we do multiple times for different things. Um, so let's go right down here, and let's say, uh, we're going to be looking at the total cases versus total deaths. So how many cases are there in this country, and then how many deaths do they have per, um, uh, you know, how many deaths they have for their entire cases? So let's say they have a thousand people who H who've been diagnosed; they had 10 people who died; what's the percentage of people who died who had, um, who had it? So, uh, let's go right down here, and we're gonna I'm just going to copy this really quick; this just going to make our life easier; I think you should do the same as well. Um, so we have location, date, total cases, um, and we're going to get rid of our new cases; we don't need that one in this query right here, uh, nor do you need this population. So let's work on our calculation really quick; it should be super super easy. Let me make sure I'm still recording; perfect. Oh man, we're 25 almost 25 minutes in, um, or more because I have the intro. So now we're going to do, uh, we want to know the percentage of people who are dying who actually get infected or or or or who, um, report being infected. So we're going to do, um, total_deaths; we'll go right down here, and we're going to divide that by the total cases, total cases, and if we do this really quick, um, what it's going to have, and well, let's go down to where there's actually numbers. So we have 34; we have one; it's it's showing 0.029%. If you ever try to get a percentage of something, you have to multiply times 8 100. Um, so let's do that really quick; all we have to add is the what's that the asterisk sign, um, times 100, um, and while we're here, let's just add the, um, what's it called? Alias. Let's do let's call this death percentage; I don't know that that works for me, and let's take a look at this; it'll be a little bit more accurate accurate. So when there were 34, there was one, and that gives gives us a 2.94% death rate, and we can go down even further, um, and this is still all Afghanistan. Let's go down to the very bottom; let's go down to the very very bottom. So as of as of today, yesterday, there were 59,745 total cases in Afghanistan, and there were 20 2,625 deaths, which is 4%. So you have a 4% chance, basically, right now of dying; I mean, if if you want to look at it like that, 4% chance of dying if you get it and you live in Afghanistan. Um, let's I mean, we you don't have to, but really quick, just to look at it further, let's look at where the location, um, I think it's let's say like real quick because I'm not 100% if it's States; it should I think it's United States, but yeah. So I mean, I live in the United States; if you don't, you can look at your country, but, um, you know, we we this is like this is genuine real reported data, so it's really interesting. Um, right at the beginning, I mean, the I don't know if it was the way we were reporting or what, but we had really high percentage rates. Um, as we go down, we're looking at a 5%, 6%; I mean, this was the peak of it; this got really bad in the US. Um, maybe get I hope it gets better. Um, how many are we at? This is I'm going to go to the end of this year; we're sitting at around 2 to 3%. Um, um, yeah, it goes down to under 2%. So at the end of at the end of the year, we were looking at over 2 million people; that's 2 million; no wait, 20 million; 9363; wait, wait, wait; 20 million people who have been infected. Um, that's a lot; that's a lot of 20 million people who have had it; 35,000 or 352,000 deaths by the end of the year; that's a lot. Um, let's keep going. Um, and at the very end, we had over 32 m346fa. Um, there's a lot of deaths; 576,000, and I verified this number. Um, I Googled it; Google knows all; I googled this number, and it's pretty accurate, um, and it's really sad; that's a lot of lot of lives. Um, and that's 1.78%. So as of right now, if you were to get it today, an estimate is around one, uh, and three-fourths to 2% chance that you're that you could die from it. Um, so really interesting numbers; this is the kind of exploratory stuff that that, you know, we're going to be doing; we're going to get a lot more advanced as we go on, but this shows, you know, the likelihood, um, and we can I'm going to write that shows the likely; I hope I'm spelling this right; I'm not spelling this right; likelihood; I hope that's right; if this not, I apologize; likelihood of dying if you contract, uh, covid in your country. Um, again, rough estimates, but, you know, just glancing at the data, that's kind of what we're looking at. Um, now we're going to look at and let's go down here; let's look at looking at the total cases versus the population; again, we're going to do a lot of this like percentage stuff. Um, it it's pretty simple. Um, that will only last for so long, I promise you, but it'll be really I'm going to keep it on the states just because, um, I'm going to be looking at that one the most because obviously it's pretty relevant to me. Um, so if you're in another country, filter by your country; you'll be really interested in the stats; I I know I was really really really, um, shocked by a lot of the things that we're going to find today. So we're going to keep the location; we're going to we're going to keep the date; keep the total cases, um, but let's change this to population, and then instead of, um, the total cases being here, we're going to put the total cases there and then change this to population. So what is this going to do for us? This is going to show us what percentage of the population has gotten covid. So shows what percentage of population oops got covid. Um, some of these things again, they're they're good to know. Um, the one that I upload to GitHub will have the notes that I recommend keeping. Um, again, not everything in here is, um, not everything in here is what, you know, you need to have in there; this is mostly just, you know, what I think you guys need to see while we're actually typing this out. All right, so let's take a look at this. Um, actually, I want to change this; I want to put this right here just as easier for me visually, um, just for because the total cases right here. So our our population in the US is around 331 million. Um, so at the beginning, when we had one case, I mean, it's like nothing. Let's keep scrolling, um, and see where we get to 1%. So 1%; that's 3,311,32, uh, people, and that happened in what is that? August, August of last year. So 1% of the population; let's keep going all the way down; again, we're just kind of glancing at this; we're about 10%. Um, again, we're at the that 32 million. So 10% of the population has has gotten it; gotten a test, and it's been confirmed. So really interesting. Um, you know, we'll come back to that one, I'm sure in the future; I you know, we might make we might use this one as like, um, a visualization; again, uh, I'm only looking at the states or United States right now, but, you know, think about it in terms of how we're going to visualize this in the future, cuz a lot of what we're doing, we're going to visualize in the future, um, in Tableau. I have Tableau even open right here; you can see I have a map. Um, this is just a super; I threw this together in like two seconds. Um, we have the, uh, we have the location, and so, you know, this is like our future; this is what you need to be envisioning when you're looking at this data. So we have, you know, Afghanistan, and let's just scroll through; bellaro and Bolivia and Bulgaria and Cambodia; all the every single country, um, that that is reporting. So we're just

Looking at the states, but remember all of these are going to be used, so just something to remember. Um, I want to know, and I'm really curious as to what countries have the highest um infection rates compared to the population. So we're just looking at our population um up here. Um, how are we going to do this? We'll do—actually, let me say—well, let me write it out really quick. So let's look—looking at countries with highest infection rate compared to population. So that's what this script is going to do, or this query is going to do. I'm going to copy this. Um, so we're going to keep the location; we are not going to keep the date. This is not going to be date-specific; this is just going to be overall. And then we're going to look at the max of the total cases. So we only want to look at the highest. So when—when we were looking at the US, we had 32 million; we don't want to look at every single pop—uh—of the total cases; we only look at the very highest one. So we'll look at the Max total cases. Um, and let's right here, we'll just say give it an alias, at least something to recognize it. So highest UI guess we can say infection count. So we'll say highest infection count; that's the highest infection count per country—um—so per location. Um, and then we want to also take—because it's going—it's not going—since we don't have Max total cases here, if we just kept total cases here, it'll give us the same one that we were looking at in this above query. What we need to do is we need to look at the max of this. Um, so we're going to look at Max, and just add a parenthesis there. Um, and we'll look at—this isn't the death percentage anymore; I forgot to change it in this last one. This is—is what is this? It's percent of population infected. Let's change that for both of these because I don't want to get confused when you're looking at the column headers later. Um, so we'll look at the percent of population infected. Let's run this and see what we get. Uh, list is not contained in either the aggregate. Oh, I need to add a group by, of course. Um, so let's add Group by, um, and we need to group by both the population and the location. So let's try that really quick. Let's see if this works. Awesome. Um, well, we ordered on location and population, but I really want to look at the highest. Um, so let's—so let's just see really quick, look at some of these numbers. Got like 1%, 4%, um, 10%. Okay, so yeah, yeah, what we want to do is order on um this percent population infected. So let's go ahead and do that. Uh, and let's do that descending, so the descending gets the highest number first. Um, my goodness, 177%. So what percentage of your population has gotten COVID? It's been reported, and—and—and um, we can see that now. So the very first one, small population, so it doesn't surprise me. But if you look right down here, here, so that's that 32 million that we were talking about; that's that Max of total cases, um, which is the—the highest number of our infection count. So we have 33, so we're at—I mean, we're—we're right up there on the list. Let's look for other large countries. I mean, it's US, you know, there's Israel, there's Belgium, Portugal, France. So, you know, we're up almost to about 10% in a lot of these countries. So some—some of us, including the United States, we are—we are in there as well. Some of us have—have really high percentage rates; we just did not keep it under control. Um, and you know, a large amount of the population has gotten it; that's what this one shows.

Um, now let's look—kind of at the sad side of things. We were just looking at how many people were infected; let's look at how many people actually died. Um, so let's do—let's comment, and we'll say this is going—this is showing the countries with the—let's do highest—high—am I spelling that right? Yeah, highest death count per population. Um, now how are we going to do this? Let's copy this off the bat, but I don't know if we're going to do it the exact same way because we just need location, um, and not much else, honestly. So let's get rid of all this stuff, but we do need—we're looking at the highest death count, so like we did up here with the Max total cases, we're going to do Max, and then we'll do total deaths. I hope it's like this—total deaths. Um, and then we'll do as total—oops—total death count. Um, and we'll order that by the total death count. See, I don't need this; I think—yeah, I need to group by because there's an aggregate function. And let's try this really quick. Okay, so if you're getting this, there's a—there's a simple/confusing explanation to this total deaths right now. Let's go into our COVID deaths columns. Okay, let's show the total deaths, which is right here. It's an nvarchar 255; it's an issue with the data type. Um, oh wait, total deaths—no, total deaths right here; it's an issue with the data type. Um, it just has to do with how the data type is read when you use this aggregate function. We need to convert it—or cast it is what we're actually do—we need to cast this as an integer so that it's read as a numeric. Um, why I cannot 100% give you a perfect explanation for it, but this happens all the time; you just need to look at the data and realize, oh, it's probably because of this data type. Let's try something else, um, and then it'll work. So let's cast this, and we're in—casting it, I find, is just easier, but—just as int. Boom, there you go. So now we're taking this nvarchar 255 over here, and then we are converting it to an integer. Now let's run this. Um, and let's get rid of this just for visual—visual purposes. Now we are much more accurate, but we have a slight issue—or we're—we're now seeing a slight issue with our data—in our data—in the location section. We have a few ones that really shouldn't be there, ones like world or Africa, um, or South America. These are grouping entire continents. So let's go back up to our—let's go back up here, and let's do—actually, let's pull it up really quick because this is just part of exploring the data and figuring it out. So if we scroll down, um, we're going to f—we're going to see one like—right where is it? Right here. This—this location is all of Asia, whereas in other ones the continent is Asia. If I can pull one up real quick, so like right here the continent is Asia, whereas before the location is Asia. But if you also notice, um, the continent is null here. So what we need to do is say, um, uh, where continent is not null because when it is null, that means that this location is actually an entire continent, and we don't want that. Um, that may be helpful for us, um, later on, but it is not helpful now. So now this right here will get rid of that. Um, and just knowing that—figuring that out now, we can add that to every—every script. Um, and we can do—you know, you don't have to do this; I'm just doing this for, you know, visual purposes. I'm not going to do that for everyone. Um, so let's say where continent is not null, and now let's look at this, and now you can see that the United States is number one. And so number one is not the best thing to be number one in, but we have a death count of 576,000. And again, I—I googled this earlier; these numbers are pretty accurate. There, some of them are like a day or two behind. Give me a second; I'm going to take a water. They're like a couple days behind. Um, this number is actually higher, um, and as you know, as we continue to have more people die, unfortunately, that number just continues to go up. Um, so the data that—that you download may be a—a lot higher. Um, as of right now, we've been breaking everything out by location. Right, really quickly, let's just do this by something we kind of saw earlier, um, and I'm just going to do this for breaking it up purposes, but I'm going to say—I'm going to do caps lock—let's break things down by continent. How—sp—continent—contin—jeez, is that even how you spell it? I don't even know. Let's keep going. Um, but now we can do continent right here, and we'll just copy and paste that. Let's get that back up here. Um, and now we can see where continent is not null. Let's see if that makes that—yeah, okay. So now it's breaking it out by continents, um, with North America, South America, Asia, Europe, Africa, Oceana. Is this perfect? No—no, it's not perfect. Um, North America looks like it's only including the numbers from the United States and not Canada. Um, so we have some small issues in here, um, but for the purposes of what we're trying to do, which I don't think anyone's going—going to come in here and fact-check us or check the data—they may, and then you're—I don't know, you might be screwed—but for the purposes of hierarchy, um, and you know, drill that—drill down effect in Tableau, which is something we are going to do, we want—want to start including this continent in our—in our queries so that we can drill down, um, further into these things. Um, we can also do where—just wait—I'm going to do where isnull—actually, let me see. So before we were doing where continent is not null, but let's do location. I'm just—I—I'm doing this on the fly; I haven't done this before; I just kind of am doing this. Um, this actually is the correct numbers, and I don't know why I didn't do this before when I was actually creating this project, but now this is a wonderful, beautiful thing. I believe this is the correct numbers. Um, I could verify, but I don't want to do that live because I—I might look stupid, but I think this is accurate. Um, remember before we were looking at the location and the location, um, and it was actually the countries itself, and then there were ones where we did where is not null to get rid of all the ones that were like world and all those other things. Well, now I'm just filtering on those instead of deleting them. Before we were looking at everything but these; now we're only looking at these, and these numbers look a lot more accurate. So with that being said, um, I'm going to use this going forward in my script, so I'm going to kind of change things up to where—from what I originally had. Um, let me see though, because if that is the case, it may screw up our drill-down effect, um, which is highly unfortunate. I may—I—I honestly might just revert back to it for the pure fact that we want the visualizations to look correct. Um, just know that this is the right way, and if you want to go back and do that, I highly encourage that. I didn't figure that out my first time around, um, but I'm willing to admit when I'm wrong. Let me see what—let me do a time check. All, we're run like 50 minutes or so. I think we're gonna—we're just going to keep going all the way through. I—I—I don't think we're going to stop. Um, I don't think we're going to stop in this project. So we want to do some of the—the above queries were kind of what we were going for—nothing crazy difficult, right? Nothing crazy hard. Um, and now we want to—we want to start breaking this out by um continent as well. I'm—I'm going to go back and—is this correct? Let me look—no—so is not no. Um, so we want to start doing some of the above queries but adding that continent in there. You can even go back and add that as well, um, if you want to; that's totally fine. I'm going to do some more queries down here, um, or at least one more—one or two more, and then we're going to start getting—I think—into some a little bit more advanced things. We're going to start getting into some temp tables, uh, stuff like that, because we're going to eventually set these up in um views so that we have these views to um use for Tableau later. Um, and again, it shows you know how to create a view, so that's important. So we—we've—we've done this first one. This next one is going to—let me go down one more. This is showing the continents with the highest death count. So almost the exact same as we did before, but now we're looking at the continents. Um, we can even go up and look at—just wait—we literally just did that. Um, so that's what this one is actually looking at—my notes wrong—idiot. Okay, perfect. Um, now we—you know, we want to start looking at this from a viewpoint of—I'm going to visualize this, so how do we do that? What we want to look at—let's look at some global numbers. Um, you can do as many—many of these as you want. Anything up here, just add continent to it, um, anything—what—like group by—just replace it with continent, and you—and you got it. Um, so I don't want to go through and do every single one of those, but that is kind of the gist of what you might want to do, especially if you want that drill-down effect. And if you don't know what that is, um, you know, it's like clicking on North America, and then when you bring up North America, then it shows all the countries in North America, so Canada, uh, and the United States. And so it's a drill down, so you—like on Africa, and then there's all the African countries. That's what drilling down does, and that's what you can do when you have um those layers, so you have the continent, then you have the location. Um, so you know, I'm not going to—we—we'll look at that when we actually get to Tableau, but I don't want to actually spend all the time writing that out. Um, but what we now want to do is we want to calculate everything for the—across the entire world. So let's do this. Let's say—breaking—let's do global—let's just say global—global numbers—easier—easier than nothing. Um, all right, uh, I—let me really quick find the—I think it's probably the first one—the death percentage—let me—let me see if this is the one that we want. [Music] Okay, let me see. All right, so let's take this one. I'm sorry that took me a while to find. Again, I'm not cutting any of this stuff out; you just got to stick with me. You—if you're sticking with me this long, I know you care; I know you're not—you're not cutting away because I'm trying to figure things out on my side. So, um, let me get rid of this. So this is the exact same—SC—what—well, let's say where—just so we can get the right numbers. Um, so we are now going to look at the global numbers. Uh, so we're not going to—we're not going to uh include any location, any continent, or anything like that, but we do want to make sure that we're only looking at all of the um countries, and we're not looking at the world numbers plus all the countries because then the numbers would get astronomical. So instead of—now—now we can't do—so let's try running this really quick. So now we really can't do this, um, because now it's breaking everything out by—um—by you know that—which is the date; it's breaking everything out by the date because um these total case—the numbers are different, right? So really quick, let's Group by date, and now let's see what it looks like. Uh, it's going to give us an error, obviously, that's because we're looking at—that's because when we're looking at this, we're looking at multiple things, and we can't Group by just the dates. Obviously, if we wanted to group by something, which we need to do, we then need to—um—start using aggregate functions on everything else. Um, so really quickly, let's do some aggregate functions. I'm looking at my notes for just a second, um, to see what I did. Basically what we want to do, and I think what'll make things easier is—I mean, I could try to do the sum of Max total cases; I don't think that's possible. Um, let me comment this out really quick. Yeah. Um, it's because there's an aggregate function within an aggregate fun—function, and we can't really do that. Um, if we go back to the data, and you—we kind of looked at this earlier, there's one called new cases. Um, let's use this because instead of doing Max, we can just sum it—or—or—or do a sum on it, and that's going to give us the sum of all the new cases, which adds up to the total cases. So if we do this, let's see—this will give us on each day the total across the world because we're not filtering by any continent or—or—we're filtering out um like the world and in the actual continents; we're not filtering by location or continent or anything; it's just by date. So we're looking at the sum of the new cases. So now let's do—let's do the [Music] sum of uh new_deaths, and we can run that one. Um, operating data type and our chart is invalid for the some operator. So going back, um, and this is something I encountered a lot when I was doing this is these new cases is a float, which is why it's working in the sum, but the new deaths is an nvarchar. So what we need to do again is cast that as an integer; it's just the easiest thing to do. Um, and now that one should work. So, um, let's get rid of the—well, let's get rid of down to here. So we're—we're about to do another one, and that's going to be our death percentage globally across—across the—I guess the world. So we need to do the sum of—I think it's—we need to do new deaths, all right, divided by the sum of new [Music] cases, all right, times 100. Let's see what this takes us. Um, okay, of course, we're getting the same thing. Let me—let me put this right here and see if this works. Um, invalid data. Oh, that's because this was new cases; the new deaths one is right here. And let's run this, and now we are looking good. Um, and as you can see, the death percentage is right here; we have 91. Um, and let me give these—I don't—we can't—let me go back real quick and just say as total cases, as—as total deaths. Um, and let's run that again. Okay, and so across the world, these are our numbers. So we have total cases on that very first day that cases were starting to be reported; there were 98 total cases; there was one total death; that gives us a death percentage of 1% across the country—or across the world. And as we scroll down, it gets lower and lower, and that's cuz we have a lot of people who have gotten infected—are the total cases. Um, and again, that's per day, right? So if we remove this all together—that date altogether—which we can do right now, this will—this will give us the total cases, which is—oh gosh—let me read this through—one two—150 million, um, versus 3,180,26. So overall across the world, we are looking at a—a death percentage of a little over 2%. So interesting numbers. You can keep both of those queries separate if you'd like. Um, you know, they might come in handy later. But let's do this. So we have—give me one second—check on my notes again because I just want to make sure I'm not doing something stupid. All right, all right. So again, we have a whole another table that we haven't used yet; uh, it's this COVID vaccinations. And just to, you know, refresh your memory, let's do—let's look at the table from portfolio project.COVID vaccinations. Let's jog our memory on what we got here. So we have—we have these tests; we have—vaccinations over here, which was what we're actually going to be using. Uh—excuse me—me—that's what we are going to be using. So let's join these two tables together. Uh, and let's—let's actually just do from—actually, let's just do this whole thing from—let's do COVID deaths, and here's

How we're going to join it? So we're going to say JOIN, and we're going to say, "Oops, wait, that is wrong." JOIN, and we're going to say ON. So what are we going to join them on? Um, we're going to join them on two things. We're going to join them on location because that's much more specific than the continent. We're going to join them on location, and we're going to join them on date. Let's call this one DEA. Let's call this one vaccination, so a little alias for these so that we don't have to type out this entire table name each time. So let's do dea.location = vac.location and dea.date = vac.date. And let's just see what we get really quick. So we'll have all of these things, and let's look at Granada 0717. Let's go all the way over here, and it should have Gren 0717. So just making sure that they were joined correctly. Um, for this query, what we're going to do is look at the total population, and let's do that right here. So looking at total population versus vaccination. So how many pe—what is the total amount of people in the world that have been vaccinated? That is—that is what we're going to do in this query right here. So let's do dea.continent, location, uh, dea.date. Again, these are going to be the same in either one, but we have to specify. Um, let me just—for example, if we do population, population—oh, actually, that's a terrible example—um, because population's only in one. Let me go back real quick. Let me say I only write DATE. That's going to give me an error because there's DATE in both of them. In fact, we joined it on them, so we know there's DATE in both of them. So it's going to give us an error. We just have to specify what table we want to pull it from. So we're going to do dea, um, and dea.population, just to keep it consistent. Um, and now we're going to add the next one, dea, and let's do new vaccinations. Um, and really quick, let's just look at this. Um, and let me get my orders cu—I want it to be organized. I—I actually—one—let's do one, two, three. I don't like it when it's not organized; it bothers me. So we're looking at—oh, no, I also need to add OR continent IS NOT NULL. There we go. Uh, da. Perfect. Now let's run this. This should look much better. There we go. All right. We are—in fact, if we want to look at Afghanistan, like we have normally been doing um in previous ones, we do two/three. So there's our population; here's our new vaccinations. Now let's see. We're going to go back, go down, and let's see. They have vaccinations starting on 2/18. Um, if we go even further down, let's just go to—who's this? Canada. Oh, yeah, Canada would be a good one to look at. They started doing vaccinations on—right here—so 12/15. I mean, they started very early, and their numbers only increased, and now they're, you know, doing—this is per day, right? So this is 288,000 in one day. Um, so that's, you know, really high numbers, but this is the number of new vaccinations. Um, there is a column called total vaccinations in this table, but we're going to do something pretty—just to display—again, this whole portfolio project is to show potential employers that you know how to do certain things. So I want to set up opportunities to do that. We're not going to use the total vaccinations; we're going to use this new vaccinations, which is new vaccinations per day. Um, so we want to—we want to know or do kind of like a rolling count um out here. So as this number—let me go back to the beginning—as this number increases—718, 2300, 4179—we want it to add up over here. It's a pretty cool thing. I mean, you know, it's—once you see it, you'll be like, "Oh, that's pretty easy," but, you know, we're going to be using partition bu—we're going to be using um uh this—a Windows function, so it's really good to—to showcase, I think. So we're going to do um—and let's do um—we need to do the SUM because we're going to be adding these together. So we need to do the SUM of new vaccinations. Oops, do the SUM of new vaccinations. Let's do OVER, and we're going to say PARTITION—oh, gosh—PARTITION BY, and we need to PARTITION BY the location first and foremost because we're breaking it up by—if we do it by continent, the numbers are going to be completely off. We need to do it by location, location, and—and also partly the date, but you'll see that in just a second. But we need to partition it by breaking it up by um location. And why is that? Because every time it gets to a new location, we want the count to start over. We—we don't want this aggregate function to just keep running and running and running; it'll ruin all of our numbers. We only want the—this part—a partition on the—the location so that it runs only through Canada, and then when it gets to the next country, it doesn't keep going. Um, and if we only did that—by the way, let's look at what this looks like. Uh, okay, real quick, I need to cast this um as an integer, like we've been doing in the past. You can also do um—real quick, I want to show you another one—CONVERT, and I think it's comma [Music] integer, um, or is it integer, comma? Let me try integer, comma. I think it's that way actually. Um, and you can do it this way as well. That is up to you. Um, you know, either one is totally fine. If you want to use both, that's even better because then it kind of shows you can do both. Um, but they basically do the exact same thing. So let's go down and let's see what—what's happening here. So it goes down to Albania, and since we're partitioning on Albania—Albania—their total amount of vaccinations is 347,000. I know that going into it because it has it on every single stinking row. But down here, they started to add—they started to add up, right? But we didn't do that. We only partitioned on location, so it added—it did the SUM of all the new vaccinations by that location. So what we need to do is go over here and say ORDER BY, and we need to order it by both the location—oops—dea.location and the date. That is very important. Uh, the date is what's going to separate it out, um, and you'll see in just a second what I mean. So now let's run this, and let's go back down to Albania, I think it was. So here's Albania. Let's go to our first one. So here's what we have: We have 60, and it gives us 60. Then we add 78, so we add 60 + 78 = 138. Then 78 + 178—sorry—60 + 78 + 42 = 180. Then 60 + 78 + 142 + 61 = 241. So you get the point; it adds up every single uh consecutive one, and when there's NULLs or there's zeros, it's going to uh not anything; it's just going to keep it uh going. And then you can see as it's—it's a rolling count. So we're going to name this—let's do AS—let's do AS—rolling people vaccinated. Let's call that—I think that's good. Now what we want to do is actually look at the total population versus the vaccinations. Um, and really what we want to do is use this rolling people vaccinated. We want to use the MAX number because at the very bottom is our MAX number. This is how many people in Albania—we want to use that number and divide it by the population to know how many people in that country are vaccinated. So what we want to do is we'll do this: We'll do rolling people vaccinated / population * 100. And as you can see, we're getting an error: You can't use a column that you just created to then use the next one. So what we need to do is we need to create either a CTE or a temp table. Um, this is at—this is the time of—of the show—of this tutorial—whatever you want to call it—where I'm going to give you some options. You can do one; you can do both; you know, there's no preference to me. Um, but we're going to take this, and we're going to—at least for this first one—we're going to use a CTE. So we're going to say—excuse me—we're going to say WITH, and let's call it um pop_vers_vac—I don't know—population versus vaccination, and then all we need to do is specify the um basically the columns that we're going to input. Um, so let's put AS, and let's insert that down here because what we need to do is we want to say um we do continent—oh, gosh, I'm so bad at spelling—continent uh location, date, population, um, and then we'll have this rolling people vaccinated. That should be it. Um, and let's see if there's—we just need to close this parenthesis. So this is our CTE; it should be working. Um, actually, that's not true. I need an open parenthesis here; that's why it's giving me that error. Um, let's see. It's—I'm still getting an error, so let me see if I'm doing something wrong. Do I have this in parentheses there and there? I say WITH pop_vac there, continent, location, date, population. Ah, I believe that is the issue. So then we need—we just need to add that last column, new vaccinations. Um, if the number of columns in the CTE is different than the number of columns here, it's going to give you an error. So you got to make sure. Um, and then let's just say for real, for right now, SELECT everything FROM, and we'll do—and we can even say pop_versus_vag; it'll come up right away. So really quickly, let's run this and see what happens. Uh, the ORDER BY clause can't be in there. I knew that, but whoops. Let's comment that out. Let's get that all the way up here. Let's run this. So now that query that we were looking at before is now in here, but now we can actually use it to perform further calculations. Um, so we'll just do everything, comma, and then we'll do rolling people vaccinated uh /, and that needs to be population * 100. I'm pretty sure this is incorrect. Give me—me a second. Um, invalid object. Oh, it's because I have to run it with the CTE. My bad. Um, so let's look at this percentage really quick. Um, it's not wrong, and it's actually going to give us a rolling number, and this may actually be what we want. Um, so basically what it's doing is it's taking this column and doing it versus this column, and so this number should only increase because as this number increases, this number will increase because the population stays stagnant. Um, again, I'm kind of looking at this as we go. So right now, 12% of the population in um Albania is vaccinated, so that—you know, that is—that's all we know. I don't think we need to go any further than that. I think um if you want to, you can look at the MAX one, um, but you'll have to get rid of DATE and just keep the location, um, population, etc., because the DATE is going to throw everything off. So if that's something you want to do, absolutely do that. Um, you can use a temp table here. Uh, we can look at how to do that really quickly, I think, um, so that you guys know how to do that. Again, I recommend throwing in one or two of these, um, like even up here, you can do different um different counts and then do one for each. Um, so let's do temp table. All right, so it's going to be a lot of the same stuff. We're going to keep this, and this is going to be what we insert. So let's say INSERT INTO, and we need to write where we're inserting it into, but let's say uh—again, I'm only doing this for—it's going to be basically the same; it's going to have the same effect, but um with a temp table. So uh we're going to do temp table, and let's look at um let's say—let's call percent_population_vaccinated, and we need to specify our columns. So let's go down here—excuse me—let's go down here, and let's do the basically the exact same thing. So continent—I think I spelled that right—no, I didn't spell that right. I almost did. I got really confident. We'll do we—and—and just so you know, for these, we have to specify the data type as well, um, because we're basically creating like a genuine table; it's just a temporary one. So let's do VARCHAR(255). We'll do um location; we'll do the same thing—VARCHAR—oops—255. We need to do DATE, and we'll do that as DATETIME. We'll do population, and we can do—I mean, there's lots of different ones we can do, but we'll do NUMERIC for this example. There's new_uncore_vaccinations, and let's do that one as NUMERIC. Again, you can use different things, um, and then we'll do rolling_people_vaccinated. Um, this can—can be NUMERIC as well. Um, and then we need to insert that into here. Okay, so we're inserting the data, and then down here we can actually select it. And let's—let's take this and do right here, except we're going to be doing this by this right here, but it hasn't been created yet, but it will be created in just a second. Okay, so you—let me see if—yeah, so these were the rows that were affected, um, and—and then we got our actual output from this right here. Now let's say you wanted to change something in here. You're like, "Oh, you know, I—I don't want to do it. We—this—" Let me comment that out, and then let me do this, and um create that table again. Oh, no, we got an error. Um, how can we get around this? Very simple. I've done this in a—I should do this in a different one. You can do DROP TABLE IF EXISTS, and then do this right here. Um, and when we run this, it should give us our output. I highly recommend just adding this, especially if you plan on making any alterations, so that when you um run it multiple times, you don't have to, you know, go and then delete the view or—or delete the temp table or DROP TEMP TABLE or, you know, it's just built in; it's at the top; it's easy to maintain, and it looks good. It's—it's something that—that a lot of people do. And so if you have that at the top of your query and somebody—you know—somebody who wants to hire you looks at this, like, "Oh, okay, that makes sense. I'm glad they included that; they know what they're doing. This guy's smart; I should hire them." Um, now what we're going to do is uh I feel like I've showed you as much as I can show you um with the limited data that we've looked at. Again, I could have done this for six hours straight if I had used all the data—at least, I mean, there's just so much data. But let's create a view. You know, I'm only going to show you how to create one view, but I want you to go back and create multiple views. You know, if this is one that you want to look at—these global numbers—let's look at this one really quick. If you want to look at this number right here, toss it in a view. I mean, that one doesn't make sense to toss in a view, but this one—toss these numbers in a view. Um, and we're—we're going to um look at it in Tableau later, but for right now, let's just create our view. Um, so like let's just say creating view to store data for later visualizations. All right, so let's say CREATE VIEW, um, and I want—I'm just going to keep the same thing um like that. Um, and for views, it's so easy. I mean, I'm literally just going to—and I can even take um the ORDER BY—I believe—we'll see if I'm correct. Um, actually, let's get rid of both of these things. So it says CREATE VIEW percent uh percent_populate—oops—percent_population_vaccinated, um, and let's see—am I doing anything wrong? [Music] Here, let me see—the ORDER BY clause—I was completely wrong. I was wondering why I was getting that. Now let's try running it. Okay, so it ran successfully. Um, let's look at our views. It's not going to be in there. Let's refresh it. Hey, look, we got our very first view. We can open that up like a table if we want to. Isn't—it's—I mean, it's gorgeous. Um, if you want to get rid of that—SELECT—or sorry—CONTROL+SHIFT+R; that's a refresh. Um, and now it—it basically recognized it. But let's go back here for a second. Um, and you know, we can now query off of that; it's a view now. So you know, it's—it's something that you can—it's permanent; you know, you have to go in and actually delete it. It's not like a temp table. This is now permanent, and this could be something that we now use for a visualization later. So do some of these—look at some of the queries that we've looked at and create a few of these views, um, and we will use them later. Um, normally, in like a normal setting, uh, if I was actually working, I would put some of these in actual—like I would call them like a work view or a work table or something set aside so that I can use them consistently. Um, but I would also set them aside so that I could connect Tableau to that view. Now we're going to be using something called Tableau Public; that'll be in the very next tutorial, unfortunately. Um, let me see if I can show you—I can't show you—Tableau Public does not connect to SQL databases, um, and that's because it's free, and I totally get it. You have to pay for the upgraded version, but I am not a—a billionaire. Okay, I cannot afford uh the real version of Tableau. I'm also not like a student or—or like something where I can get it cheap, so I'm not paying for that. So we're going to use Tableau Public, and—and I recommend this anyways because anybody can access it; it's—it's free for anybody. So we're going to be using Tableau in the next one to actually visualize a lot of these things. I want to get at least five visualizations. We're going to create a dashboard; it's going to be a beautiful, beautiful thing. All right. So the very last thing that we are going to do is we are going to actually save this and then put it into GitHub, and I just want to show you how to do that. That's where we're going to be storing our code, at least for now. Um, so let's go up here; let's click File; let's click Save As. I've already have multiple versions of this. Let's just put B2. We're going to save that. So we have this saved. Now I'm going to go over here; I'm going to go to my GitHub. Now if you don't have an account, I highly recommend getting an account so you can start putting your portfolio projects in here. Of course, we're not going to put our Tableau one in here, but our SQL ones and our Python ones you can put in here. Again, I'll talk a lot more about how we actually want to display this in GitHub or other places, but what we're going to do for this is we're going to create a new repository. Let's call this one portfolio_projects. Make it public. We'll create the repository. We'll do all that extra stuff later. So what we now want to do is upload an existing file. We'll click right there, go to Choose files, and we'll click this latest one that we saved, uh, and we'll open it, and we can always change the name of it later on, and you can add notes if you'd like, but we'll commit that change. So we'll actually upload this uh this file. Um, but let's look at it really quick, and I'm going to go back, and I'm going to use the real one where has the formatting and—and the notes that I have that I wanted to add in there. But as you can see, you know, you can see all of the queries that we wrote, and this is fantastic. So if somebody comes in here, you know, we'll have more notes and kind of better comments on what they do um and what the takeaway is—this—from—for a hiring manager to, you know, when they actually look at this. So this is a really, really good place to start. Again, uh, this may not be your optimal place.

To put this, I'll give you a few different options in a later video about how we can actually, uh, potentially improve upon this. I'm really looking forward to getting more portfolio projects done so we can actually start building a compl complete portfolio.

Uh, if you've stuck around all this way, I just want to say congratulations. I mean, I know this was a long video. I know that it took a long time, but you stuck with me. Uh, you you put in the hard work, and that is fantastic. And I really hope that it pays off, and I hope that this has been helpful. Thank you for watching. We'll have a lot more, uh, videos in the future on these portfolio projects, and I'm I'm just really really looking forward to doing them, to be honest. So thank you for sticking with with me. Uh, thank you for watching. I really appreciate it. If you like this video, be sure to like and subscribe below, and I will see you in the next [Music] video.

What's going on, everybody? Welcome back to another video. Today we will be heading back in a sequel for our third portfolio project. Now I am extremely excited for this project in particular for a few reasons: one, we're getting back into SQL, and I really like SQL; and two, we are finally focusing on data cleaning. I have talked so much about why data cleaning is important and that you really need to learn how to clean data and that that's a big part of what a data analyst does, but I haven't actually showed you how to do it yet. And so that is what this whole project is going to be, and then at the end you'll get to add it to your portfolio, so it's really a win-win.

Now, before we start, I just want to say that I think it's going to be a little bit more advanced than our very first video in Sequel where we walk through data exploration. If you see something that you have never seen before, I will do my best to explain it while we're walking through it. But if you get confused or it seems a little complicated, please pause it, Google it, do a little bit of research, and then come back, and I think that will be very helpful. With that being said, let's jump over to my screen, and we'll get started on the project.

So we're going to start over here on GitHub, and this is where I've actually put the data set that we are going to be using. So I will put this link in the description. Uh, we're going to go right over here to the Nashville housing data for data cleaning. All you have to do is click download, and it's going to download it, and you can open it up if you want to. We're not going to do anything to this data at all, but really quick, I'm just going to show you what it does look like, um, and we'll of course look at this in SQL in just a little bit. But we have a unique ID, parcel ID, uh, we have this address, a sales date, uh, the price of the home—so this is housing data if you didn't pick up on that already—uh, who actually owns the home, the owner address, and then some information about land value, um, bedrooms, bathrooms, things like that. Again, not super important, um, because we're going to be doing all of this in uh SQL. So let's actually get this data into SQL. We're going to import it the exact same way that we did uh in the very first video. So we're going to come right over here, going to go all the way down to Microsoft SQL Server 2019 Import and Export. We'll click next. Our data source is, like last time, a Microsoft Excel, and let's take a look, and we'll take that first one. This is the most recent one I've downloaded, but I just wanted to make sure, so I downloaded a few times. Um, for the destination, we're going to click SQL Server native client 11.0, and this is my client or my server right here, and I'm going to go down here, and I want to put it in this portfolio project. So you know, just configure this to what your server is. Um, again, if you haven't done this before, you've never set up SQL server or a server um to go on SQL Server, I will leave a link hopefully right here also in the description, uh, like I did for the first project. So, um, you know, be sure to go through that video so that you know how to download this and have everything. We're going to copy the data; we're going to take sheet one; um, we could rename sheet one to something else, but uh, we didn't; and then we're going to finish this and finish, and it should run successfully. Hopefully it's looking good. Perfect. So we have 56,477. So let's head over to SQL.

All right, let's go to our database portfolio project, uh, and here is our sheet one. Now I'm going to rename this—um, let's rename name it what is it? Nashville—let's just do Nashville housing. That's what I'm going to rename it as, um, at least so when I post these queries um to the GitHub and you see them, this is what they will be. So if you want to have them the exact same or be able to copy and paste them, um, you know, you should you should do that as well. So let's take a look really quick. Let's select the top 1,000, but there's about 56,000 rows; there's a lot of data in here, um, and a lot of things. So, uh, I'm about to open up a a save thing, and we'll walk through the exact things that we're going to be working on in just a little bit, but um, yeah, this is what the data looks like in here. There's lots of columns, uh, lots of data. So really excited about this. Um, let me pull this open really fast. It's going to be this project walkthrough. Here are the things, and I'm going to show you this really quickly. Here are the things that we're going to be walking through: so we're going to standardize the date format; we're going to populate the property address data—that's referring to this right here. If you notice, there's the address, and there's also the city that it's in, so we want to be able to separate that out—um, and that is actually right over here. We're going to be doing the same same thing to the owner address, except that has an address, a city, and the state, um, which makes it a little bit more complicated, and so, um, that one should be really really cool to to show you. Oh, whoops, I I messed up. That's what this one is: breaking out into individual columns. That's where going to do for that. This popular in the property address, um, you know, if you notice, and we'll go into this a little bit, there's actually some values in the property address that are blank, but I'm going to show you how you can actually populate that, um, which, you know, is a it's just a cool trick that I've used a few times, and it it it does work. I think you'll find that one interesting. Um, in the sold as vacant field, we're going to be doing some um some case statements, if then, um, then we're going to be removing duplicates and then delet deleting unused columns. So we have a lot to get through. This could be potentially the longest video, and I'm okay with that, um, because I'm I love SQL down here, and and I will say that when I when I in the very first video I said it was going to be an ETL video, um, and I fully intended on doing that, but I ran into not issues on my side but issues in the fact that the ma vast majority of people who are going to be watching this are not going to be able to do what I did to configure my server, um, but I left it in here anyways. When I think ETL is an automated process in order to uh extract the data from somewhere, we're going to transform it and then put it somewhere. This was going to be the extraction method, um, and I was going to put it in a store procedure so that you could um, you know, run the run the store procedure, run the job, import the data. It was going to be really cool, but I know that if I was having trouble with it, me trying to explain it to you and you being able to figure it out on your side was going to be very tough. I left the this anyways because I was able to get to work on my computer, um, but it is tough, and it took a lot of research, um, and I did this for a previous server like a year or two ago, and I remember it being crazy hard, but I was able to figure it out on my computer. So if you want to try it out, um, try it out and and look into the stuff. So I'm going to leave this here. This is just for if you want to try it; it's a little more advanced, um, and so you don't have to just important, and this will be a data cleaning project instead of an ETL project, but data cleaning is what 90% it was going to be anyways. Um, anyways, let's go back up to the very top really quickly. I have a whole another laptop right here, as I did in the first video. I didn't show it to you last time, but um, I have all of my queries written out over here. I'm going to try to do this as quickly as possible. We have a lot to get through. Now, before we start writing our queries, I am going to turn off my camera so I do not get in the way.

All right, you should still be hearing my voice. Let's let get started. Let's just start with select everything, and we'll do from uh and it is portfolio project.db.Nashville housing. So let's just get this pulled up on screen. Awesome. So this is exactly what we were looking at before, and the very first thing that we're going to be looking at is this sale date. Now, uh, I wrote standardized sale date, but I'm really just going to change the sale date, um, so let's copy this really quick, and let's look at just s date, and it has this time on the end, and it serves absolutely no purpose, and I it just annoys me. I want to take that off, and so right now it's a say it's a date time format, but we're going to convert, and we're going to do date, and we're going to take sale date, sale date, and we're going to go like that, and let's run this really quick, and this is what we want it to look like. All right, so let's say update, and we have portfolio project specified up here, so we can just say Nashville housing, and we are going to set sale date equal to, and we're just going to copy this. Now I will say before we do this, um, I had some issues in my when I was initially doing it, whether or not it made the update, and I was I'm not sure why why not it was doing it, um, so yeah, it's not doing it right now. I you try it out on yours; it may or may not be working. I'm not exactly sure why that is because I would say like 80% of the time it's doing it, 10 20% it's not. I don't know why, um, no logical explanation of that, but uh, when I most the time when I did it, they would then be the same column. Something we can do, I just thought of, we can do alter, alter can't even say that word, alter table, and we can say um I think it's new or it's add, add, um, give me one second. Yeah, so add, and we'll just do sale date converted, um, and let's make that a date format, and bum, just like this, and then we can say like this and say sale date converted, um, let's try this and see what happens. So I'm going to add this column, and then I'm going to update this, and it says it's affected. Let's see what happened. Uh, so let's write sale date convert, sale date converted. Let's see what happened. Let's see if it actually worked, and it worked. Okay, so we we now have a column, um, and maybe at the end we'll remove that sale date column, U so that we just have that sale date converted, but we know what that is. You don't have to name it that; you can name it sale date to or something like that. Um, cool. Well, let's go down to the property address, and let's get a just a really quick look at it. Uh, let's copy this up here. I hate rewriting this stuff, so I'm always copying and pasting, um, but we're going to be working with the prop address. There we go. So let's take a look at this really quick. Um, so let's look at, sorry, I was looking at my notes. We need to look at where the property address is null. So what you'll see really quick when we run this is that there are null values. Um, why there are null values? Yeah, I really don't know. Um, I I really am not sure. But let's look at everything where this is um where it's n. So we have this property address, we have a sale date, a price, legal reference, um, there's this parcel ID, and there's this unique ID, um, so we have a lot of information, and when you have something like this, something like a u an address, an address is, you know, the address isn't going to change; the address is the address. The owner, the owner's address might change, but the property itself, the address 99.9% of the time is not going to change. So you can say with almost certainty that you know this property address could be populated if we had a reference point um to base that off of. So really quickly, um, let's look at just everything, and let's look at, and we'll just order by let's do property not property address, uh, let's do parcel ID, and let's take a look at this. So we have to do a little bit of some research on this, um, but I'm going to show you something really quick. Let's see if I can find example um in not too long. Okay, so here's an example. Here's the same ID, so 015 bum, and that's the exact same address, and we'll find this a lot of times, and I look through the data, and it is pretty much accurate, um, when it does have it, it it is the exact same address. So this parcel ID is going to be the same as the property address, um, so something that we can do is basically say if this parcel ID has an address and this parcel ID does not have an address, let's populate it with this address that's already populated because we know these are going to be the same. That is basically what we are about to do, um, and it's not super complicated, um, but let's get started writing it. Let's copy that down there. Um, one thing we are going to have to do with this is do a self-join, so we have to join the table to itself to look at if this is equal to this, then this needs to be equal to this, that kind of thing, um, so real quick, let's just write that join part out, and we'll go from there. I don't know why I sounded Canadian right there. We'll go from there. Uh, so we'll join on this, and we'll say on a do oh wait, let's let's label them. I'm gonna do this in a really lazy way. I'm just going to do a and b, a.parcel ID is equal to b.parcel ID, and um, let's see really quick. So we need to find a way to distinguish these; the sale date could be the same. Um, one thing this unique ID is is unique, so we need these to be different. So let's use this, and let's say um let's say and a.unique ID is not equal to b.unique ID. So all we have done here is we've joined these the same exact table to itself, and we said where the partiel ID is the same, but it's not the same row right, because this is a unique ID; unique will never that means these will never repeat themselves, so we'll never get the same one. So if this is equal to this, but these are different, we want to then populate um populate the other one. So let's do a.parcel ID and we'll say a.property address, b.parcel ID, comma bproperty address, um, and let's take a look at this really quick, and let's do let me see if this works where aproperty address is null, and let's see if see what comes up here. Okay, so this is perfect; this is exactly what I wanted to see. So we have this parcel ID, we have this parcel ID, and here is our address, and it's blank in all 35 of these. So we have an address for all of these, but we're not populating it. So what we want to do is we want to say use this thing called isnull. So isnull is basically saying it's the first thing is what do we want to check to see if it's null. So we want to check aproperty address; this whole thing. Now, if it is null, what do we want to populate? Um, we want to put in there this B.bproperty um address because we want to take that property address and stick it in there. So, um, let's run this really quick. So this row is what is eventually going to be stuck into this row. So this is perfect; it's literally saying when it's null, take take this and put it there. And so that's what this um this part of is doing. So let's go in here and write our update, uh, so we want to update, and let's take this whole thing from here up, and we this will be the set oops, um, so we're going to set um property. Okay, we need to specify, um, and just so you know, when you're doing joins in an update statement, you're not going to say Nashville housing. Okay, that's going to give you an error. You need to use it by by its Alias. So let's put a. So now we're going to say property address is going to be equal to, and now we're just going to copy this is null and put it right here, and we only want to update. Let's see if it it does take this. So I think this should be correct. Let's let's test it out really quick, and we're going to run this above query and see if it made that update. All right, so there you go, um, as you can see, there are now none that have null in there; otherwise it'd be giving us an output right now. So that one is fixed. We can go back and check it if you want to, please go back and and double check that, um, but that is what we did, and it worked perfectly. So that's what that is null does; it checks to see if this is null; if it is null, it it it can populate with a value. You can also do like a string, and what we I mean you can write, you know, no address if you wanted to do something like that. We don't want to do that; we're going to keep it how it is. Let's keep moving on. We do not have unlimited time here. Trying to keep this I'm going to try to keep this on one under two hours, stretching the rules because for my love of SQL, and that is the only reason, um, and this I think is going to take a little longer. So let's take a look, and let's copy this real quick, and let's take a look at uh what are we doing? The property address, the property address, um, and we can get rid of this as well. So if you notice, we have two things here: we have both the address, and then there's this comma after all of them, and there is the city. Now, you know, you don't know that or you maybe you haven't looked into this, but I have, and there are no other commas anywhere except for in between these things as a separator, as a delimiter. Um, a delimiter is lit if you don't know what if you've never heard that term, delimiter; a delimiter um is something that separates different columns or different values. So for us, the delimiter is a comma, and for this first one, because we're going to be separating this one out, and then we're going to be doing the owner address, um, for this one, we're going to be using something called a substring, and we're also going to be using something called a character index or a charart index. So let's start writing that out, and let's do select, and let's say substring. Now the substring that we want to take, we of course want to be looking at oops, let me um

Put this down here so it helps us out a little bit, and I'll get do like that so substring. And of course, we're looking at property address, and we want to look at position one. So we're going to start at position one.

Now, this next part is something that you may have never seen before, um, and if that if you haven't, that's totally okay. Um, we're going to be the character index is going to be searching for the um, it's going to basically be searching for a specific value. Okay, that's all it's doing, and you and you can look into this a little bit more if you want. Um, so it's going to be CharIndex; that's how it's spelled, and then like an open parentheses. And we want to specify what we're looking for, so it can be anything. You can even do, you know, if you wanted to things like um, Tom, or you can do Val, well you do it um, like this: you can look for Tom, or if you're looking for a specific word like John, you can search that. That's what this is for. Um, but we're going to do a comma. Where are we looking? That's what this next one is. So we're looking in property address, uh, and then we're going to close the parenthesis, and and we'd also close it again to complete off that substring, and we'll say as address. Um, and let's just take a look really quick at this. So right now it's taking the it is basically going it's looking at property address; it's going to the very first value or starting at the first value, and then it's going until the comma.

Now, the unfortunate thing is is we actually getting this comma in this output, and we don't want that. Uh, you don't want a comma at the end of every address. We can change that. Um, so we can say because this is specifying a position, if we just look at this CharIndex, which we can do really quick, it is going to give us a a number. It is saying at position 19 that is where the comma is. Right, so it's not like it's taking it's not a value or it's not a um, it's not a string; it's a it's a number. So we can say minus one, and if we do that and now we run it, now that comma is gone because we're looking back; we're going to the comma and then going back one from uh one behind the comma. So that's how you get rid of that comma right there.

Um, the next one's a little bit more tricky because we're not starting well it's not super tricky, but we're not starting at that first position anymore. So let's put a comma, then we have our substring. Now where we want to start is at this as at where the comma is. So instead of position one, we want it to be where that CharIndex um, I don't want it to look like this this whole time is it like this? What am I doing? It doesn't matter; let's just get rid of this and see if that fixes it. What am I doing here? Oh, it's just because this is wrong, um, and we'll just do comma parentheses; that might fix it. Ah, doesn't matter. Okay, I'm wasting time; I'm going to keep going. We want to start in this in this position. Okay, um, but we actually don't want to start at minus one; we need to start at plus one because we want to go to the actual comma itself. Then once we get to the comma, we want to add one. So if we didn't if we just left it the same again, it would include the comma at the beginning. Um, then we need to specify where it needs to go to; where does it need to finish? Now every single thing is going to be different; every single address has a different length, but we can use that to our advantage in this one, and we can literally say the length of property address; you guessed it right, and then we can close this off. Let's see if that works. Okay, what's messing up? So we have property substring, property address, comma, CharIndex, and then we have specifying it in the comma. Um, we have the property address plus one. Okay, we can't have that right there. I don't know why I had that. Finally figured it out at the end. Um, so let's see what we're doing here; let's see if it worked. It works perfect. Um, and again, this was one that I'm guessing a lot of people haven't used before, so I was trying to explain it a little bit more than other ones. Um, but if we take that out, we take out that plus one, you're going to see the comma at the beginning right here, so that's what that is. Um, so plus one, and that's what we're going to keep.

Now we can't separate two values into from one column without creating two other columns. So just like we added this um, table up here, we're just going to I mean we're we're I'm just going to copy this down here really quick; we're going to create two new columns and add that value in. So we're gonna we're gonna add that we're going to call this um, let's call it because it's property address, let's do property property split, um, and this is the address, and then we'll say this one this next one is going to be property, and this is City split city city, and this isn't going to be a date, of course, uh, this going to be let's do nvarchar, and let's make it 255 just in case it's a large um, just in case it is a large string, a large text. So then we can say um, update that, update that, um, and now we need to insert um, what we did for it. So this first one is the address, so we're going to say that equals the address, and we're going to take this whole thing, this whole substring, oops, and copy that, and that's going to equal this, um, and then at the end we'll we'll look at it really quick. So first let's add this table. I'm going to do this one at a time really quick so you can see it, so it adds the table. Now it adds the results, and again adds the table of city and sets that City to that substring. And now let's take um, let's take this and just do select everything from this, and you should see at the very end because when you add it it goes to the end; we should have two new values, and here we are: so property split address and property split city. Um, it's much more usable than this. I mean, this would be a nightmare; not a nightmare, it just be annoying to use this column. I mean, now that it's separated on the address and the city, it's so much more usable of data; it really really is.

The next thing we're going to be looking at is this owner address. Now it was hard enough or it was tough enough to do this, um, but I want to show you maybe even a simpler way to do it, even though this is more complicated. So let's go down here and let's get rid of this. So let's say um, let's get this and let's just say property oops, no, we're doing owner owner address here we go. Let's just take a look at this; let's see what we got. So again, we're using or what we have in here is the address, the city, and the state. So what we need to do is split all of those out. Um, and again, I don't want to use substrings again; that was a pain. I want to use um, something a little different, something again that you may have never seen; it's called PARSENAME. Um, and PARSENAME is super useful, um, especially for like delimited stuff, stuff that's delimited by a specific value. Um, so let me just show you what it is, and then we'll go from there. So we can say parse PARSENAME, um, and we're going to be doing this on the owner address. Okay, let me see, let me see. Yeah, I mean, it's because I don't have this; of course, I do that all the time; so annoying. So on the owner address, um, and then let's do one, and let's just see what happens. Uh, nothing changed, of course, because PARSENAME only is useful with periods, or that's what it looks for; that's what PARSENAME looks for, and these are commas. So something we can just do is we can replace those commas with uh a a instead of a comma; we replace it with a period. Super easy; we're just going to do owner address, comma, um, and we'll look for the comma in there, then we need to specify what we need to change it to; we'll change it to a period, and let's close that, and now let's run it, and it's taking Tennessee. So something odd about, at least to me, odd about PARSENAME is that it kind of does things backwards than what you would expect it to do. Uh, let's really quick let's add the other things. Um, you'll you'll get a kick out well you won't get a kick out of this as much as I do. Here's one, two, three. Let's execute this, and it separates everything for us, but it's backwards. So it's 1, 2, 3; you would imagine it'd be one, two, three, but no, it's one, two, three. So all we need to do is go three, two, one, and run this, and there we go. So now we have it broken out; this is now our address, this is our city, and this is our state. So super what I would consider super easy, a lot easier than the substring, but I didn't want to show you the easy one first and then give you the hard one. Um, so now we just need to add those columns, and then we need to add the values. So let's do this. Uh, let's make some room, and I need to get rid of one of these, I think. O, did I do that right? What did I do? I have my ALTER TABLE, UPDATE, ALTER TABLE, UPDATE. What is this doing here? What is this? I don't even know what this is. We'll just go like that. So now we have three perfect. Um, so from National Housing, we're going to say we're going to say this is the owner oops, owner split address. Um, actually, let me just copy the owner; make it easier. So we have owner split address, owner split City, and let's do owner owner split, and then State, oops, and copy there, owner split City there we go, owner split address, owner split address. So I'm putting all the sets equal to what we're about to add to. So now this first one, this three, is the address; we'll paste it there. The second one is the city, so we'll put that. Oh, I see what happened here; that's what happened. Got to get rid of that. Um, I set the owner split City equal to that middle one, and then, of course, the third one is the state, so let's go do that, and that should be done. So let's do it two at a time. Oops, owner split address. What's wrong with that? Oh, I probably just got to run this first. Let's try that. Tried to get good too quick. Um, you can do this a much more efficient way; I'm just doing this for visual purposes. I would update all the tables first or add all the um, columns first, I mean, and then do all the updating at the end; that's normally how I do it, but um, again, for visual purposes, this is what we're doing. So let's go get this; actually, let's get this, bring this down here. Um, don't keep this in in your final queries; it's a lot of extra selecting everything; you don't need to do that. Um, so here we go: so owner split address, owner split City, owner split State. Again, so much more usable than when it's all in one column. I mean, it is 10 100 times more useful data now. Um, you know, that one to me, you that gets used a lot. Let's keep going; I feel like we're making fantastic time. I don't even know; I'm not even keeping track of time; time is not even relative anymore. Be three hours, and I wouldn't care. Let's keep going.

Um, let's take a look at this column right here: sold as vacant. Um, right now has no, but let's look at let's do SELECT DISTINCT. Oh gosh, I hate when I do this; I do this all the time. Am I the only one? I don't think I'm the only one. And we'll do sp uh, what is it? Sold as okay, sold as vacant. Let's do a distinct count on are distinct on these. So right now we have yes, no, n, y, I'm guessing which is no and yes, and then no. So let's look just for just because I'm curious. Um, let's look at a count of I don't want to do the let me just do sold as vacant; let me do a count of this, and we'll Group by uh sold is vacant. Okay, let's run this and see what we get. Oh gosh, let me order by. Okay, here we go. Now we're now we're moving. That's not what I wanted at all. Order by two. Here's what I wanted. Okay, so at no we have 51,000, yes 4,000, almost 5,000 no, and then just a few. So let's change them to to yes and no because these are obviously the vastly more populated ones, um, and we're just going to do this through a case statement. So we're going to say oh yeah, let me get this ready before we start. Oh yeah, I'm ahead of the game now. Let's do SELECT, and we'll do sold as vacant, and then we'll start our case statement. Um, yeah, let's do right here. So we'll do CASE WHEN sold as vacant is equal to yes; all we want to do is say then we want to make it no. Oh, won't make a yes; what am I doing? Geez, I'm losing it. When and I'm just oops oops oops oops, ignore that; pretend that didn't happen. WHEN sold as vacant is equal to n THEN no, and then ELSE we want to say if it's already if it's not one of those values, it means it's already a yes or no, so we're just going to say just keep it as sold as vacant, and then we'll end it. So let's take a look. Okay, so let's scroll through here and see if we get any that we can see. Oh, I just went by y some didn't I? Oh, I just went by some; I know I did. Um, let's see. Okay, here we go. So here's an n; it's now a no. So this this sold as vacant as this column, the newly uh, the CASE statement right here is changing it, so the n is no, so this should work all, and this will be a unique UPDATE statement, um, and I hope it works unlike the first UPDATE statement that we we did that was a that was a travesty. Um, let's do UPDATE Nashville housing, um, and we'll say SET sorry, I'm talking faster than I'm going. SET sold as vacant equal to, and we can just literally put in this CASE statement. Um, it's not, but let's try it. Okay, now let's go look at this again and see if it made the update. There we go; the UPDATE statement worked. Oh, fantastic; it's a beautiful thing. Okay, great; I'm glad that one worked; I was worried for a second that uh my update had broken in um in SQL Server.

Now now we're going to do something. Um, these next two things is we're going to remove the duplicates and then we're going to get rid of unused columns. This removing duplicate I got to be honest; I don't do it a ton in SQL, but I have done it, um, especially for like queries, you know, when I'm looking at full tables; I I will write some sort of temp table and like put the remove duplicates in there. I normally don't delete actual data; we are we're going to do that, um, but it's not a standard practice to delete data that's in um, that's in your database. So just for future purposes, don't blame me if you delete all the all the duplicates back accident in your uh table at work. So you can do this a few different ways, but the way I'm going to show you is we're going to write a CTE, and we're going to do some window functions to find where there are duplicate values. Okay, so excuse me. So let's start writing out our CTE and or you know, even we can write out the query first, then put it into a CTE; that might be a little bit better. So let's do SELECT everything, and oh my gosh, I was about to do it; somebody's out there just like waiting for me to make that mistake again. So we want to partition our data. Um, when you're doing removing duplicates, we're going to have duplicate rows, and we need to be able to have a way to identify those rows, right? So you can use things like RANK, ORDER, RANK, um, ROW_NUMBER; there are a few different options. We're going to be using ROW_NUMBER, um, and you know, if you want to look into how RANK and RANK uh, like DENSE_RANK and all those ones work, please do that, so you know why we're doing it. Um, but we're using ROW_NUMBER because it's the I think the simplest, um, and it's going to do what we need exactly. So I'm going to get this over here; we'll say SELECT everything because we're selecting everything, then we're going to add this ROW_NUMBER on here. So ROW_NUMBER, and we're going to do these parentheses right here; we're going to say OVER and an open parentheses. Now we need to write our partition because we're going to partition this data. So we're going to say um, Partition by cool. Now really quickly while we're here, we need to actually know what we're partitioning on; that's helpful. So let me write this. So while we're writing it, we can see what we're doing. We need to partition it on things that should be unique um, to basically to each row um, if in I guess for the sake of what we're doing, we're we're going to pretend this unique ID isn't here, um, although you know, you could say I'm cheating; it doesn't matter. But I'm going to say, you know, if things like the parcel ID are the same, if the sale date is the same, um, the property address is the same, the sales price is the same, this legal reference, which I'm guessing is some type of legal document saying it's like somebody's uh property, if all of those are the exact same, then to me that is the same data; it's it's unusable. Just for example, I mean, this may I don't I mean, this data is just some random data set I found online, right? So that's what we're going to be going with; that's what we're going to be running with, and pretend that lie that I just told you is completely true. So what we want to Partition by, let's start with the parcel. Um, can I is this not right here? Why is it saying this? Why is it not giving me? Okay, doesn't even matter; I'm just going to say parcel ID. Um, we can say property; we'll do a property address; stick with me; we're getting somewhere. We'll do sale price. Um, what do we say? Sale date; I mean, there shouldn't be two of this; they didn't sell twice on the same day; come on. And then legal reference, and oh, I know why it's not working or my autocomplete isn't working, which I love. Um, it's because we're creating our own partition, so it's its own column; of course, I don't know why I'm it's late, as you can see down here; it's 11:15; it's getting late for me, but hey, I I this is an adrenaline rush for me. Um, now we need to order it. Now we want to order it on something that should be um, not necessar I guess unique, so we're going to order it on this unique ID; we'll see if that actually does what we want it to do. Um, oops, what am I doing? ORDER BY come on, and we'll say uh unique oops, unique ID, perfect, and we should be able to close that off, and we're going to call this RNUM; I mean, that just that just makes sense. So now we have this, and let's run this really quick and see what happens. So, um, and maybe we should order this as well, but we'll maybe we'll do that later. Yeah, let's order this on parcel ID. Um, ORDER BY parcel ID; let's just see what happens because this I think that should be pretty accurate. Um, let's scroll down and see if we get any. This is all ones; maybe should be doing it on unique ID; I don't know. Let's see if we get any hits. Okay, there's a two in there. Let's let's look at this really quick because I want to see it; maybe I did something wrong; I don't know. It is absolutely possible. Somebody play some Jeopardy music for me. Real

Quick, yeah. I don't know. I don't know why it's um, okay. So let's see. Let's let's look at these two um, and let's see if I did something wrong. Oops, don't need to pull that up. I was doing some research when I when that convert by wasn't working. Um, okay, so this one and this one, it's giving different row numbers. So let's look at the actual data; ignore the unique ID, but the data itself. So the the sale date is the same, the sale price is the same, the legal reference is the same, the owner is the same. This is the same. I mean, literally every single thing in here is the same. So this is a good example. So we're going to, in this query that we're about to write, that that will be that second one will be deleted because we don't need it. Now there there's only one, so it looks like this is working as intended. Um, I can also do um, let's do where rowcor num is greater than one. Let's see if that I don't think it will work actually. Yeah, that's because uh, it is that is in a Windows function. Of course, we can't do that. What am I thinking? That's why we need to put it into a CTE. Oh, of course, it all comes back. So let's call this all comes back to the CTE. Those things are amazing. Um, let's call this um row num num CTE and we'll say as and then open parentheses, and I don't think we can have an order by in here. Let's do it like this, and let's just do select everything from row number CTE. So again, if you haven't watched my like CTE CTE video or you've never used a CTE before, um, this is now basically almost like a temp table. So we're going to be able to this query down here is querying off of this table that we quote unquote created. So um, it looks like it's working. So all we're going to do is select um everything from that, and we want to say where row num, because that's now a row, is greater than one, and let's order that by I don't know, property address. Let's see if that works, and let's see what happens. Okay, so all of these are duplicates; we have 104 of them, it looks like. So there's not many, but it there's twos, any threes? No, no threes. So there's multiple of these rows or columns that are basically duplicates, um, and we want to delete them. So all we're going to say is we're going to select instead of saying select everything from row, we're just going to say delete, and uh, yeah, I got to get rid of that order bu; that doesn't work. And let's do this; there's 104. Let's see if it worked. Um, so now let's do let's go back and we'll say select everything, and let's see if there's any more duplicates in there. There are none. That is fantastic. Every I'm like biting my nails now to see if each one of these works um, because I that first one didn't work. Um, so yeah, so it worked. We got rid of the duplicates. That is fantastic. Um, and now it's smooth sailing from here because we're just going to delete some um unused columns that we don't care about. This doesn't happen often. Um, this I would say actually happens more in like views when I'm creating views. I have a view, and I'm like, oh, I didn't mean to add that column. Let me just remove it because it's a I don't need it. You don't do this to um, like the raw data that you import usually. This is I mean, again, best practices, please don't do this to your raw data that comes into your database. Um, talk to somebody before you do this. That's just my my legal advice for the day. I'm not legally bound or legally held responsible for any mistakes you make. So let's keep going. Um, we're literally just going to delete some columns; it could be any columns that we want, um, but for example, we got have these property split address and owner split address um, in city and state and city, and these are perfect and much more useful than these owner um, these owner address because this is really unusable to be honest. So we're going to delete those, um, and maybe we'll also get rid of like I don't know, maybe the land that land use might be useful. This tax tax District, who cares about that? Um, so it's going to be super easy. We're just going to write alter table. Alter table, did I say that right? Geez. Um, and we're going to say alter this table, and we're going to drop a column, and you can do as many as many as we want. So we're going to say owner um address, we're going to do tax district, and let's also do the property address. All right, and let's try this, and let's see if it works. I'm nervous. All right, so as you can see, that the property address is gone, the owner address is gone, the tax what was it? Tax district is gone, and now we are left with this. Um, now remember the whole point of everything we were doing was to clean up the data, right? We wanted to clean the data, and actually now well now that we're here, we have this sale date as well, U, and we have the sale date converted over here. Let's get rid I forgot; let's get rid of this. Oh, that was my dog Max. Excuse them. Let's get rid of oops. Let's get rid of that sale price that that or the um sale date that made me look like an idiot. This is sweet revenge, sale date. Sweet, sweet revenge. All right, and it is gone. So it's as easy as that. Now remember, like I was saying before, the whole point of this project is to clean the data and make it more usable, um, and it may not have felt like that as we were going through, cuz I wasn't, you know, really looking at the clean cleaning data uh uh, we were cleaning it, but you know what was the purpose of it? I may not have highlighted that too much. All these other columns that we created um are just it's much more usable, much more friendly. Um, this is standardized now, and you know, we we did that through quite a few various methods. Um, so let's go back up the top. We're going to recap what we did really quick. So using this convert, we tried to standardize the date format or change the date format. May or may not have worked for you; didn't work for me. We populated this property address um, which we did that before we broke this out because if we reversed it, if we broke these addresses out into individual columns and then we populated the this thing, um, we would have because then we went and deleted uh, we went and deleted this column. Oops, sorry. We went and deleted uh this property address, so we wouldn't have actually gotten any of that data. So there was a reason it was in that order. Uh, don't mess that up; that's happened. Um, so we broke it out; we did that to to using um substring, chart index, as well as parse name and replace. Then we went through, and we changed yes to no or Y and n's to yeses and NOs using case statements. Um, then we use we removed duplicates using a row number, a CTE and windows function of Partition by, and then at the end, we deleted a few useless columns that we no longer want to see because um they are horrible and terrible, and um, you know, we don't want to see them anymore. That is the entire project; that was everything, and you did it, and I'm honestly super proud of you for sticking around this long. It this this was not necessarily an easy project. We used quite a few new things that I may have not talked about or showed you before. This to me is just the beginning, right? This is just a a glimpse into all the things that you need to do; you need to look for um in order to clean data. So you know, I really do think this is a good portfolio project because it will show that you understand and know how to clean the data, although this is not an end-to-end project, right? That could that would take a long time and a lot more exploratory analysis looking into the data to to figure out what we need to change. But for all intents and purposes, I mean, this is a a pretty good project for cleaning data, and I hope that you learned something. I also hope that you worked on this hard. Um, if you want to make any improvements, please do that. This is not perfect by any means; there's other things that you could change. Um, you could you know, I don't even know; I'm not even going to try to guess. You could do other things to this data though, um, and and create your own queries, create your own um data cleaning uh part of this, and so um you do that. If you were able to get this um the ETL part of it done, do that. I think it'd be really really cool. Um, again, I was able to get it to work, but I don't think 90% of people out there would be able to get it to work. Um, it's just every computer is different; every server is configured differently, um, and so it would just be a huge pain. So I decided to cut that out, and I'm sorry, um, but hopefully this will suffice. Um, with that being said, this is it. You made it all the way to the end. Again, I'm super proud. You guys are doing fantastic. You guys are the ones putting in the hard work to build the portfolio for your future job. I mean, it's not easy, but you're putting in the work, and so and so kudos to you. Um, in our next video, we're going to be going into Python for the very first time. Really excited about that one because um I think the only Python video that I have up right now is on one where I was scraping data from Twitter. So um, you know, this will be a nice change of pace or a little bit different content than I normally put out, and so I'm really excited about it, and I hope you are as well. With that being said, I am done with the video. I'm going to be stopping it soon. Thank you for joining me. If you like this video, be sure to subscribe, be sure to like this video, leave a comment below um telling me how it changed your life, uh, and I will see you in the next video. [Music] Goodbye. [Music]

What's going on, everybody? Today we are starting our Excel tutorial [Music] series. Now there are so many things that you can do in Excel, so I don't know how long this series is going to be. It could be 15 or even 20 videos, but what I do know is that I'm going to be covering just about every single thing that I've used since I became a data analyst, and I want to show you how to do it. Uh, so won't just be the more concrete things, um, you know, like pivot tables, charts, V lookups, things like that. It'll also be some of the more nuanced things like how to deal with missing data or how to deal with dirty data and how to clean that up within Excel. And so those are things that you may not be able to do, you know, if somebody wasn't showing you how to do it. And so that's what I'm going to try to help you because I know that that is something that you will need to do or learn how to do in Excel. Now before we get into it, I want to give a huge shout out to the sponsor of this Excel series, and that is Udemy. I took so many Excel courses on Udemy when I was first starting out as a data analyst, and there was this one course that I kept going back to over and over again because as I got into it in my job, I realized that there were so many things that were in that course that I really needed to know, but I didn't realize I needed to know it. And so I'm going to put the links to those courses in the description in case you want to take those. Again, huge shout out to Udemy. Without further ado, let's jump on my screen and get started with our very first Excel tutorial. All right, so I'm going to go ahead and get rid of myself. We are going to be looking at something absolutely pivotal in your data analytics career, and that is Pivot tables, uh, and I think that's really appropriate. It is probably one of the most commonly used things I think that data analysts use to convey information in Excel. It's super easy to group things together to display information in a very easily understandable way, especially for people who are not data analysts, right? I use this a lot for other managers or for higher-ups um who don't want to get into SQL or or you know, aren't super text-savy in like Python or Tableau; they just want it in an Excel cell. And so I use it all the time for that reason. And so we're going to be using this data set right here, Bike Store Sales in Europe. I will include this link in the description. Um, we're not going to look at the columns just yet; we're going to download it. Um, I've already downloaded it a few times, but we are going to go to um our downloads; we're going to open it up, and we're going to open up this sales right here and give it a second. All right, perfect. And so here's what it looks like, uh, at least on my screen. I'm going to uh spread it out just a little bit, um, and really quickly, let's take a very quick glance at this. So we have a date, a day, a month, a year, so some um some date information, um, then we have some customer age information, so how old was the customer? Again, this is bike sales, so what did um you know, what did they buy? And they have some demographic information, so this is their age group. We have uh the gender, country, state, the product category, the subcategory, the actual product that was purchased, and then we have things like um you know, how much these things cost, the quantity that was that was ordered. So we have order Quant quantity, unit cost, unit price, then we have the profit, cost, and revenue; all things that we almost everything in here we can in some way put into a pivot table. Now I'm not going to go through every single variation of that, but we are going to be um looking at a lot of this um Revenue over here because I think it's it's pretty easy to show the value of a pivot table with especially with um you know, currency or money. So what we're going to do to get started is we're going to go up to insert, and we're going to click on insert, and then we are going to click on pivot table. Now really quick, there is a recommended pivot tables, and if you click on that, what will come up is some recommendations that Excel gives based on the data that you have, um, and it can kind of give you some ideas of of what you can do with pivot tables; it's going to generate it for you. We're not going to do that; we're going to build our own, uh, but let's click on pivot table, and it's going to Auto Select basically everything, and that's fantastic, um, but what if it doesn't come like that? I I just erase that. If it doesn't come like that, you can click right here; you can cck excuse me; you can click control shift, and then the right arrow, and then the down arrow, and is going to select all of our data, um, and you have right here a new worksheet or an existing worksheet. We're going to create a new worksheet; it just tends to get too clogged up if we put it on the same worksheet that already has a lot of data in it. So right over here are pivot table fields, and these are all of our columns that we just looked at, and we're going to be able to select those and kind of drag and drop. Now if you just took the Tableau um tutorial series that I just finished doing last week, then this is going to be pretty pretty familiar. Um, you're going to start seeing a little bit of um hopefully some patterns about how the data is kind of displayed. And so we have our filters down here; we have columns, rows, values, all these things uh, we will be using; I'll show you how to use today as well as some additional things. Um, one thing that we want to start with uh for this demonstration is we're going to be looking at kind of the um these bottom ones right here, profit, cost, and Revenue, and we're going to be doing that per country, uh, per country and state, and we'll kind of do some drill downs, um, and I'll show you how those work. So for just to start out, we're going to take the country right here, and you'll see it populate right over here. In fact, um, let me zoom in maybe once, uh, yeah, that should be fine. I don't know if I want; I might zoom in again in just a little bit. Um, so we have our country, and and it's just like this very very simple oops. Um, now I'm going to include the state. Now I'm going to drag this um all the way, and I'm going to put it under; you can put it above or you can put it below. I'm going to put it below; it definitely makes the most sense there. Now when you do that, it it um kind of populates it in an expanded way, but you can collapse this very easily. We're going to go right here; we're going to right click; we're going to go go down to expand and collapse, and we're going to collapse the entire field. And so now here are all of our um all of our countries as they were before. Now each of them has this plus sign to the left, and if you click on it, now we can go, and we see this state that we that we added to these rows. And what this is going to do is it kind of is like a rollup or it's like a grouping, um, and so if you you know have taken the SQL um tutorial series and you've done things with Group by, this is very similar to that, um, and if you've done the Tableau tutorial series, it's kind of like a drill down; it's very very similar. So you can drill into the information. So we um can put some values in here, uh, and what we're what that's going to do is that's going to kind of create some some context to what this what we're grouping by. So just for um visual purposes, let's add this Revenue. So this is the revenue that is bike uh bike sales revenue, right? That's what we're looking at. So this is the sum of the revenue for these bike sales per country. Now if we drop down right here, we can see that in Australia, uh New South Wales had uh 92 was that 9,234 N5; Queensland had 5 million, you know, etc, etc. So now we can break it down; we can't it's we don't just have to look at Australia; we can now drill down even further to the actual state is what they're calling it, um the actual state within Australia. And so it's super super useful, and you can do that for every single one. And so we can look at Canada; we can look at France, and we can really drill down into uh the revenue for each of these countries as well as the states within them. Now over here, this is not the most uh pretty; it just says sum of Revenue, and then it has some numbers; not not the most pretty thing I've ever seen. Um, really quick, we can go like we can um kind of highlight over these, and we can go back to home. You can do it in a couple different ways. We can go to home, and will type currency. Now it has these two. Z at the end; you can get rid of those really easily by going like that. Um, already this looks quite a bit better, just visually, um, especially if you're looking at it in uh you know, dollars. You can change the currency um to different currencies if you want to do that. Now we don't just have to do uh the sum of Revenue; we can do a lot of different things. So let's go to the value field settings. So we can customize this name. So we can do um Revenue oops. Good if I get spell Revenue per country. That's fine; that you know, it's just a placeholder; trying to show you, but we don't have to just do that. Um, you know, we could do the count, the average, the max

The minimum we can do is just about anything we want. But let's keep it the sum right now. And if we want to, we can show this value as different things, so we percentage the percentage of column total, percentage of row total. Let's do really quick, just for demonstration purposes, the percentage of grand total. So when we do that, we can see that the United States, the per Revenue per country, United States has 32%, just between these, um, you know, these countries and Australia has the next one. So you know, it might be kind of hard to glance at this really quickly to know who has the highest. But what we can do is we can go right here, and we can go to sort, and we can do largest to smallest. And there we have the United States on top. Now when you do it right here, it's not sorted largest to smallest; you'd have to go in again, click sort, and do largest to smallest. And so now we can see that California has the, has the, um, you know, biggest percentage; they're pulling in 20% of that 32% of Revenue. So I'm just going to click Ctrl+Z a few times and get us back to where we just were.

Um, and what I want to do is I want to show you a few different things pretty quickly. So we want to pull in this profit and this cost. And so I'm going to pull in this cost next, and then I'm going to pull in this profit again. I'm going to change the currency on this, and I'm not going to change the names right now, but you know you absolutely can do that. Now the revenue is how much is actually being sold. So you know, for the United States it was 27 million. Now the cost is how much did it cost to manufacture or store or distribute all of these products? So that was 60 million, and the profit is actually how much money is being made at the end of the day after, um, you know, all their costs, after all their employee costs, after everything, they're still making the United States is still making $1 million.

Now you might look at this and you might say, well, you know, I can kind of glance at it and say, know that this profit is correct based off these two numbers. But we can do a calculated field. If you remember what calculated fields are, that's something from Tableau, very, uh, basically the exact same thing. And so we can create an additional column right here that is a calculated field that can add and subtract these things to make sure that our numbers are adding up correctly. So let's do that really quickly. U let's go to PivotTable Analyze; we're going to go over to Fields, Items, and Sets, and go to Calculated Field. Now we can name this anything, and I'm just going to, for demo purposes, I'm going to say, um, oops, Calculated Field Demo. I'm sure yours will be different. Now, if you want to, you can go in here, and this is the formula; it's almost like, um, you know, we haven't looked at formulas up; this is our first tutorial, but you know when we look at formulas, it's basically the same thing as writing it if inside of a cell, but here it gives us kind of this, um, open text to do how we, uh, do what we want with it. Now what we're going to do is we're going to do Revenue; I'm going to insert that; I'm going to get rid of this; I'm going to do revenue, and so that's the, the, the very large number, and then we're going to subtract, and we're going to subtract our cost; we're going to insert that, and let's do this and click okay. So this is our Calculated Field Demo column that we just created, and as you can see, it matches our sum of profit column exactly, and that's exactly what we want to see. We want to kind of check to make sure that this revenue and cost fields are generating the correct profit, and sometimes those are off, and so it's really good to kind of check those and have that additional column.

You probably wouldn't have this if you were, um, you know, going to submit this to somebody, just so you know. Now that this is an actual column, you can't go here and do something like cut or and paste it over here; you know, that's not, it won't let you do that. What it is is, is now an actual column, and so we can go and remove that, and we can add it back at any moment. So if we want to go back and add that, um, oops, add that down here, we can do that because we've created that column; it's now permanently there unless we go and delete all of that data. And so we can just click this check mark, and it will get rid of it for us. All right. Now the last thing that we have not used down here is the filters. Now the filters is exactly what it sounds like; it's going to allow you to filter on certain things, but probably not things that you already have included in your pivot table. So if you add something like the country down here, it's going to kind of expand everything, and then if you then go and filter on it, it kind of breaks it down; that's really not what the filter is kind of used for or meant for. For example, right up here we have customer gender. Okay, so let's take the customer gender and we'll put it in this filters. Now we can see all of the revenue, all of the cost, all the profit, and we can do that based off of the gender. So we can filter by a gender, not really having to change anything about our pivot table. And so at a super quick glance, we can see that the males, the profit from the males is 16.48%. So at a super basic level, at a really quick glance, we can see that the men or the males are, you know, spending a little bit more than the females by about, about $700,000.

Now let's go ahead and create one more pivot table. We are going to create a pivot table right over here. Let's go back to the sales right here again; Ctrl+Shift+Down; it's going to select all of our data, and we're click okay. So one thing that we're going to look at is we're going to use some of this date information right here. So let's select our country just like we did before, and what we want to do is see, you know, what year were we performing our best? When were we doing our absolute best with, oops, let me go back, with our sales? So I'm going to select the year and put that in our columns, and so now we have 2011 through 2016, and we want to look at our Revenue; let's put our Revenue right down here. And now we have all of our Revenue. Now let's again make this into a currency just like that. And super quickly now we can get a really quick glance at how Australia was doing each year, and we can see that there was a huge uptick in 2013 and a huge uptick in 2015. It didn't happen for every single country; it did go up for most countries very slightly for some, but we can see on a large scale from year to year what that's like. And so within just a few minutes, we're able to create some really useful pivot tables that anybody could look at and understand. And that's really the biggest use of these PIV pivot tables is that you can kind of group these things together, show some information and data at, at kind of a broad, larger scale, and make it to where anybody who's looking at it can understand it. That is why pivot tables are so useful, and so I hope that this video was helpful. I hope that I was able to walk through it and help you better understand how pivot tables work and how you can use them when you are working within Excel. Thank you guys so much for watching; I really appreciate it. If you like this video, be sure to like and subscribe below, and I'll see you in the next video. [Music]

What's going on, everybody? Today we're going to be looking at formulas in [Music] Excel. Now I know what you're thinking: there's absolutely no way that you're going to be able to show us every single formula in Excel, and you're absolutely right. But I am going to show you some of my favorites and the ones that I found the most useful, and then you can go ahead and practice those and try those out. And if there are ones that you really want me to do and you think that I missed, put it in the comments below, and I will see those, and I'll try to make a list of those and make another video on formulas and include all of those as well. And now before we jump into the actual tutorial, I want to give a huge shout out to the sponsor of the series, and that is Udemy. You guys already know, if you have watched any of my videos, that I absolutely love Udemy. I mean, honestly, they were the ones who got me started and were able, able to give me affordable courses for me to get started as a data analyst. I learned SQL and Excel and Python all through Udemy courses. And so if you are looking for a platform to take a course, I absolutely recommend you look at Udemy. They have fantastic sales going on right now, especially during the holiday season and this new year. And so if you're looking to take a full-fledged Excel course, I have some of my favorites in the description below. And now without further ado, let's jump onto my screen and get started with the tutorial.

All right. Now before we start, I want to say that this is not like every other tutorial that I have created; created this one is very streamlined. Okay, so I already know exactly what I'm going to do; there's not going to be much messing around. I left little notes here and there, and I'm going to try to get through it because there's a lot of them to get through. So all these ones at the bottom, now these are ones that I use a lot that I think are useful. Again, if you know other ones that you use a lot that think that I should be using, which I know there are ones that I left out of here, you know, put it in the comments. I'll see the ones that people are liking, and I will, I will create more videos on the because I know there are so many. I also will save this Excel in on the GitHub, so you can go and download it; it will be exactly what you're looking at right now. I highly recommend trying these formulas out for yourself so you can get a feel for how they work and how they're actually used, and you can mess around with it yourself. So, um, as you can see at the bottom, we're going to start with Max, Min, and then we're going to go on to some more, I think a little bit more difficult things, and all these things are super useful. I'll try to talk about how you can actually use it as we go through it; some are super self-explanatory, but some may not be. So this one I think is super self-explanatory, but again, one that you're going to use all the time. Um, and so what we can do is we can say equal, and that's how you kind of start off saying this is going to be a formula in this cell; equal means, I am now creating a formula, and we're going to say MX, and I'll hit Tab, and so it'll kind of populate it, and right here if you've never seen a formula before, it'll to give you what the inputs need to be. So it's going to say Max of number one, number two, etc., etc. What we're going to do is we're going to give a range, so we're going to go from here down to here; you don't have to close the parenthesis, but you can; I'm going to, and then you hit Enter, and so for this date, it's going to give us the max date. Now these are the start dates for these people right here, and so if we just kind of glance through here, we can see that 2013 was the last year, and this one is actually the latest in that year, and so it gave us the correct one. The Min is going to do the exact opposite; it's going to give us the smallest, and so we'll give it the same range; we'll close the parenthesis, and it's going to say December 7th of 1995, and we can see that that is correct. So Michael Scott started in 1995, the earliest of all the employees. Um, and you can do the exact same thing for really any of these columns; we can see who the, who's making the most money or at least what the higher salary is. U so we'll do Max, and then we'll do the salary range, and so this is this one again, uh, whoops, what did I do? Oh, I did the wrong range, didn't I? No, I didn't do the wrong range; it's just there it goes. This column was a date range or a date column for whatever reason. Let me get rid of that, and then we can do equals Min, and we'll do again, we'll do the salary, and at a quick glance we can see that Pam Beasley is making the least, and 65,000 is Michael Scott who's making that. So super simple; it shows the max, it shows the Min; you can select a range; there you go. Let's move on to IF and IFS. Now IF is, um, I think pretty straightforward, so all you're going to do is you're going to say if this, then that. IFS is a little bit different, so IFS is you can, you can put multiple conditions, and as we're writing it, I'll show you kind of what it, the conditions that need to be met.

All right, so we're going to click right here; we're going to say equal; we're going to do IF, hit Tab, and we need a logical test, and so we're going to give it a range or, or, or something; we're going to say if it's equal, greater to, um, something like that, then we're going to say if the value is true, what's the, what is going to be the output, or if the value is false, what's going to be the output. So let's do this right here; we'll do this age range, and so if they are greater than, let's say, let's do 30, if they're greater than 30, we're going to do a comma, and so if the value is true, what, what should be the output? Uh, if they're greater than 30, we're going to call them old, and then if it is false, so if they're younger than 30, what should it say? And we're going to say young, and we'll close the parenthesis, and there you go. So if they're over 30, then they are going to have young, or if they're younger than 30, they're going to have young. Now this is something where you need to specify if you want 30 and over or over 30; we chose over 30, so 30 is not included in that, so they're going to be young. Now, uh, let's get, we don't actually need two of these; that's pretty self-explanatory. The IFS is a little bit different; right, you can have multiple conditions. So let's open that up real quick, so IFS, and now we have a logical test, value if, that's true, then you can do logical test two, value if that's true, um, so you can have multiple, multiple, multiple things. Now this one is a little bit different; in this one, oops, let me get out of this; in this one, you had a value of true, a value of false; IFS does not have that; IFS is going to give you different ranges in different specific conditions, and you can't say if this one's false; you're just going to have multiple conditions. So let's do equals and IFS, Tab, and we'll do our first logical test, so let's do, um, if the salesman, or if that equals to salesman, we're going to say we're going to respond with sales, so that's if the value is true; that's what we want the output to be. Now we're going to go on to our logical test two, so you're going to see this pattern right, if this is our conditional or logical test, so if this is true, this is what's going to be returned, so you'll notice that's just a, a pretty simple pattern; we can just do random things, so if it's equal to sales, um, and we'll just do the same one, if that is equal to say HR, we can say fire immediately, and now we're going to say if it's equal to regional manager, and we say give Christmas bonus, and we'll close the parenthesis, and let's see what we get. So as you can see, there's no default value for true or false like, like this one; there was a logical test, and if it was true, there was a value, and if it was false, there was a value. So for every single one, you'll get a value; for this one, that's not exactly going to happen, as you can see there are these NAs. Now when that happens, it just means nothing met that condition, so we never said anything about supplier relations, we never said anything about accountants, but if it was part of that IFS statement, then it got something. Um, and so that is how the IFS works. Now let's move on to length. This is exactly what we're going to do, but you know, some of the uses for this, U for the length, I've used it for a lot of different things. Um, one thing that I've used it for in the past, and you know, Max and IFS, you know, you can use it for almost anything; length is, there's a lot of different use cases. One, I used to work with a lot of customer data or patient data; they had like Social Security numbers, and if you know there was bad Social Security numbers, we didn't want to include that, and so we do like the length of that, and if a Social Security number was, let's say, 10 numbers or 11 numbers where it should only be nine or, or you know, however many they are, I think it's nine, then we know that that Social Security number is incorrect, and then we can get rid of that or discard it from our results; that's just an example, right? So for this, oops, what I do? That I did Ctrl+Z to undo that; if you didn't know how to do that. So we're going to do equals LEN, which is length, um, and again, if you didn't see that, it returns the number of characters in a text string. So let's go right here and let's go to, let's go to their last name, and we'll give it a range, so it's going to tell us how many characters are in that string. So for Halpert, it's seven characters; for Flenderson, it's 10 characters, and we're able to see a length. And so again, there are a lot of different use cases for this; the Social Security number was one; another one is phone numbers, right? If you look at the length of the phone numbers, and there's ones that are like 12 numbers long, you know, those might not be ones that are accurate, and you need to go look at them and see if you want to include them in your results or your output. So that is how length is done. Let's move right over to the LEFT and RIGHT. I, I might be going a little fast, but, uh, you know, I'm keeping it, I'm keeping it live; I'm keeping this on our feet, so let's keep going. LEFT and RIGHT, um, are kind of like substrings; if you've taken the SQL tutorial series that I've done, substrings are where you can choose a certain part of the text string and you can extract data from that, and usually have to reference a certain number, so a certain amount of characters; that's the exact same thing except, unfortunately, there's no substring; there's SUBSTITUTE, but there's no substring; LEFT and RIGHT is really the closest thing that we have. So let's kind of take a look real quick and see what we can do. So we're going to do LEFT, and it's going to say returns the specified number of characters from the start of a text string, so we're starting from the very far left, and we need to choose our text and then choose the number of characters that we're going to be looking over. So let's go over here and let's just choose, you know, start symbol; we'll get a little bit more advanced.

So we have, um, this is our text range. So these are the the the ones that we want to look at. And then how many characters do we want to look forward? We'll just choose three as an example. And so you can see that it takes the first three characters from every single thing. Now you can also do this with numbers; it doesn't just have to be, um, you know, name with with actual words or letters. You can do the exact same thing. So you can say, write, um, and we're going to choose our our string, uh, and let's do this one. So you know all of them start with 100, um, and we'll just say we want to take the last one. So this one is going to start from the very far right and go over one character, so right here you can see this is our range, and I just chose one. So starting from the very far right, we go over one character, and that's what we take. And so that can definitely be useful.

Another one that you can do, and this one is one that I have used so many times—I mean, honestly, countless times in in actually using this in my job—uh, so we're going to go from the right, and we're going to look at a date. So you know, sometimes you have these date structures: month month day day year year year or year, um, you know, day month year—all these different, and sometimes you just want to extract either the month or the year or or something like that, the day. And so we want to come in here; we're just going to extract the oops, I wanted to make that arrange—we want to extract the year of the start dates. So we're going to do that, and then we're going to go over four. So we want to take the first four characters from the right to give us the entire year. Let's do that, and now we can see exactly the year. And this can be just super super useful. This is again one that I've used used a lot. And so that is one that you might want to remember in case you're ever doing analysis on, you know, start and end dates or or anything with um date data—again, one that I highly recommend remembering.

Let's go over to date to text. I actually probably should have included that um before because I actually used it in this one. Um, if you notice right here, this is a text. So in in this one we just did—that was a text—you can't do this right on um start and end dates when it's a date uh format. And let me show you. So this is a date. Now if I do equals and you know we just did this, uh, let's do on the end date, and I'll do the whole range. Give me a second, and we'll do four. It's giving us completely random numbers. Why is that? Because underneath the date range there are um numbers. Right? So if I go right here and I make this a general, it's going to have the numbers, and look—these are the first four characters from the right. And so it's doing what it's supposed to do, but uh it's not doing what we actually want, and that's the issue. So how can we convert this? Now there are a ton of different ways, um, but the quickest, probably the easiest besides actually writing writing it out like this—like 11-2d201—which then converts it to a date format, um, but what you can do, you know, just so you know, you can create a as a text; you can do 11-2d201, and now it will stay a text string. And as you can tell, these are a little bit different because this one is uh formatted or situated on the right, and this one's on the left; that's how you can tell the difference.

Now if you don't want to do it by hand uh completely manually and waste hours of your time, you can do it in a very simple way. So we're going to do uh text. So this is the exact um form for that we're going to use. So let's get rid of that one. There we go. So we're going to do equals; we're going to do uh oops, text. It says converts a value to text in a specific number format. So for a date format, we can choose a date format, and then it'll convert it to a text for us, which saves so much time, I promise you. Uh, let's do all of these just like we did, and then we need to tell it what the format is. If we don't—if we tell it something incorrect—it's going to give us a completely terrible output or just give us an error alog together. So this is a DayDay month Monon year year year year format, and that is what we're going to do. So we're going to do ddmm yyyy, and close that up, and there you go. And now we—well, because it's in a formula, what we need to do is copy this and paste it right over here. And now you can see that is a general; this is something that we can use as a string. And let's just check it just to make sure. We're going to do right; we're going to do this one; let's do all of them, and we'll do four. And there you go. So now it works; that is what we are looking for. Um, and you can do that. Imagine doing that with millions of rows or, you know, let's say 10,000 rows; it's going to be a breeze, right? It's going to take you two minutes or a minute to do everything that you want to do instead of having to just do a bunch of mess to convert it to a string, which I promise you I've done it; it just takes forever; it's it's terrible. So that is uh date to text—super helpful formula.

Let's go over to trim. Now I I purposefully messed up this column. Now why did I mess it up like this? Because when you're working with real data, you're going to get data like this; it it's messy; it's dirty; it just has random spaces at the end for no reason, um, because sometimes you're going to be working with um data that is inputed by a user; it's not like a drop-down option. So imagine somebody's typing this in; they accidentally put a space, so they actually put an enter or something, and then they submit it, and this is how it's going to look in the database. Um, and if you're a data engineer or you know you're working with the raw data, if they don't clean that up, then you're going to be working with that that dirty data. And I I guarantee you if you're working as a data analyst, you're going to see stuff like this—not with maybe a last name, but all sorts of data. So we're going to go right here; we're going to say equals trim, do open parenthesis. Actually, this says removes all spaces from a text string except for a single space between words. So like, you know, if it said Halpert space uh or gy space Halpert, it won't take the space in between there because it it kind of understands that in normal language space is supposed to be there, so it won't do that. Um, but we'll take that; we'll give it this range; close that up, and there you go. Now it is nice and clean—much more usable.

Now let's look at concatenate—one that I have used just way way way too many times—um, and something that I've used concatenate for, and you'll see this one in a lot of demonstrations for a good reason, is because a lot of people use it for this. Um, so what you can do is you can say equals, um, and well, let me tell you what concatenate does real quick. So what concatenate does—oops, I'm totally messing up here—um, but it joins two or more text strings into one string; it basically joins things together and adds them together. So let's do concatenate, and we're going to add this first and last name. Again, one that gets used all the time, but that's because um it really is useful. So you can do this, and you can say—now now I want to include this—so concatenating this and this, and let's take a look. So it says Jim Halpert U, but it's all connected, and that's typically not how people write their names. So what we can do is we can go back in here, and we can do what my demonstration up here already tells us to do, which is we're just going to add another thing in here, and if we add two parentheses, we can include anything in here; we can include a dash; we can include an exclamation point, or we can just include a space. So let's just include a space really quick, and just like that, it works perfectly. And so now we have the full name. Now something that you could use it for is something like generating uh an email; this is something that you absolutely could do, um, and it's, you know, pretty simple. So I'm going to do it like this; I'm going to say oops, what did I do? I'm going to say um dot, and then at the end I'm going to say at oops, comma quotation gmail.com, and now I've created emails for all of these people. So just something that you can do with this, um, and something that it it absolutely is used for, and you'll see that demonstration almost everywhere because honestly, it gets used a lot um by data analysts. And so uh you know, just a good one to know—understanding how that that concatenation works.

Let's go over to the next one. So we are going to do substitute. Now substitute's really interesting. Um, there are different ways you can do it; I'm going to show it to you on these dates real quick; uh, that's what we're going to look at. So changing a date format, changing how what it's supposed to look like is absolutely something that happens all the time, and um you know, sometimes you'll even get it like this where it'll look like it'll be messy; it'll be different a different um I guess format. So this one has—all the other ones have slashes where these ones have dashes—and you know what you can do is if you want to—well, let me actually go with the no instances real quick because this one is uh actually makes the most sense. Um, so we'll do equals, and we're going to say substitute, and oops, and let me say substitute replaces existing text with new text in a text string. So if we do an open parenthesis, it says we take the text, have the old text, we have the new text, and then we have how what instance or how many times uh or or or what instance are we looking at it, and I'll explain that in a little bit. So the text that we're going to be looking at is this one right here. So let's take this range, and the old is we're going to take this dash. And so let's take the dash, and then what do we want to replace? Replace it with we want to replace it with this slash right here. I think it's a forward slash; isn't that what it's called? It's called a forward slash; am I crazy? Um, and we're not going to put an instance. Notice that that's in a bracket; that means it's optional; we're going to do none of that, um, and what it's going to do is it's going to fix this. So this one is now in the correct format that we want, uh, and that's fantastic; that's, you know, that's what we tried to accomplish given what we had. Now let's fix that. If we want to do the exact same thing, uh, we can say uh what are we doing? Substitute; we can do substitute; we can do open parentheses; we'll give the range, and now let's say we want to change all of them to a different format. So instead of the um forward slash—I'm going to keep calling it that if that's correct—we want to give it a dash. And so then we close that, and now all of them are in this new format. So it it's able to substitute a specific value for a new value, and if you don't include an instance, then it'll do it to every single one in there. So let's go over here, and we're going to actually use the the um the the instance num, and I'll show you what that does, uh, and so really quick we'll do the exact same thing that we just did; we'll do the forward slash, and we want to replace it with this one again—this dash—but we only want to do it on the first instance of that forward slash. And so as you can see, all the ones that um all the ones that were replaced are the very first instance, whereas the second instance, which is the second time it appears in this string, does not get touched. So if we take this and we put it right over here and we move it to two, it's kind of the opposite; so the first one wasn't touched; the second one was. So we're choosing which instance or which time it shows up in that string, and then it replaces it. If you do not choose an instance, it chooses all of them. So this can be super useful if you want to do like a bulk replace, um, but you only want to do it on a specific column, um, and you just want to use a formula really quick, right? Um, and so you can use this in a lot of different ways. So that's how you're able to actually do it with the first instance, the second instance, and if you don't include an instance at all.

Let's go over to the sum. Uh, this is one I think everyone knows how to use, but I want to show you two other ones um as well. So let's go to the sum, and we're just going to do equals the sum, and I hope you know what this is—well, not hope, I—if you don't know what this is, it just adds up all the numbers in range. So we're going to add; sum means add. So we're going to take this, and it's going to give us the uh what all these salaries are together. So super super simple. Sum is one of probably the most basic formulas that you can do. Um, sumif is a little bit different; you can add an if statement, which we learned right back here; you can add an if statement, and then add it if it meets a certain criteria. All right? So we're going to do equals sumif, and then you're going to need to give a range in criteria, and you can include a sum range if you would like. So we're going to do the salary again; we're going to do a comma, and now here's our criteria. Let's do if they have greater than 50,000 for their salary, and close our parenthesis. So now it's only going to add up if their salary is greater than 50,000. Now his is 50,000 exactly, so that won't count, but we have 63 and 65,000, which does equal 128,000. So it it just gives a specific criteria or an if statement, then it does the addition, uh, so super useful on that one. So that is how you do a sumif. And sumifs is kind of the same thing as we did back here; there's the if and the ifs. So the ifs is going to be if it has—it meets multiple conditions. So let's take a look at that one. So let's do um equals sumifs. Now uh oops, now the syntax for this one is going to be a little bit different; you'll see that in just a second. This adds the cells specified by a given set of conditions or criteria. So let's do an open open parentheses; we give the sum range. So let's do um the same one as before. Then we have our criteria range. So what are we looking at? What's um this is the area that's going to be added after all these if statements are done, right? So we have to initially set that. Now we're going to say, okay, what criteria are we basing this off of? So let's put a comma, and we're going to base it off of—let's do this one—we'll say um if the uh gender, so we'll do comma, if that's female—oops, if that's female—and then we'll give another one; we can say if they're female and let's say they are greater than oops, greater than 30, and we'll close that up, and it's going to give us 88,000. So female female—there's one two right here—so it's going to be this one and this one that equals 88,000. So that's how that works; you're able to incorporate several different conditions into uh the sum formula. So again, I know this one's super simple, but you you can use it in a much more complex way if you use the sumif and the sumifs.

Almost the exact same thing for this count; I'm not going to go super in depth into this one; um, I'll just kind of show you because count is um count and sum are kind of on the same level of difficulty; they're both pretty beginner. This is just going to give you a count of how many cells um are there. So let's give this range, um, and so it's not going to add it; it's just going to give us a count. So if we do right here and scroll over them—like highlight them—this count down here—oops, this count down here—is nine, and so it's going to give us that count. But we can do a count with conditions exactly how we did it in the sum. So if we do countif—oops, I did not spell that right—if we do countif, we're going to give a range and a criteria—exact same as we did before. So let's do this; I mean, you can do this on basically any of these; it doesn't really—for this demonstration, it doesn't really matter—um, but we'll say if their salary is greater than 45,000. So how many people—this is going to give us how many people have a salary over 45,000—and that's five. So before, in the sumif, if we did that, um, we did 50,000; it adds everything together; the count is just going to count the amount of cells that meet that criteria. And again, countifs, uh, we're going to have a criteria range, and then we will specify what if statements we want to be uh to occur in order to count those cells. So let's do—we want, you know, we want to count—it can be any range, or it can be any of these; we'll do the ID this time—and now we can say, you know, want it to be—is our criteria one—we can say we want it to be greater than—want their ID to be greater than 1005—and let's say we want them to be male. So they have an ID over a certain um a certain range, and then they are a male. So there's only three people that meet that criteria, and so it'll be Michael, Stanley, and Kevin; those are our three people. And so it gives us a count—very useful to give quick numbers like this—something I I genuinely use a lot, and I know I've said that a lot during this tutorial, but that's because everything I'm showing you are things that I've used a lot, so I don't feel like um you know I'm speaking out of turn here.

Let's look at this one; this one is very um has some specific use cases. Um, notice that this is a text right now. Um, if you do it when it is uh in a date format, it actually will not work; I mean, I can—you can test it out yourself; you just got to trust me; it's not going to work. So what this does is it's going to give you the range from this day to this day; that's what it's going to do. So let's do uh oops, days; it's going to—we want to choose our end date. So this is our end date; it's kind of backward from what you think—end date to start date; you think start date to end date—so you have to start with this one, and then we're going to choose the start date, and now it's going to tell us how many um how many uh days was it from here to here? And this one, it's 5,56. Networkdays is extremely similar, except it takes out holidays and it takes out weekends, and you can see how many working days has this person um how many working days or networkdays has this person worked—not including, you know, weekends and holidays—have they actually worked since their start date and their end date? So let's do networkdays, and we need our start date, our end date, and you can specify extra holidays if you'd like, but there are a already standard set holidays in there that it takes out, um, so you know, if you want to do

That you can. So we're going to do the start date again. This one's different. This one says start date, end date, and then we're going to give the end date. And if you notice, they are going to be different numbers. It's dramatically lower because it's taking out weekends and holidays. So this is how many days—uh, calendar days—they've worked, and this is how many days they've actually been in the office and worked. And that is it.

Um, again, there are so many formulas. I mean, literally hundreds of formulas that you can utilize and use and are out there for you to try out yourself. If there are specific ones that I did not cover in this video, please, please put it in the comments below so that I can, you know, show you how to do these things. I, I, I will say I've probably used a majority of the ones that you're going to put in the comments already. And if I haven't used it, I'll take a look at it and see if it's really useful, and I'll show you that. So thank you guys so much for watching. I hope that this has been helpful. I, I feel like a lot of these things are not things that I learned before I started. Almost all these are ones that I learned while I was on the job. And so I'm hoping that you can get ahead of the curve, and you can learn, learn these things before you actually start. So that when you get in there, you're just like killing it with the formulas, and people are like, whoa, this guy is like, this guy knows what he's doing in Excel. Give him all the Excel work, and then you become like, you know, just the Excel guy. Um, and everyone, you know, loves you for it. So with that being said, thank you so much for watching. I really do hope this helped. If you like this video, be sure to like and subscribe below. I'll see you in the next [Music] video. [Music]

What's going on, everybody? Welcome back to another video. In this Excel tutorial, we'll be looking at [Music] XLOOKUP. Now, if you don't already know what XLOOKUP is, it is a new feature in Excel to kind of replace VLOOKUP or to be a much better option—at least in my mind—is a much better option than VLOOKUP. And so if you're someone who's either used VLOOKUP a, a lot and you're trying to, you know, learn this new option, or if you've never used it before, this video will be super helpful because I'll walk you through kind of the options and what XLOOKUP can do, as well as the difference between XLOOKUP and VLOOKUP. But before we get into the tutorial, I want to give a huge shout out to today's sponsor, and that is Udemy. Udemy is the go-to place if you want a full-fledged course in Excel. I have three options of courses that I have taken on Udemy, so I'd highly recommend checking those out. They are having a huge sale on all their courses during this time. And so if you are in the market for a course, I highly recommend checking out Udemy and getting one there. Now, without further ado, let's jump on my screen and start the tutorial.

All right, so let's get me off the screen because we all know why we're here. So I didn't include this in the formulas video last week because I knew this was going to be a large one, and a lot of people are going to want to know how to do this, what the difference between VLOOKUP and XLOOKUP is. So it has its own dedicated video to it. So let's get started. It is a formula, so we're going to come in here in this cell, we're going to hit equal, and then we're going to start typing XLOOKUP. Now I'm gonna hit tab in just a second, but let's read what this says. It says, "searches a range or an array for a match and returns the corresponding item from a second range or array. By default, an exact match is used." So really useful to know. Um, we'll talk a little bit more about that in just a second. Let's hit tab, and it's going to complete it, and it's going to start giving us, or it's going to tell us what our input values need to be. We're going to have our lookup value, we're going to have our lookup array, our return array, and then some options, things like if not found. So if your option isn't found, you know what will be, um, you know, the, the uh, output that it gives us, a match mode, and a search mode. And I'm going to show you, um, kind of how to use every single one of these things. As you can see at the very bottom, I've kind of already set up all of the instructional, um, instructional content for this video, and so we'll kind of get through all these different scenarios. So let's just start really quickly with, um, how to use it very simply with the lookup, lookup array, and return array. So we're going to come in here, and we're going to give it our lookup value. Now, Toby Flenderson, right over here in A3, is going to be our lookup value, so that's who we're going to be searching for. Now we're going to hit comma, and now we're going to be needing to look up, uh, or to input our lookup array. Now an array is just, uh, you know, a range basically. So we're going to do—this is where it's going to be searching for, um, that value. This is where it searches for A3. So here's Toby Flenderson, here's Toby Flenderson, so it will find it in this array right here. Then we're going to hit comma, and now we need to give it the return array, what it's going to return on that row when it finds it. So we're going to return his email. Keep it really simple. So what it should do, and let's close parentheses, what it should do is it should take Toby Flenderson, it's going to search in this column or in this array, and then it's going to return the email when it finds Toby Flenderson. So it's on Toby Flenderson is on row six, so it's going to find Toby Flenderson, it's going to come over here, and it's going to return Toby Flenderson, tobyflenderson@dundermifflincorporate.com. That's what it should do. Let's see what it actually does. Said enter, and it returns it. Now if we drag it down like this, it'll apply it to all of these names right here, and it works exactly how it's supposed to.

Um, again, if you have never used VLOOKUP, you don't know how good you have it. Okay, VLOOKUP, um, was extremely useful, but just, uh, a bit complicated, and I'll talk about that near the end of the video when we compare VLOOKUP to XLOOKUP. But just know that if you're using XLOOKUP for the first time and you're just getting into using Excel, you guys have it good. Okay, so just know that. Um, now let's go over here to XLOOKUP multiple rows because you can return more than one output with, um, with XLOOKUP. So let's go right in here, and we're going to basically write the exact same thing as we did before. So let's write XLOOKUP, we're going to do Toby Flenderson as our value, we're going to search here, and we're going to do something a little bit different this time. We want to include our end date and the email. So what we're going to do is we're going to start here, we're going to go down all the way to the bottom of end date, and then we're also going to include the email. And when we do that, it will, uh, in the output give us a row or a column for end date and a column for email, so an output for both. So let's hit enter, and now we can see that we have the end date here and the email here. Now one of the downsides, or, or something that I'm not a huge, huge fan of, is—well, first off, I love that you can do this, that's fantastic—but it has to be right next to each other. So you're only going to get that output exactly how it is in the columns. So if I went and did this range, um, I would include all of that, um, so H, you know, let's just, for example, let's pull that down here. So let's take this and put it right here. If I did instead of O2 to P10, if I included H to email this whole range and I hit enter, it's all going to be included. So, you know, that's one of the small downsides of, of that functionality of when you can use multiple rows is that it's going to use the rows exactly as they are. You can't really customize it within the formula. You can move around, um, these columns to how you want it, um, so that is something to note. And again, you can pull this down, and it'll be applied to all of those names. Let's go over to XLOOKUP exact match. So let's open this up. We're going to do equals XLOOKUP as we've been doing, and we're actually going to be looking at the if not found and the match mode, uh, both, you know, on this tab right here. So let's do what we've been doing before. We take our value that we're looking up, we take the array that we're looking, and we're going to do the email. And, you know, as you can see, this says Toby Flender and not Toby Flenderson. So what we are going to do is we're going to hit comma, and if it's not found, you can return, um, a value or a string that you want to return. Now, for simple purposes or for simple instructional purposes, we're going to do not found, and then we're going to close that off. So let's do this, and Toby Flenderson was not found, and so it was returned not found. If Toby Flenderson was actually in this full name, then it would have returned the email. And then if, along the way, you know, one of these was not part of it, then, you know, we would have, we would have had the not found. All right, so let's go right up here. We're actually just going to copy this, uh, because I want to reuse it, um, and then we're going to go right here, and we hit a comma. Now this is our match mode option, and so we have four different options that we can choose from. A zero is an exact match, and that is by default, that is what we have or what we use. Then there's a minus one, that's an exact match or next smaller item. Then there's a one, which is an exact match or next larger item. And then there's a two, which is a wild card character match. Now we're going to do that, and we are going to, um, you know, try this out, and it's not going to work, and not just because I forgot to put A4, it's doing it because it's searching for Beasley, but if there's not a wild card option already put in here, um, it doesn't recognize it. So we need to indicate where that wild card needs to be. So we're going to do a double apostrophe or quotation marks, we're going to put, put an asterisk right here, and then do another one, and we're going to hit an ampersand. So we're going to have an ampersand right here, and when that's going to say is anything that comes before A4, anything that comes before Beasley is okay, doesn't matter what it is as long as it has Beasley at the end, that is going to be okay. So we're going to have Pam that comes before Beasley, and that's going to tell it, and it's going to say, okay, I know that anything that comes before Beasley is all right. And so when we hit enter, is now going to return the output that we are looking for, and we can include that on these as well. Now this one is Meredith, um, and so Meredith is at the beginning, so we have Meredith Palmer. So we can actually take this, and we're going to put this at the end, put the ampersand right here, and now it'll work. And the exact same thing for Kevin Malone right here, Kevin Malone. So it just didn't include, uh, the ne at the end, and so it's still going to work if we include that asterisk at the end.

Now I know I said we were looking at search order, but I'm actually going to kind of give you an exact match, uh, first, and then search order, but it just kind of easier to show it over here. So I'm going to do XLOOKUP, I'm going to look up this value, do a comma, here's the range, this is our start date that's it's going to be looking for, and I want to return the full name. Now no value in here has 11/1/2000, but what we can do is we can do comma, and then a comma for the match mode, and do an exact match or next larger. And I know this is in the exact match part, but it, you know, kind of refers to search order a little bit, um, where it searches for the next largest value, that's that's what that number one represents, the next larger value. So we have 11/1/2000, and if we look right here, the next value above 11/1/2000 is 1/5/2000, and so it should, should return Angela Martin. Let's see if that works, and there it is. Now let's look up the actual search order, um, so let's do equals XLOOKUP, this is the value that we want to be searching for, and we're going to be looking in this start date, and comma, and we want to return the name. Now let's get over to search mode. Now the search mode performs a search starting at the first item, so at the very top going down. So by default, it searches from first to last, but you can reverse that and do search from last to first, or you can do a binary search, which is where it sorts in ascending order or sorts in descending order, um, and that's with the actual value. And so we won't be able to show this binary search or on ascending or descending because our values are the same, but if we had different values and we were looking up, um, using this, um, next largest, we, we would be able to show that. But I'm going to show you the search from first to last and last to first. So let's put in—by default, and this is what it would be—search from first to last, what the default would be. So it starts at the very top, it goes down, and finds the first 5/6/2001 and returns Toby Flenderson. Now if we go in here and we hit minus one, that is going to search from last to first. So it's going to start at the bottom and go to the top, and the first one that it finds is Michael Scott, so that's that first one starting from the bottom, and then the Michael Scott right there. So these two, the exact match and the search order, can kind of be combined into, um, this one right here. We're using this one, um, which is, you know, exact match or next larger, and you can include that in this binary search in this one as well. All right, now let's head over to the XLOOKUP horizontal. I think we're, we only have a few left. Yep, XLOOKUP horizontal, then we'll do XLOOKUP with SUM, and then I'm going to show you the VLOOKUP at the end. So let's go right here. Let's say equals XLOOKUP, the value that we want to be searching for is February, that's what we're looking for. Hit comma, and where do we want to search to find February? We want to search in, uh, these calendar months, and then we hit another comma, and now we're going to be searching for paper. So let's do paper, and we'll hit enter, and it found February and it returned paper right here. And we can do that for paper, printer, and manila folders, and so it's going to give us the 310, the 40, and the 118 from February. Now let's go right over here to XLOOKUP with SUM. I actually, it's basically a carbon copy of this, uh, let's take this over here real quick and place it right there because it's the exact same thing except at the end, we're going to use—I'm going to show you how to use SUM with the XLOOKUP at the same time. Now, um, we're going to be using the formula SUM, and so we're going to do SUM, and then within the SUM, our first number is going to be an XLOOKUP, and then our next value is also going to be an XLOOKUP. So let's do XLOOKUP, and now we're going to search for our very first value, oops, our very first lookup value. So we're going to go to I1, and then we're going to search this again, and we want whatever value, oop, goes into that. So let's close that parenthesis, and now we're going to do a colon and another XLOOKUP, and now let's do March. So now we're going to search for March, we're going to do our search range where we're searching for that March, and we want the paper as well, and let's close that, and then we also need to close that parenthesis. So now we are basically adding this February and, and this March, so it's going to be 310 plus 150, it's adding those, um, two values, and it should be, uh, what, 460? So let's see if that is our output, and it is. So you can do this with a lot of things, not just SUM, but you're able to use XLOOKUP within different formulas. If you're searching for a specific value and a specific value, um, in, in another, um, cell, you can add those together using XLOOKUP, which is honestly, it's pretty great. So let's go over to VLOOKUP. I wanted to show you this because I wanted to show you where it came from and what we used to do, um, unless you are continuing to use VLOOKUP and what we can do now. So XLOOKUP, I just showed you kind of everything, um, but super quickly, I'm going to show you how VLOOKUP used to work, um, in a super short way so that you can understand how it used to be used and how it is used, uh, how XLOOKUP is used now. So let's go in here, and we're going to say equals, and we're going to do a VLOOKUP, and so we have a lookup value, val, and so we're going to click this, we're going to hit comma just like we did before, and now we're going to do a table array, and the table array is a little different in that you're searching an entire area. So let's do, uh, H2 all the way through O, oops, O10. So that's what, that's what our table array is going to be. Then we're going to do a comma, and now we have to do a column index number, which number, um, are we going to be, um, searching for? Which, um, value are we going to be searching for in here? And so we want to search for eight because this is 1, 2, 3, 4, 5, 6, 7, 8. We want to return that email, and we're searching for the name right here in this very first column. So we have that comma, and we're going to do eight, and then in the range lookup, you can do true, which is an approximate match, or false, which is an exact match, and we'll do false. I don't know why it's not auto, auto doing it, but there we go, and now we will do it, and it's going to return it just as we had it.

A lot of people, uh, I guess not everybody, but some people didn't like—and the reason why they created XLOOKUP—you had to do those ranges, and if you ever went in here, and then we, let's say we, um, added another column, which happens to data, now it gives completely different, different data. So let's say, for whatever reason, we added, uh, address. So now we have these people's address, well, now it's going to give us a different, um, value. It's going to have this end date because if we go in here now, it doesn't, now the eighth is this end date, and the ninth is this email. So if you have a VLOOKUP that you use for, um, you know, a calculation or a table that you've created or different things in Excel, you then have to go through here and manually change this. And so a lot of people didn't like that because if you, you know, needed to change data or you needed to change something or add an additional column, you'd have to go back and fix all of your VLOOKUPS. They wouldn't just automatically, uh, move with it, which is what happens with XLOOKUP. And just to prove this, uh, let's go back to the very first one, which is the XLOOKUP, and right now the email

Is looking at O2 and through O10. Um, we're just going to insert right here, and that would be our new column. We'll do address—oops, address—and notice that it hasn't changed. And why is that? Because it auto-changed for us from P2 to P10, understanding that it wanted to stick with, when something was inserted here, it wanted to stick with the original data, the original array that was selected. And so XLOOKUP, does that work for you? And it makes it a little bit easier to automate things and create these processes in Excel without having to go fix it later, which you had to do with VLOOKUP. So that is it for today. I hope that you know how to use XLOOKUP a little bit better now that you have watched this. Uh, if you enjoyed this video, be sure to like and subscribe below, and I will see you in the next [Music] video.

What's going on, everybody? Welcome back to another Excel tutorial. Today we'll be looking at conditional formatting. [Music] Now, if you've never heard of conditional formatting before, that's okay. I had never heard of it before I became a data analyst. And so now that I've been using Excel a lot—of course, I use it quite a bit—and so I want to show you how to use it. Conditional formatting is basically just a way to see patterns and trends in data, and that's a super simple way of putting it, um, but it's very easy to use. And so hopefully I can show you how to use it, uh, really easily in a lot of the things that I use the most and some of the things that I use it for, so that you can also know how to use conditional formatting.

Now, before we jump into the tutorial, I want to give a huge shout out to the sponsor of this Excel series, and that is Udemy. You guys know by now that I absolutely love Udemy. I've been using them for years, and I've taken literally hundreds of courses on Udemy, and I've learned so, so much, especially when I was first starting out as a data analyst. Uh, I learned a lot through their Excel courses on Udemy. And so I have actually put the ones that I really like, and I have taken and enjoyed and think you would as well, in the description. So if you want to take those, be sure to check those out. Again, huge shout out to Udemy for sponsoring the series. Now, without further ado, let's jump onto my screen and get started with the tutorial.

All right, so let's jump right into it. On this Home tab right here, if we go all the way over to the right, there is conditional formatting, and the description that it gives us is: Easily spot trends and patterns in your data using bars, colors, and icons to visually highlight important values. And that is exactly how I would have defined it. A really good job, Microsoft; exactly how I would have done it. So what you'll see right away is there's nothing too complex. So we have some highlight cell rules, um, we have some top/bottom rules, data bars, color scales, icon sets, and then at the bottom we can create a rule; we can clear the rule; and we can manage our rule. So if you create a rule, then you can manage it. So we're going to start with these icon sets, and I'm going to show you how to use those, and we'll work our way to the top, and then I'll show you how to create some rules yourself and how that all works. So let's start off with the icon sets. I'm going to go over here to sales, um, and for this data we kind of have this, um, you know, trend or or pattern that you can kind of see over time, so over the months, um, so if we go right here and let's use that conditional formatting, let's use that icon sets, and right here we can use these directional. So, you know, we have this kind of time series each month that shows us how much paper they're selling, and if we do this right here, it's going to show us if it's kind of average or if it's below average or if it's above average or if it's going up. So at a really quick glance, you can kind of see the pattern of this data set; it's kind of going mostly yellow and red; there's only two months where it's going up significantly.

Now we don't have to only do that for one row or one column; you can apply to all of them. But as you can see, all of these are red. Now why are they all red? It's because they're using numbers for everything, so they're comparing these 24s, these 50s and 65s against these 450s and 750s, and so they're all going to be red. But if we do it individually, if we do it each row, if we take it just like this and then we go to Icon Sets and do it, it's going to be much more representative of the actual printers, not of all the numbers as a whole. And you can do other things; the arrows are ones that you'll probably see the most often; that's the one I've used if I ever do use them, um, but you can, you know, do ones like this where they have, you know, kind of a trend upward or a trend downward, um, and so there's just several more arrows. This one only gives you three, as you can see; this one gives you five, um, and you can do, you know, colors or shapes or or different indicators and all these different things, um, and honestly it's kind of whatever you want to use; whatever makes sense for your data. But, you know, I've really only ever seen like these colors being used; I've never really seen these flags or anything like that. But again, it just depends on what industry you work in; you might you might see that. Let's go right over here to the demographics, um, and let's look at our color scales. Now color scales are going to be the probably the most obvious thing that, in data bars, are going to be the most obvious things in here, um, if you go right here and and you look at this color scale, if it's high, if it's among the top ones, it's green; the lowest, it's red, and you can change that, um, to really any colors you want, any colors that they offer you, um, and it it does exactly what it does; it's a color scale, a gradient of the colors from high to low or low to high. And so any color that you do, you'll be able to kind of see, um, you know, what's good and what's not good. That really is, um, color scales in a nutshell. Data bars are again super, super straightforward; it's going to be either a gradient fill or a solid fill. So let's look at the gradient fill. If we do a blue gradient fill—I'll actually, let's get rid of our—let's go over here; let's go to Clear Rules from Selected Cells. We haven't looked at that yet, but that's how you clear it. Let's go to Data Bars and we'll use this blue gradient. So with this blue gradient, you know, this one is—or sorry, this one is the highest one, so it's going to be completely filled, and this one is 36,000, almost half of this; I'm pretty close, and so it's almost half, um, this one again, you know, it's not used very often; I you don't see these a lot, to be honest; you just don't, um, but if you do see it, that's how you use it; that's how it can be done. Again, pretty easy. As I just showed a second ago, if you want to clear the rules, you can clear from the selected cells; that's what we're doing. So I have column G selected, and I'm going to I'm going to clear that. If you want to clear the rules for the entire sheet, you can do that as well, so it would affect every single column and row. We'll just do this for now. So now let's go look at the top/bottom rules. So, so this is the top 10 items, top 10%, bottom 10 items, bottom 10%, above average, and below average, and they're going to do exactly what you think they are going to do. If you select above average, it is going to select or highlight the cells that are above the average in column G. So let's look at the salaries that are above average. All right, and so, uh, the ones that are at the very top are Michael Scott, Toby Flenderson, and Dwight Schrute—no shock there—um, I believe the average is somewhere around like 48,500 or something, so I think this one just is just below it, and so all these other ones are below average, and that's just because, you know, Michael Scott and Dwight Schrute and Toby are kind of bringing up that average quite a bit, so everyone else is going to fall beneath that. So at a super quick glance, you're able to just highlight the cells, and you're able to see who is above average, and you know you can do this in a lot of different ways in Excel, but this is just a really simple, fast way to do that. Um, let's get rid of that real quick and let's go back up here, and now we can—oops—let's go to top/bottom rules, and now we can see the below average, and it's going to highlight all the other ones, and so it works exactly how you think it is going to work, and this is the default way that it highlights these cells, so it highlights them this kind of see-through red, and then it highlights the actual text or or the um characters in there red as well. Now I'm not going to go through and show you every single one of these top/bottom rules; I think they're pretty self-explanatory; I just kind of wanted to show you what happens when you do use one of them; it's going to highlight that cell. So let's go up here to the Highlight Cells Rules, and honestly these are the ones that I use by far the most; all these other ones combined I do not use more than this Highlight Cells Rules, um, and the one in here that I use more than any other conditional formatting rule is this Duplicate Values. So I'll start with that really quick, and I'll kind of show you a few few of these other ones, but this Duplicate Values, to me, is one of the most useful ones, um, and so let's kind of show you how that works. If we go to the Start Date, you can see that we have a duplicate value right here, and if we go over here to Conditional Formatting, Highlight Cells Rules, and Duplicate Values, it is going to highlight, um, the uh duplicate, and that says Duplicate right here. Now we can go through here and click on Unique, um, and then it would highlight all the ones that are not duplicates, um, so you can use it, you know, kind of in a similar inverse way; it's just different, different. But I use the Duplicate almost always, um, another thing that you can do is go over here and you can change the color, um, or you can even do a custom, um, which I never do that; it's not, um, something I spend a lot of time doing; I typically just stick with this one. So you can do that, and it's going to highlight, um, you know, something that has a duplicate value in there. Now why do I use this so much? Well, I work with a lot of different types of data sets, but one thing that you'll find in almost all of them is they have some type of ID, and they're going to have some type of, um, personal information, whether that's a Social Security number or an address or, um, you know, or a cell phone number or something like that; there is going to be data that is going to to identify that person. Now I work a lot with pharmaceutical data, a lot with pharmacy data, um, as well as healthcare data, so like names, Social Security numbers, addresses, phone numbers, all those things, all that customer or or client information, and oftentimes when I get a new data set and I have it in Excel or I convert it to Excel, I will start using these duplicates to try to find issues with the data, and I find them all the time; either there's an employee ID or some type of customer ID or client ID that has a duplicate in there that should not be in there, or there's multiple Social Security numbers, or there's an issue in some other way, and I'm able to find those things and spot those patterns using this duplicates, and I promise you I use this one almost every single time I open a new data set or I work with a new client's working with their data, um, and so I wanted to show you this one; I wanted to really press upon you that this one is a really, really, really good one to know and learn how to use; it's not complicated; it's not hard; it just shows you, you know, you know if there's a duplicate value. But I wanted you to know how I use it and how often I use it, so that you can, you know, pick that up and put that in your tool kit in your back pocket so that you can use that later on if you have uh if you have a similar need or if you're trying to do something similar to what I was just talking about. So that is how duplicates work. Again, super great; it's obviously not super useful when you're only using, um, 10 rows, but when you have, you know, 50,000, 100,000, and there should be zero duplicates in there, and you highlight it, and then uh you come right here, use the filter, and we're going to filter, and we're going to sort by the color, and it allows you to sort by the color, and you have duplicates in there, then that's a problem, and you identified a problem super quickly, uh, and you know some of those things they slip by because nobody checks it, and so that's something that I I often check. And if you go here and you sort by color and there isn't an option to do, um, this this pink/red color, and that means there aren't any duplicates, and that a really good thing—most of the time that's a really good thing. So let's go ahead, and we're going to clear that as well as get rid of our conditional formatting rules.

Now another one that I use a lot is this one right here, which is the Text That Contains. Honestly, this one comes a lot in handy, especially when you're looking for like a specific keyword. In my, uh, case, a lot of times I was using this when I was going through drug names. I am not a doctor; I do not pretend to be a doctor, and so when I was looking for lorazepam or something like that, um, I would just search for like "loraz" or something and and not Lorax, but Loraz, you know, I I would just search for it, and then all the ones that contain that would pop up; I can bring them to the top, and I can see them, and to me that's super, super useful, and I would do that all the time. And so in this case we're looking at emails, and let's say we all only wanted to pull all the ones that are Gmail, and so now we can go through and we can, you know, click Okay, and that's going to pop up, or we want all the ones that have "Dunder Mifflin," and if we click on that, all the ones that are Dunder Mifflin come up or have Dunder Mifflin in it, and again we can, um, sort by or we can, and so we can sort by right here, and we can bring all those to the top, and so super, super useful, um, and another use for it that you may not think of is something like if it's, you know, there's some incorrect data in there; this happens often with phone numbers, addresses, um, start dates or or or dates in general, date formats where you can go in here and you can say Text That Contains, and if you know you put in a oops a dash and it has it in there, then you know that that is that is wrong. Now that is really all I wanted to show you in the Highlight Cells Rules; the Duplicate Values and the Text That Contains are by far the ones that I use the most; all the other ones I have used, um, these ones not so much, but in these Highlight Cells Rules I use, you know, these two all the time, um, sometimes I use this between; I don't really use these other ones as much, although I have used them. And so you got nothing else from this video; I just wanted you to know that these two are super useful, and if you haven't used them before, to maybe try them out and see if you can apply them to your own data sets.

Now we've looked at all of these preset ones in conditional formatting, but you can also do a new rule. And so if we click on New Rule right here and we go down to Use a formula to determine which cells to format, we can add our own formula in here that will then highlight exactly what we want. And so if there isn't a preset rule that you like and it doesn't have the option that you want, you can do almost any formula that you want. In our formulas video that we did a few weeks ago, and you can put it in here, and then you can format uh what you want the cell to look like if it meets that criteria. So let's take this right over here, um, and before we start this formula, I just want you to note that, you know, I have H11 highlighted; that's going to come into play in just a little bit, but I want you to be aware that H11 is the cell that we're highlighted. So what we're going to do is we are going to create our formula. Now if you've never created a formula, I highly recommend uh watching my formulas tutorial because that is going to show you how to do this, um, but we're all we're going to do is we're going to do equals; that's how you start the uh how you actually create a formula, and we're going to give it this range right here. And so it's going to take everything from G2 to G10. Now these dollar signs are super important; if you don't know how to use them or you don't know what they do, um, you're going to mess up this formula a lot, uh, and so what this dollar sign basically does is it's basically hardcoding it in there; it is only going to look at G2 and is only going to look at G10 or through G10 because that colon, and this can come into play because if you have something selected like the H11, it's going to mess it up because now if you have H11 selected like we do, you'll see this in a second; it's not going to be applied to this, um, and again I'll show you that in just a minute, but we don't want this hardcoded in there. Okay, but we do have to select the proper range in a second, um, so we're going to get rid of this; we're going to get rid of the dollar signs because we want to pretty fluid and be able to applied to be applied basically anywhere we want. Let's go into this formula, um, if it meets our criteria, let's give it, um, let's give it a border, and we'll give it, um, we're going to say if this is greater than 50,000. So let's hit Okay, and nothing happened. So let's go back and see why. So if we go to our Manage Rules, you can see that so as the G2 to G G10 is greater than 50,000, but it only is being applied to this H11 cell, which really makes no sense, um, so if we had wanted to get it done the first time, we needed to have basically selected that G2 to G10 right away, um, but we can do that now. So let's get rid of this, and we're going to say G2 to G10, and that is hardcoded in there; that's should be fine still, um, but let's see what it does. And so now every every single thing is highlighted, and why is that? Uh, that's because when we changed it, it also changed the format of it because we changed the cell that we were looking at. So we need to come back here, and that's why again you want to do this the right way the first time. We're going to come back here; we're going to give it this range, and we're going to get rid of these dollar [Music] signs, and now we're going to hit Okay, and so now it's being applied G2 to G10, and G2 to G10, and we'll keep it like that, and we'll apply it, and now it works.

Properly so now everything that's above 50,000 is being highlighted again. If that was confusing, um, it it is confusing; it genuinely is. And so, if you wanted to do this right the first time without having to make a bunch of changes, you'd want to highlight these before you start. And then you want to go in and create the rule. We'll do this really quick, just to kind of show you what I'm talking about. We'll say equals; we'll give it this range; get rid of these real quick because, again, I don't want this hardcoded in there; it will ruin our formula. And then we'll say greater than 30, um, and we'll give this nice green. Uh, and so now if they're over the age of 30, it will be highlighted, and we didn't have to go back and change anything; we didn't have to go back and fix anything like we did in the first one. Um, that was all for demonstration purposes, but again, you need to really be aware of that; that is something that I think think almost everybody's going to mess up at some point. If you don't already know about it, then you definitely are going to make that mistake.

Now, if we come over here in this area, uh, we go to our manage rules and not just the current selection, but this whole worksheet, then you can see that we have these two formulas. Now you can go in and edit any of these by double-clicking or clicking on it and then hitting edit rule. You can also delete these rules or duplicate these rules. Um, I just wanted to show you what you are able to do with them. But if we uh go ahead and we get rid of this, um, so let's say we delete that rule and we hit apply, uh, you know, the rule is going to go away; that's that. I mean, it's as simple as that. So that is how you can create your own rule. I want to be again very specific in the fact that that is a confusing piece, and if you mess that up, you're going to be, you know, fixing a bunch of different stuff and not understanding why your rule is not working properly. It's just because it's confusing; those dollar signs are are really important to watch out for. And that is all all there is to it with conditional formatting. Again, conditional formatting is, um, you know, it's not anything super confusing; we've looked at more complicated things, but it's a really really useful tool to use to look at these patterns and trends super quickly and to find um these outliers or these specific values that you're looking for very quickly. And if you're looking at just thousands and tens of thousands or hundreds of thousands of rows, this is one of the fastest ways to find these things without having to kind of wait and filter and use these um these these filters right here because, again, this can just take forever. Um, and so if you haven't or if you've never worked with a ton of data and tried to use this before, it can take honestly like 10 minutes for something simple that you could do with conditional formatting in like 10 seconds. So definitely something to mess with and use when you are working with your own data sets. Uh, I hope this was helpful. I mean, honestly, I use this all the time, so you know I hope that somebody out there can can use this uh for their own work that they're currently using. Thank you guys so much for watching; I really appreciate it. Again, huge shout out to Udemy for sponsoring this Excel series. If you like this video, be sure to like and subscribe below. I'll see you in the next [Music] video.

What's going on everybody? Welcome back to another Excel tutorial. Today we will be looking at [Music] charts. Now, if you have data in Excel and you want to visually show that with bars or graphs or anything like that, you can do that really simply, and I'm going to show you how to do that today. And a lot of people are a little bit intimidated because they think it's a little bit complicated, but I promise you by the end of this video you will know how to do it like a pro. It's not that difficult; it's just you need to know where to look, where to click, and how to actually filter through things to make sure that you're visually showing the things that you want to show. But before we actually jump into the the tutorial, I want to give a huge shout out to the sponsor of this Excel series, and that is Udemy. You may not know this, but I probably get at least 15 to 50 companies every single month reaching out to me wanting to sponsor the channel and promote their product, and I turn down almost every single one because I either don't know their product or I don't believe in their product. And so I'm not going to, you know, go and promote that on my channel, but Udemy is one that I have consistently promoted over the past year, and that's because I truly believe in their product. I've been taking courses off their platform for years, and I've honestly learned so much, and I cannot recommend them enough. So if you want to take a full-fledged Excel course, I have my recommendations in the description if you want to check those out. Thank you again to Udemy for sponsoring this Excel Series. So without further ado, let's jump onto my screen and get started with the tutorial.

All right, so let's jump right into it. Right here we have the Dunder Mifflin sales report, and over here we have all the products that they were selling along with the months that they were sold in. And so in January they sold 450 reams of paper. Down here we have the total items per month, and so in January they sold 898 units of uh products or or things that they sold. At the very end we have the year-end total, so this is the total amount of paper that they sold throughout the year. Now we're going to use this data right here for all of our charts. Now you may not have data exactly like this; it can come in lots of different flavors, but you're going to get the basic gist of how to use charts, how to edit it, how to customize it to fit what you need, and then we're going to kind of put it right over here and kind of create its own sheet where we can kind of visualize all the things that we want to show. So let's jump right back over here into sales, and first thing we need to do is kind of highlight the data that we're going to be working with. Now I'm going to start with everything, but um, you know, I'll show you along the way; we don't actually want everything, but we can filter that stuff out as we go. So let's go right here, and we're going to insert, and we're going to go over to charts. Now this is the chart section; there's lots of different types of charts, um, but the first thing that we're going to be looking at is right here; this is a 2D column or kind of like a bar chart, and we're just going to click right here and we're going to pull this down.

So now that we have this down here, there are a few things that I want to show you before we actually really get into it. I kind of want to show you the options that you have. So if you go up here, we have different uh chart styles, and so if I hover over them, you can see that each one kind of looks a little bit different, and it really doesn't matter; it doesn't really change the data in any way, just how you visualize it. And so if that is important, if that is something that you um you want to stick with a certain theme or a certain look, then go for that. The other thing that's really nice to have over here is this switch row and column. So right down here you can see this purple and you can see this red; those are our rows and columns, and we can switch that right here. So if we go like this, now instead of the months being right here, the months are the colors, and the actual product is right here. Let's click it again, and it'll go back. And so now we have this kind of time series; now we have January through the end of year total. Now this one is one that I think is super helpful; you know, it you can do it down here as well if you go to this filter, um, but both of these are super helpful because you sometimes just want to select all the data and then kind of get in there and mess with with it. Something that we want to get rid of is this total items per month, so we want to remove that, and then we also want to remove this year-end total because both of those are are kind of the end result; they're not the actual data per month or or per product. So we're going to get rid of those, and we're going to apply that, and as you can see just right off the bat our data is changed dramatically, uh, and that's because we aren't including these these large large numbers that were kind of throwing off uh the visualization for us. So this one right here as is is already pretty good. Um, what we can do right here is we can change this, and we're just going to say products sold per month.

Now what we can do if we want to move it to another um to another sheet is we can actually move the chart, and we can select where we want to move it; we can move it to chart sheet, and we can do that, or something that I do um almost 99% of the time, I just copy, and I come over here, and I'm going to paste it. And so now we have this um this chart right over here as well as back here. And so I typically tend to do that because now we can still go over here and change this one as much as we want. So if we want to go in here, we can alter this one, and it won't affect the other one, so we just have basically two copies. So we're going to keep this one right here; this is going to be our first visualization, um, and as I said said it's it's fairly straightforward if you've ever done any types of charts or graphs before. Um, right here it's January, February, March, April, May, and if you hover over these, you can see that that's the the paper, and if we just glance, you know, the paper is their biggest product by far, and so that blue um which is their paper is going to be the biggest every single month, so that makes perfect sense.

Now what if we want to change up uh the the kind? So what if we want to change up the kind of visualization that it offers us? Well, we have a lot of different options. Let's go right over here to change chart type. Now this is going to offer you just about everything you could possibly imagine or want and even things that you absolutely would never ever want ever, um, and so I'm going to show you some of the good ones, and I'm going to show you some just absolutely insane ones that uh Excel came up with which cannot I could not imagine a scenario that these are ever used, um, but within these columns you can do; they're called cluster columns; these stacked columns so would look just like this; those are often used as well; um, and then we have ones that they're just not used often. Let's look; let's take a look at this one right here. I mean, it's tough; it's tough to look at, um, but let's let's put it right here. This is basically the same thing that we just had except visualized in a different um we'll call it more unique way, uh, and let's for the sake of it let's put it over here. These two things show the same information; they show the same data; just one is shown well, and one is not shown well. Um, I'm not a fan of these 3D type of visualizations; I I just don't like them, but maybe you do, and and you want to use that; that's fantastic. Let's go back. Something else that you'll probably use a lot are things like these um these line graphs. Okay, so these are line graphs, and they're different types, so they're these stacked, um 100% stacked lines with markers, different flavors for this this type of line graph, and so you can go in here and take a look again; um, not my favorite, but they have it as an option if you ch so choose to do this, um, but I kind of I'm kind of a simple guy, um, but I'm going to go in here, and it's pretty cluster; I want to kind of take the ones that have the highest sales or the highest total amount sold, so that would be paper, manila folders, and three-ring binders. So let's go in here; we want to keep paper; we want to keep uh manila folders, and we want to keep three-ring binders, and let's apply that. And so now it's a lot cleaner, and we're just going to copy this, and we're going to put it over here, and I'm just putting these all over here for you U because we'll look at this at the end and just kind of see different options and and ways to do things as we have gone through this tutorial. So let's go back here. Now something else that we haven't looked at is the actual colors and color schemes that you can do. So let's go right here to these chart styles, and we can go to color. Now color is um something that probably is quite overlooked um in actual charts and graphs; some terrible colors like this or or this, um, where they're really close together, especially when you have a lot of them, um, for example, let's just pretend we put all of them back really quickly; it is near impossible to distinguish these colors; we wouldn't we wouldn't want that. Let's go back to this color; you know, when you have it like uh in some of these colors at least it at least distinguishes them, so you can kind of see what you're working with with um, but when you have it in these monochromatic options, sometimes they're just impossible to distinguish. So be sure to choose the right colors that you're using so that if somebody who's never seen this data before looks at it, they can easily distinguish uh the product and the month that you are looking at. But let's go just back up here; we'll choose this default option; well, let's choose this one right here; this one's nice, although there's lots of yellows and oranges; let's see this one; this one's not bad; greens, blues, uh, and like yellows, so that's nice.

Other things that we want to look at, and there are these chart elements right here; other things that we can add are things like data labels, um, and right here it's super messy, um, but if we went back and we got rid of some of these things like the printer, staples, highlighters, pens, and total, we apply that; it's a little bit easier to distinguish, um, and that's you know something that you may be interested in doing. You can also add this data table at the bottom, which is the actual columns and rows that you have for this visualization right here. Now let's expand this quite a bit; I'm going to make this extremely large. If you have something like this, it actually can be pretty nice, um, you know, maybe we get rid of these data labels, but it can be easy because you're putting it all in one place. You can also make this two separate visualizations, so you can have one visualization just like this, and right underneath it you can have the actual rows and columns, but this option allows you to put it all in one. So let's put this back down because that is way too big, and uh wait, let's expand it a little bit. Now if you notice right here we have our legend up top; um, it is possible to actually change that; you can go right here, and you can move this um kind of wherever you want, um, but it's not exactly easy to put based off how we have it right here. If we go into to this chart elements, we go down to Legend, and we hit this little arrow right here, we can select it on the right, the top, the left, and the bottom, or we can just go to more options, uh, which allows us to push it anywhere, but um let's say I want to do it just like this; I'm going to put on the right, and I actually want to bring it down right here, and you know that's just an option if you want to kind of customize it a little further; makes a little cleaner; you can do that with almost any of these things. So if you click on this, oops, if you click on this, you can move this anywhere as well. So if you want to move this over here on top of it, you can and make it look terrible, or you can move it uh right back over here. You know, this is something that you can move around; you just kind of want to make sure you're doing it the right way. So let's get this back where was there; we go. Now before we go any further, let's copy that and put it right over here with our other uh charts and graphs. And if you see over here on this side, we have this this format chart area; notice I haven't showed you this at all yet; that is because I genuinely just don't use this almost at all; there are some good stuff in here, um, and I'm sure that you know if you were someone who really wants to go in there and super customize it, you can do that, um, but I honestly I just never get in here, and I never, you know, change the glow or the shadows; just not something I use, and some of these are only for these three 3D formatting which I never use, and so I'm not going to show you and walk through these things again; I I really don't use it, and so if you want to go in there and mess with it, uh, you know, by all means go for it; it's just not something that I want to take the time to show you. And with that being said, let's go back over to this chart sheet that we have, and it was super super easy to get these um charts and graphs and and whatnot; there are lots of different options. Again, if we go back here and we go up here to chart design and go to the change chart type, and again there are a ton of different options like a pie chart um like this; it's it's you know you can try to figure this out and use these um, but you know I wanted to show you the ones that you'll probably use the most, which are these columns and line charts, and they all kind of are similar in their own way; this bar chart is basically, you know, this column chart just on its side, and so they all have their different flavor; they all have their different way of visualizing the data, but but in essence they're using the data in a similar way to to visualize it and represent the data itself, especially things like these box and whisker plots or these waterfall charts, uh, you know, these are things that usually require specific data to kind of use uh and and so I'm just using data that you'll probably see the most of um like this this sales data. So I hope that this given you a pretty good um you know quick understanding of how to use these, how to customize them, how to copy and paste them over to to a different sheet to create some type of little uh chart and visualization sheet that you can use to show your employers and and visualize the data that you are working with. Thank you guys so much for watching; I really appreciate it. Again, huge shout out to Udemy for sponsoring this Excel series. If you like this video, be sure to like and subscribe below, and I'll see you in the next [Music] video.

What's going on everybody? Welcome back to the Excel tutorial series. Today we'll be looking at how to clean data in [Music] Excel. Now, knowing how to clean data in Excel is actually extremely useful, and there are a ton of techniques to do this. I'm going to be showing you the ones that I probably use the most; I feel like are the most helpful to kind of do the bulk or the majority of the data cleaning that you're going to do in Excel. Like I said, there's so many different ways and very specific things that you can do, but I'm going to

Highlight some of the bigger ones that I find the most useful. Some of you may be thinking, "Well, I'll just do my data cleaning in SQL or Python, or when I get it ready to put it in Tableau." Um, but honestly, a lot of the data cleaning—at least a lot of the big stuff—I tend to do in Excel if the data set is small enough to fit in Excel. And so I think it's actually really, really useful to know how to do this because you'll most likely be doing it more than you think.

Now, before we jump into the tutorial, I want to give a shout-out to the sponsor of this video. It is a brand-new sponsor; it is Unlocked by Z by HP. Unlocked is a movie that's actually broken up into four parts, and each of them has a unique data science challenge associated with it. Now I'm going to read this next part because it's extremely interesting: Each challenge represents a different topic, so there's data visualization, text analysis, audio signal processing, and computer vision. You can submit your answers and your work on their website for a chance to win one of 10 Zbook Studio laptops or a free trip to the Kaggle World Championships. So I'll leave a link in the description where you can go watch the movie and then do the challenges and then submit your answers for a chance to win. You should also go check out their hackathon where you can do these projects with other people just like you who are trying to figure out these answers and submit them to win as well. So go check that out. Thank you again to the sponsor of this video, Unlocked by Z by HP.

Now, without further ado, let's jump onto my screen and get started with the tutorial. All right, so let's jump right into it. I have this US president data set. I got the base data set from Kaggle, uh, but I added some of my own data and then I messed some stuff up as well, just to kind of, um, demonstrate some of these things that we're going to be looking at today. This is not a full project, so you know we're actually going to be using this to create any visualizations or anything like that, so you know all this is just for demonstration purposes. But we will be doing a full project in about two or three videos in this Excel series where we're going to be doing from start to finish with a real data set. So you know, if that's something that you're, you wanting, then we will absolutely be doing that.

Now, something that you may be wondering is, how do you actually identify what you need to clean in the data? What do you know to look for? Well, some of the obvious things are things like formatting and standardization. So things like, you know, this James Monroe is in all caps—that happens all the time within real data—um, and and so you know you want to standardize that, or this all lowercase—you want to standardize that; you want that all to be the same. There's also things like, um, right here, or we have this Whig, and this Whig with a bunch of random stuff after it. This happens all the time where it's not completely standardized, um, and you may even notice, um, you know, there are some spelling errors in here, and I'll we'll kind of look through that in a little bit. And then, you know, there are things like additional spaces where there shouldn't be spaces. There are things like currencies that you need to be aware of if you were importing this into or going to be importing this into a SQL database; um, things like currencies can be just a problem or be really, um, unnecessary. It may actually cause more issues in the long run, so you may just want to, you know, take that to the base value. And then dates are always an issue—always, always, always—so always look at your dates; make sure they're they're formatted correctly; make sure they're all the same. These are the types of things that, right when I glance at this data set, these are things that I'm looking for.

Um, one other thing that is actually the first thing that we're going to start out with is you want to make sure that your data is not duplicated. Because if your data has duplicate data in it and you don't want that—it's not supposed to be there—there are some specific use cases where duplicated data is okay, um, you know, you want to get rid of that, and it's very easy to do in Excel. Uh, the first thing we're going to do, we're going to go uh to this Data tab; we're going to go right over here, and we're going to get see if there's any uh duplicates in our data. So we're just going to go up to Remove Duplicates. It's going to automatically choose all of your columns to to check against, so it's going to for from A all the way through I; it's going to see is the exact same data in all these rows, and if it is, it's going to get rid of it, um, and so we're going to click OK, and it did find one duplicate, and I'll show you that one real quick, um, because you know it was right here. So Barack Obama was here twice, and then I'm going to hit Control—I hit Control Z to go back; I'm going to hit Control Y to go forward—and it removed that uh that row completely. Now, in this example, you may be able to spot that with your eye, but in a real data set where you have 10,000, 100,000 rows, there's absolutely no way you're going to see that, or very, very unlikely that you are going to see that there's duplicated data in there. So just running a a a quick um dup or or removing of duplicates—that is really important to make sure that you um have gotten rid of those things. So that's one of the first things that I do.

Um, we're going to go into a lot of these different uh columns, and I'm going to kind of show you different techniques or things that I do when I look at actual data. So I'm going to come right over here; I'm going to insert—and this is what I actually do; I I usually create a separate column, especially when I'm working with this because I don't want to change this one; um, I don't want to go in here and you know say, um, =UPPER, =PROPER, etc. There's a lot of different ways that you can change um names, or not a lot, but the main ones that you can change names, and all of them are completely okay. So, for example, I'm going to hit =UPPER, oops, UPPER, and I'm going to go like this and close my parentheses. So I selected this S; I close my parentheses; hit Enter; it is; and I'm going to hit um in the bottom right; I'm going to double-click this, and it's going to apply to all of them. It is completely okay to have your data like this if you want it to be like that; um, if you want it to be all lower, you can do that; if you want it to be in proper case, you can do that; um, there are oops, there are different um uses for all of them, and honestly, as long as it's all the same, typically it's okay. But if, um, you know, for example, if you're selling this to like a third-party company or something like that, they may have um what they want for their ingestion process when they take your file in—if you send, you know, a weekly file or a monthly file—they may want it exactly how they want it, and you can change that to to what they want. Um, but as long as it's standardized for you—it's all the same for you—that is a good thing. So now we have all of these um in the proper case; that's typically what I I do, or I use UPPER; those are the ones I use the most; I don't usually use um LOWER. And if you go in here and you type in LOWER, you know, it changes it to all lower; I don't typically do that. Um, and I'm going to add—I'm oops—I'm going to say President-Fixed, and so now all of these names, um, all of these uh different uppercase and lowercase, these are all fixed, and and it just makes it so much easier to read, and you don't have different um uppercase and lowercase issues; it's all the same. So I'm going to keep keep that right there.

Uh, if we move a little bit to the right, if you look at this Prior, now this Prior is a mess; it it has stuff all over, and to be honest, this is not really something that I would probably be using, um, like in a real data set. I would look at this column and I would say this is pretty useless. Um, if I had a very specific use case for this this data in this column, I might try to, you know, parse it out and do something, but I don't. Uh, this this is a completely useless column to me, so I'm actually going to skip this one. I'm going to go to this Party one, and this Party one to me it looks pretty important because this is something that I know I can Group By, um, and I can create visualizations with and and kind of break that out. And if you look right here, we're going to add um we're going to add a filter, so now let's open up Party and take a look. So if we look right here, we have Democratic, Democratic-Republican, Federalist, Nonpartisan, Republican, Republicans, Whig, and Whig with a a date and some information in the back of it, and then some blanks, um, and it's really important when we're when we're looking at these um ones that we think we might Group By that we have these um properly grouped. So Republican and Republicans to me, right off the bat, looks like a spelling error, and so I'm just going to deselect All; I'm going to go to Republican, Republicans, and it's literally Republican all the way down except for for this last one, and to me that's just something that I would update. So I would just go right here; I do that. If I didn't do that and then I try to create, let's say, a pivot table on here, I'll have its own group of Republicans, and it wouldn't be added to Republican, and maybe that's on purpose, but let's just presume that we know this data extremely well and that's not supposed to be like that. Right again, that that just comes back to knowing your data really well, understanding what it um, you know, what it should look like, and we know that it should not be like that, so we're going to fix that. Uh, the next thing that we're going to fix, um, and as you can see, it it got rid of it. The next thing we're going to fix is this Whig; um, that's just like an error; that's that's some issue on the the data side, and we're just going to fix that by updating it, and that's it. I would always be keeping um a a copy of this with the raw data uh somewhere else because this is presumably like a working document; this is not a um, you know, you aren't saving over your original file; let's just say that. And then let's take a look at these blanks real quick. Um, okay, so there are these rows right here that have nothing. I think we're okay, but if we see anything different—47, 48—okay, so yeah, it's just these ones right here that have no data in it. Anyways, it's just seeing it in the filter, so not an issue at all. So okay, we're looking good; we've gone all the way over; we we fixed this President; we skipped this one; um, we we cleaned up this Party, and I kept this one in here because I'm not exactly sure if that's a Democratic or Republican, so I'm going to keep it its own thing; um, I'm not a huge uh history buff in that aspect.

The next one right here is um the next one right here is really easy; uh, this is something that happens all the time, especially on actually most often it's happens on numerical data, so like uh, you know, there'll be a number of 1,1 and then there'll be a space after it for absolutely no reason, uh, and it happens all the time; it does happen like this as well, um, where you'll see this, and all you got to do is do TRIM and select the the cell; we're going to close that parenthesis, and we're going to apply that all the way down. What is so fantastic about the TRIM is that it's really intuitive, and it knows basically everything it needs to do. For example, um, it gets gets rid of the um spaces before it; gets rid of extra spaces in the middle; and um it'll get rid of extra spaces at the end, um, which you wouldn't be able to see, but they are there, and they they absolutely can cause issues if you have spaces at the end that you cannot see. Um, let's take this one for example, like if I had spaces at the end, that can cause issues when you insert or or or put that into a database; um, that happens a lot with numbers, um, you know, when you're putting that into SQL; that can cause issues, and so you really it is important to actually do that TRIM, um, and you can do that on all of your columns or just ones that you know you're having issues with. But once you import that data into SQL, you will know if there's an issue or not when you actually try to start using it. So we're going to say Vice and we're going to say Fixed, oops, there we go.

Uh, this next one is one that you'll run into a lot when you're working with numerical data; you will encounter so many different issues; um, one that I run into a lot is I I've worked with a lot of cost data or pricing data, and when it's in an Excel, it h it sometimes comes in with um these currencies like a dollar sign, a pound sign, things like that, and when you put that into SQL, it just is a nuisance, right? You're not going to be able to run—it's going to go in as a text, or it's going to be like a string, right, because it has that special character, and you don't want that; you don't want to have to then go in and then change things around; you just want to be able to start um, you know, doing calculations on those numbers. So what you can do is sometimes it'll come in as a text; sometimes it'll come in as um currency, which I think this one's a currency; we are just going to change that to be a number, and then we're going to get rid of these oops and get rid of those. That it doesn't look as pretty, but that is much more useful than actually having the currency on there with the decimals. This actually is so much easier when you when you want to use it for almost anything because you're able to add and uh do things properly in other systems. In Excel, I think it does understand it, um, but you know that can cause issues, so there is how you do that.

The next thing that we're going to look at is these dates, and just notoriously whenever I see a date field, I know there's going to be an issue with it. It's very rare that I get a date field that is perfect; uh, it just it is genuinely is um is a novelty when that happens, and most of the time it has to do with, um, let's say, a date comes into Excel and it's in a text format, or date comes into Excel and they're not the same. In this example, they are not the same, um, and we just want them to all be similar. They say Date on—if you look right here, it says Date; it says Date; it looks like it should be the the same—um, but if we go like this, it all looks the same, right? There's no issues at all. If we were to um try to use that, it may or may not be an issue, but we don't want to leave that to chance later on. If you're using this with Python or something like that, it can cause issues. You maybe not in SQL because it may um see the underlying um what's in the underlying cell, not just what we see, but some systems won't, and so you want to make sure that they're all the same, and so you know what we were doing back here with um oops with the Party, and we were looking at this uh this filter and identifying the issues; I usually do that on date fields as well, and and oftentimes, um, I know just for just for demonstration purposes, oftentimes I will get something like that, and then I'll come up here, and I'll notice that there's this one random number that happens all the time—all the time—and so you know you want to make sure that you um that you look at these things and just just do at least a quick glance, if not kind of doing a kind of a deep dive into it. But all we're going to do is we're going to do both of these, and we're going to do a short date, and let's take a look and see if that fixed it, and so now they are all the same format, and that is fantastic; that is exactly what we want. We're going to go back through here; we're going to get rid of these; um, again, this is a working um this is a working document; oops—we need to—we're—I'm going to do um Control Shift Down, oops, let me go back up; do Control Shift Down and copy, and what I'm going to do right now is I'm actually going to copy—let me do it right here; I'll show you; sometimes I do this; it just depends. I'm going to go right here; I'm going to hit right-click, and I'm going to Paste as a Value, which means it's not going to take the calculation or the formula that I just did; uh, it's going to actually paste it as that value. So we just replaced it; um, right here you can see up here it says =TRIM(G2); this now now that I copied and pasted it over as a Value, um, it got rid of that um calculation, and now it is actually a string, so we don't need this anymore. And I'll do the same thing over here as well; I'm going to Control Shift Down, copy, and I just hit the right key uh or the left key, sorry. Now I'm going to right-click, and I'm going to do Paste as a Value, and again it has this PROPER, and now it doesn't have the PROPER; it's actually the value that was here, so that's really important to note, uh, and we're going to get rid of that one. And so now what we have is is already looking much better.

Now, one of the last things I we're going to look at is deleting columns that we are not going to use, and this is why it's so important to keep a backup or or or the raw data not in this file, because if you start saving over this file and this is your raw file, uh, that can mess up a lot of things, and that happens to me before, and it's terrible, and then you have to request another file, or you have to go back and find it or something like that; it's terrible. So so this is our working document, so we can mess with this and do whatever we want for our purposes. Now, for us, um, I can already tell you that this Prior is a bunch of nonsense, and we do not need it; we're not going to use it for anything, and it and if we have—this is a small, very small data set; this only has like um, let's say, you know, one, two, three, four, five, six, seven, eight; we have like eight columns that we're you know kind of using that has data—eight or nine. Now that's a small data; I've had ones with literally like hundreds, um, and and it has so many columns, uh, so much data, and sometimes it's good to just trim it back to the things you know you're going to use. This to me is absolutely useless; um, we're going to delete that, and then right over here it's pretty redundant; um, it's just one number off, but if we scroll down just a little bit, um, it goes—it's basically just counts; it's a you could even call it a unique um identifier if you want; sure, why not? But we don't need both, um, so we're going to get rid of this first one, and now we have more of the useful and relevant data rather than the stuff that we absolutely know that we are not going to use. These date

Updated and date created. We may never use them, but we might. Um, so it doesn't hurt to keep it on hand. Those other ones are ones that we are almost certain we will never use again. Keep a backup just in case you need it. You can always go back and get it. So you know, if you go back to what we started with and you look at what we have now, it is much cleaner; it's much more usable. And these are small, subtle changes, um, especially with this very small data set of only like 50 rows or 46 rows. But you're going to be working with data sets that are thousands, tens of thousands, hundreds of thousands of rows, and you need to know how to kind of look at this data, standardize it, um, format it properly for what you're going to be using it for. If you're keeping it in Excel, there are different things that you may do than if you're putting it into a database or going to be using it in, you know, um, using Python to access it. So you need to kind of know your use case, but these are some things that I do all the time to kind of clean up the data before I use it for something, whether I'm creating pivot tables or I'm inserting it into, or I'm putting it into SQL. These are things I do all the time, and so hopefully that helps give you kind of an idea of some of the things that you should be looking for when you're actually cleaning data.

And it's really important to understand why you're actually making these changes and the reason you're making these changes because some of the things that I did today may not be things you want to do on a different data set that has different uses and different purposes for. So you know, take everything that I've said and apply it um with a little grain of salt to your data set because your specific needs may be different than what I wanted when I was cleaning my data set. So I hope this was helpful. I hope this gave you a small glimpse of some of the things that I'm looking for when I clean a data set or I get a new data set in and I'm kind of, you know, analyzing it, figuring out what I need to fix in it. I hope this has been helpful. Uh, with that being said, thank you so much for watching. I really appreciate it. If you like this video, be sure to like and subscribe below, and I'll see you in the next [Music] video.

[Music] What's going on, everybody? Welcome back to the Excel tutorial series. Today we're going to create an entire project in [Music] Excel. Now, if you've never done a complete project in Excel where you take the data, you clean it, then you create an actual dashboard where people can click on things and filter things, this is going to be a really great learning opportunity, as well as potentially, you know, a simple project that you can use for your portfolio, or you can spice things up and go a little farther than what we're going to be doing in today's video. I will walk you through every single step of the way, and hopefully we learn something together. And without further ado, let's jump right into it. Let's jump onto my screen and get started with the project.

All right, so this is the data set that we're going to be working with. I will leave a link in the description to my GitHub where you can go and download it so you can be working with the exact same data set that I am using. Now, before we actually get into this data and start looking at it, I'm going to show you what the final dashboard is going to look like. Um, we're going to create a few different types of visualizations, nothing too crazy, um, and then we'll create some filters as well so we can kind of, you know, create some interactive filters with our data. So let's go right on over to our data set. Now I'm going to hide this because we are not going to use that. But what I am going to do before we do anything is I'm going to create a dashboard, and I'm going to create a pivot table, oops, and I'm going to create a working sheet. So um, all these things have different uses, and I'll explain that as we go along. So this is our data set. Um, I'm going to copy this over to our working sheet. When I go into, you know, an Excel and I'm working on something, I don't like to, you know, use just the one that I was using in case I mess something up and it saves over or there's some issue. I like to create a working sheet and keep the raw data right over here. It just makes my life easier. I don't have to save it and then, you know, open up a different Excel to compare them. So we have our bike buyers; this is our working sheet; this is our raw data; this is the one we're actually be working on today. So let's um let's start looking at it really quick and just kind of glance and see what data we're working with, and then we'll start cleaning it up, making it more useful for what we are going to be using it for, and then we'll start building out the dashboard.

So right here we have an ID that should be a unique ID to each person. Uh, this is their marital status, so married or single; this is their gender, male, female; we have their income, children, their education, their occupation, do they own a home, how many cars they own, how long their commute is, the region where they live, their age, and if they purchased a bike. And this column right here is extremely important; this is going to tell us whether they did or did not buy a bike. So we got their information; they're looking for a bike, but they either decided not to buy a bike or they did buy a bike, and we're going to be using that one a lot in this video. And so, um, you know, this is basically the data set that we're working with, um, some of the demographics and information behind the person. So what we want to do when we are cleaning the data before we do anything, uh, I like to see if there are any duplicates in here. Um, what we're going to do is come right up here; we can go to uh, where is it? Right here, we got remove duplicates. So we're going to click on that; it selects every single one; we just want to see if there's any useless duplicated data that we do not need, uh, and the data is a header, so we're going to click okay. All right, so we had a ton of duplicates in there, uh, for whatever reason. So yeah, we do have duplicates in there, so I'm glad we did that; otherwise we would have, uh, you know, not good data, and we don't want that.

Let's start right over here. Um, the ID, of course, we're not going to change. The marital status and gender are M's, S's, F's, and M's. Um, this isn't inherently a bad thing to have it like this, but you know, we have to think about it from the perspective of someone who's going to be using this dashboard: Do they know what M and S is? Do they know what M uh and F is? And if they don't, it's better to just spell it out for the most part. Um, so let's just do that. So we're going to click on the column B; we're going to hit Control H; that's going to bring up our find and replace. Now there's an M in both of these columns, and there's different things; one is married, and one means male. So we're going to do is we're going to search by columns, um, and we'll have match case; I don't think that's going to change anything, but that just means an exact match, uh, and we're going to do M equals, and we're going to replace it with married, and we'll replace all. Awesome. And then we do S is single. This one is super easy; we're going to do the exact same thing right here. So column C, to hit Control H, we'll do still has by column, so we'll do M is male; we'll replace all of those, and F is female, and replace all those. That's great. Uh, you know, the next column right here is income, and in a previous video I talked about how I don't typically like it in this format, and that's true. Um, if you're doing calculations on it or or any other thing, it can mess it up sometimes, having the dollar sign or it being a currency. We're not really going to mess with it too much right now. Um, what we can do is just kind of make sure all of it's currency; um, we'll just go like that to make it a little simpler, but we're not going to change it to like a numeric. We will use this in the visualization; we'll see how it looks, and if we need to, we'll come back and change it; if not, we'll keep it how it is. Um, so so that's all we're going to do to that one. Uh, the children, those look good. We have education, partial College, partial High School; this looks fine to me. Um, if there's any spelling errors or anything like that, of course we need to clean that up; it doesn't look like there is. Occupation, skilled, manual, manual; okay, those should be separate. Are they a homeowner? Should just be yes or no. All right, we have cars, 1, 2, 3, 4; good night, who owns four cars? Um, and then we have the commute distance, uh, and you know, there's nothing terrible about this; it's giving you ranges, um, which can be a good thing. I say let's keep it for now, but I have a feeling when we get further and we start using in the visualization we may want to change this, so let's just hold off for now. Um, but if needed, we will come back to this, and we'll change this. Um, and then we have our region, and that looks totally fine, and we have our age.

Now, when you're using ages, typically you have some type of like age bracket or age range, and you do that because there are so many ages in here, right? It's 25 all the way down to 89, and if you're using that in some type of visualization, it could just get really messy. And so you'll create kind of, you know, just brackets around these so that you can kind of condense it and make it a little bit easier to understand. So let's do that and just create a new column, and then then we can use that for our dashboard. So let's go right up here; we're just going to create a new column; uh, we'll call this age brackets, and what we can do is we can use an if statement to kind of say if it's older than or less than and and and kind of give them these ranges. Um, that's one way to do it, and that's the way we're going to do it right now. So let's go up here, and what we want to do is we want to say is going to we're going to say equals, and we're going to do if, and we're going to close that parenthesis. Now what we're going to say is if this, we'll go right back up here, if this is less than, so we're going to do this 31, and we're going to say comma. So if they are less than 31, what do we want to call them? What do we want their, you know, name to be? We'll call them adolescent. Oops, that's not how you spell adolescent; adolescent. Um, and then if they're not, what we're going to do is we're going to say it's invalid. Okay, and let's just see if this one works first. All right, it's not working at all. Um, okay, so basically what we did was um incorrect; we did it backward. Uh, we want to do I said uh L2 is greater than 31; no, we want to do like this. So let's do that now. All right, and it should pull up where if they're under the age of 31, so if they're 30 or below is basically what it's saying. So if they're 31, they'll be invalid, but if they're 30 or below, it's adolescent, so it is working properly. Um, and let's see what it see what it says. Perfect. So this one is working, and and now what we want to do is we actually want to build on this and make it uh kind of like a nested if statement, if you've ever heard of that or done that before. So this is our first first if statement, and this is going to be this is invalid; this is our value if false statement; this whole statement is going to become our value if false for a different if statement. Um, so let let me write it out, and hopefully that'll make sense, but we're going to say if, do open parenthesis, and we're going to do it like this, and let's just get rid of this for a second. All right, uh, what did I do? And let me do oops, give me a second. Okay, we have our if; let me just write that out again; we have our if; there we go. So now what we're going to do is we're going to write basically the next part of it. So we're going to say if, do open parenthesis, and we're going to say if, oh actually, let's do it um let's not do it to this one; let's do to this top one; just easier. Uh, so we're going to say if, open parenthesis, we're going to say L2, and this time we're going to say anybody over the age of 50, uh, or we can do 55; let's do 55. So we'll do 55, and we're going to call them old, and we'll do a comma, and this is the value if false statement, and we need to close our parenthesis. So let's try this. Anybody over the age of 55 should have old. Um, you know, maybe we'll do 54. So anybody who is 55 is considered old. I think that's fair; I think that's fair, guys. Oops, I should have done I should have done that to this one. Let me get out of this, and we'll do 54. My dad is 55; that's why I'm doing it like this. This is fre dead CU; he should be in this old category to be fair. So now we have adolescent, adolescent, middle-age, and old; these are three categories, so we can now have these buckets, these different groups of ages, and it's much more usable than these individual ages, um, and so we will be using this in our in our dashboard for sure. Now our next one is the purchased bike, uh, and we're not going to do anything with that. So you know, that is that is that one, and you know, there wasn't a ton to clean up here; we removed some duplicates. Um, I don't know why it says that; what did I do? Married, married; what does this mean even mean? Did I write that? Did I mess this up, guys? Oh, when I did the M and the S uh replacement in there, it replaced it with married and single; it's supposed to say marital status. Oops, thanks for catching that, guys; thanks for catching that. I hope that's how you spell marital. Uh, we are going to keep it just like this.

Now what we are going to now now what we are going to do is build pivot tables with this data. So we had our raw data; we have our working sheet; and now we want to create pivot tables, and pivot tables is how you actually help build your dashboards or help build your visualizations. So we're going to go right here; we're going to hit whoops, get rid of that; we're going to go right here; we're going to insert, and we're going to say pivot table, and it's going to ask us what range. So we're going to go back to the working sheet, and we'll just click here and hit Control A; this is going to select all of our data for us, so it's really easy, and we're going to hit okay. And so now we have all of our pivot; I don't need I don't need to pull it out that far; that was way too far. And now we have all of our pivot table information over here, and so that should make it really easy to, you know, actually build out. So what we're going to do is start selecting what columns and what data we actually want to work with. So the first one that we're going to build out is a dashboard that is basically looking at the average income of somebody who either bought or did not buy a bike. So we need in this one; we're going to need their income; that's definitely going to be a value right here, um, but we want to break it out by male and female. So let's look at their gender; we're going to pull that down into the rows. So um, this is basically a sum, and no, let's look at let's make this an average. So I just went to the um I clicked right here; I went to the value field settings, and we're just going to do an average. All right, and then we are going to make these um and as you can see, there's four decimal points; um, we'll keep it as is right now, but we may need to go back and change something. Then we're going to look at if they purchased a bike or not, and we're going to put that right here. So so we can see that uh right here for the people who did not buy a bike, the females, their their average salary was 53,000; the average salary for the average salary for males was 56,000; for yes, the ones who did buy a bike, the average salary was 55 for female and 60 for male. So the people who had a little bit more money are buying bikes, and you can also see that uh the men are making more money in this data set just overall in general. Um, so let's make the visualization really quick, but you know, I don't know; I'm not a huge fan of these decimal points, and maybe we can just change that in the visualization; we'll see. Um, oops, that's not what I meant to do. Um, let's do that. So what we are going to do is we're going to click into here; we're going to click insert, and we're going to go to these recommended charts, and it's going to bring up basically every single type that we would want, um, and we can just click in here and see which one looks good. Oh yeah, I love those 3D ones; those are my favorite; you guys know that. Uh, let's let's use this one right here; pretty simple. Um, whoops, let's pull this right over here, and as is, it looks pretty good. Um, you know, it shows male, female; we have the average or the incomes right here; whether they did or did not purchase it, um, and so at a glance, it's pretty easy to see. Let's see if there's anything, um, you know, if you want to change up style-wise, go for it; I'm just going to keep it as is, um, but let's see if there's anything we need to add. Right? Do we want to add these access titles? Uh, for the most part, I I tend to do that; um, it makes it pretty easy to see. So we can go in here, and we can just click it like this, and we'll say income, and we'll say oops, and we'll do gender. So that's what that is, and and let's go back in here. Do we want to add a chart title? We definitely want to add a chart title; uh, for most of these, we'll add a chart title for sure. So we'll say average income per purchase. I don't know if that's 100% right.

But we'll we'll we'll use it. Uh, if we need to change it to be, you know, by gender or something, we can. But um, for now, let's see. Do we want to add data labels? Uh, definitely not. Uh, a data table? Um, we can do this. It may make it a little easier to read. I will say that again; these numbers are just—these decimal points are really throwing me off. Let's go see if um we can change it in here. Let's go to see if we can just make these numbers okay. And um, we can keep it like that, or we can even do something like this: add commas. Yeah, I'm going to keep it just like this. I I think this just looks the best. Um, again, I'm I'm getting—adding commas here. I'm changing the um decimal place right here; it just makes it look a little nicer, a little cleaner. Um, so let's keep this exactly how it is. Um, we can always change things if we want to, uh, if we want to come back to it.

So we created our pivot table, and then we created our visualization—basically exactly what we're going to do for all of these. Because again, all of these need um, you know, all of these need pivot tables in order to create the visualization. So let's um get out of here. We're going to scroll down, and we're going to create our next pivot table. And once we get done with all of the pivot tables that we need, all the visualizations that we need, then we will um we will start. So we're going to do Control A; we're going to do okay, and basically do the exact same thing that we did. Um, this time we're going to look at the distance. So for this one, I wanted to see, you know, I try to—you know, I created this already; I've already done this entire project through, but I haven't really talked about why or what we're going to look at for this one. You know—know we're looking at is their income; does it change whether they bought or didn't buy one? Um, so if they said yes, you know, is there a reason? Are they making more money? Is, you know, are price points—are the customers—do they make more money, so you—we cater to them or not? Uh, that's a good question.

Another thing is, you know, we're—we sell bikes, or this person sells bikes, so commuting distance definitely makes a difference. You know, does the person who is buying a bike live one mile away from where they work or 20 miles away? Uh, this will help us determine—this next visualization will help us determine, you know, who—who is doing that or who's buying it. So what we are going to do is we are going to look at the um that one that we were looking at earlier, the commute distance, so we're going to bring that right over here. So we have these, you know, one mile, 10 mile, 1.2, etc. Now we are going to—again, we're going to look at if they purchased a bike; that's really important, and let's make that the column as well. So now what we have is a count of these Nos and yeses, whether they did or did not buy a bike. Um, one of the issues I already see, and we'll—I'm going to visualize it, and then I'll show you that this 10 miles, you know, it's right next to the 0.1, so it's not in order, um, and that could be—that could be an issue. Um, so we may have to revise that somehow to put it at the very bottom, because we can either do ascending or descending; uh, either one I don't think is going to work, so we may have to work through that in just a second. Um, I don't know if I did that—my—I plan for that.

Um, yeah, so it has this big dip. Um, yeah, so let's—let's create it. Um, that's okay; we're going to figure this one out together, because I honestly um I didn't plan for this one. So okay, we have 0.1 miles; that's exactly where it needs to be, the one, the two, the five; that's exactly where it needs to be. This 10 miles is not, and let's see if I change that 10—10 plus miles to 10 miles plus; let's see if that'll put it down here, because I—I don't know if it's looking at—I don't know if it's reading it weird, um, but let's go into this working sheet, and let's go right here, and we're going to do Control H, and we'll do—oops, not this one—10 miles plus; let's get that in there, and we're going to do 10 uh miles plus. I—I don't know if that's actually going to work; um, we will see. So let's go back to the pivot table; let's re—go to the data; let's refresh. Uh, no, it didn't—it didn't change it. Um, okay, so let's think about this. Maybe if we change it to like a letter, it might change down here. So start it with uh miles; that could work. Um, let's try it. It—okay, it's already selected; let's do the 10 plus miles. Okay, so let's do um M—more than 10 miles, and we'll replace all. Let's get rid of this; let's go to the pivot and refresh. All right, okay, so it's not perfect, but it works, um, and for what we're doing, I think we'll keep it how it is.

So we have our second one, uh, and you know, there are different ways you can kind of change this one. Um, you know, on the last one we did a ton of different stuff; we can do—just do commute distance, and we can say—what do we want to say on this one? What is this? Oh, this is the count. Um, do we have to—do we have to keep this one? Um, no, there we go. I'm just going to do um just one and say commute distance, and let's add a title—chart title. We can make this one um let's say distance per customer. Uh, that's not 100% true because it's no or yes; that's—that's the important part of this; it's distance—average distance. Uh, let's see; we'll just say customer commute. All right, and we'll keep it just like that. All right, perfect. I don't think—let me see—I don't think there's anything else we need to add on that one. All right, now let's go right down here; we're going to create our very last one. Uh, we only had three, so you know, sometimes you'll have a ton; sometimes you'll have like one on each sheet, and you'll create multiple sheets, but um do Control A. Um, now we have our thing. Now this one we're going to be looking at these age brackets that we were looking at—that we created. Um, something that I do honestly a lot is—is kind of bracket things into groups like this, and you know, for this I'm just kind of made them up, but you know, it's good to know how to do this because I—I promise you this one happens a lot, or I use this one a ton. And then we just want to look at who purchased a bike. Uh, so the same thing as we did before, so like purchase a bike—count of the purchase. Um, you know, pretty easy, so we just have to—count of either no or yes for these age ranges. Um, and let's go to the Insert; we'll go to Recommendation. Um, I personally like a good line for this one. Um, so let's—this is already interesting. We could do something like this; that's nice. See this one versus this; it just adds a dot; it looks nice. We'll keep that one.

So just really quick at a glance—really interesting. People under the age of 30 are not buying that many bikes. Um, age 30 to 54—31 to 54—buying a ton of bikes. Uh, they buy more bikes or look at bikes more than anybody—really interesting. Um, but yeah, we'll make the dashboard in a little bit. Um, let's make these chart titles. We'll do—vert—oops, the horizontal; we just call this age bracket. Um, and then we'll add a chart title. Um, again, you can add some extra stuff if you want to, um, but you don't need to. Uh, none of this other stuff we really need; I'm just kind of looking at the stuff we do need or do want. Uh, so what do we want to call this one? Let's call it customer age brackets. Um, and it's not perfect, but we'll keep it as is for comparison. Um, let me see if I can copy um or—or use this um real quick. Instead of the age brackets, I'm going to get rid of this and use the age, and then let's use um let's insert—recommendation; we use a line, and we'll use this. So this compared to this—just think of it like if a customer or consumer or—or not a customer—if somebody you're working with is trying to use this dashboard to understand this dashboard, this is going to be—just—it's going to—I don't know—it might melt their brain. Just makes no sense. It makes sense; it's just all over the place; it's really hard to make sense of this; it really is. I mean, you can kind of see a pattern going up around like the mid-30s, and then it trends downward, but it's hard to see. Um, it really is. So doing these um these brackets really helps, and you can even add, you know, adolescent, um, you know, 0 to 30 underneath it, and in fact, we may want to do that. Um, why not? Why not? Let's do that. Oh, whoops. Um, so why don't—why don't we do that? Why don't we go back? I'm just going to—I'm doing this on the fly. Why don't we go back? Uh, what am I doing? Whoops. And this is all calculated, but let's do adolescent 0 to 30, let's do middle-aged 31 through 54, and then old 55 plus. Let's see if this breaks anything; I hope it doesn't. Um, and we'll go back to our pivot table; let's refresh the data. Uh, okay, it did mess with stuff. Okay, never mind, guys; that was a terrible idea; don't do that. Um, perfect. Uh, let's get rid of that; that was a terrible idea; don't do that. I'm glad we tested it out though. I like—I like to see if it was going to work. No, it messed with the um the order of things. Um, I—I intentionally named them adolescent, middle-ag, and old because it's—it—it makes sense for the visualization, um, but you know, if—if I change something and it messes with it, I'm not going to mess with it; it was just an idea on the fly, guys. Come on.

All right, so let's start building out our dashboard now. Um, when we're building our dashboard, what I personally like to do is to have this pivot table sheet, and then I will copy them over, and later we'll hide these other sheets—sheets—and I'll explain that a little bit, but I like to have this—this one for us. So we're going to copy this, so I just click on it, hit Control C; we're going to paste it right over here. Uh, let's just make them small for now. That's—oh gosh, no; let's not do that. Oh, these look terrible. Okay, anyways, um, let's copy this one over. Oops. Okay, what did I just do? Oh, I didn't copy this one. Whoops; it's not copying. Okay, we're going to go—copy; hit paste. Fantastic. Oops, guys, look away; this is—this is tough to watch; this is tough for me to watch; I'm the one doing it; it is tough for me to watch. All right, let's go to this last one; I'm—I'm going to try it again. All right, it worked this time. So now we have um our—our three visualizations; this is perfect, but now we actually want to create a dashboard. Now how do you do that? How do you make it look nice? U—and then we're going to add some, you know, filters and stuff like that. How do we make it look nice? Um, what happened here? What changed? What did we do? Oh my goodness gracious. All right, let's copy this; let's paste this; let's get rid of this. I don't even know how that happened; I've never seen that before; that was wild. Uh, Excel is trying to destroy my whole video. I mean, I'm doing this for you, Excel. Good night. Okay, no problem at all. What we're going to do, and how you make this at least look nice, um, first off, we can get rid of these grid lines pretty easily, and I recommend when you do that—when you make a dashboard—just makes it look cleaner; makes it look like an actual dashboard. Um, let's go to View and grid lines, so we can get rid of these grid lines; it just makes it look nicer. Um, we're going to make—you know, we can choose any color here; here I'm just going to—choose a color; I like this, and let's—we're—we're basically creating like a header, right, if you're using like Tableau or something. Um, we're going to merge and center, so it takes every single cell that we have highlighted, creates it into one. Let's call this um bike sales. Uh, I have—I think I called it bike sales dashboard; let's just call it that. Um, you know, see what happens. Let's get that—let's make it white and—and make it much larger than it is. Okay, okay. Um, sure, let's do that. Doesn't look bad. Um, what is it doing? There we go. Uh, let's—bre—that—center—perfect. Um, it's not perfect, but we're going to use it. All right, so now we kind of want to organize these, and you know, everybody has their different way of doing it. Uh, I'm just going to start building it out myself—self—and just see how it looks, uh, and then we'll go from there. I like this one there. Um, we can put this one—I—this one's a kind of a longer one, so I'll probably put it at the bottom. Let's see how it looks. Um, but we'll put this one right here; try to line it up. Geez, let's—let's zoom in a little bit; let's try to line this up; see what it looks like; let's extend it to the end. That doesn't look too bad. Uh, needs to move up just a hair, and I'll show you how to kind of align these in a second, but um that looks not bad, and we'll kind of try to align these as well. Let me zoom out and extend this—the length of this—just to make it look nice. Um, you know, now what you can do, and you know, this is something that's pretty simple, is you can get both of these, and we're going to go to Shape Format, and we can just align these. It's really nice to align, especially if like the top and maybe like the left to right, but like—we're going to align these to the top, and they just kind of align themselves on the very top. Now these look much better. This one is a larger dashboard or a larger visualization, so I'm going to keep it how it is, um, and I'm going to keep this one how it is, so it is going to be a little bit smaller, as you can tell, and then we'll have this one, um, and I'm going to do that. Um, I—this is going to bother me if I don't align these, so let me do this: I'm—Shape Format—align to the right, and it's not exactly what I wanted to happen because—oh jeez, what am I doing? That's not exactly what I wanted to happen; I actually wanted this one to align—this one to align with this one; it did the opposite. Um, so let me just scoot this back. All right, visually looks fine, but that's how you do it if you want to do it. Um, I—I—if you have multiple of them like this, it—you can make it look bad.

So we have our dashboards; this is already looking really good. I—I like how this looks; colors are coordinated; it—we have a kind of a theme throughout, um, and it looks nice. I actually—I actually kind of want to change this one um to um let's see—maybe if I did like that, it'd look nicer than all of them. Yeah, this does look nicer. Um, it doesn't change much either, guys. I'm—should I do it? All right, we're going for it; we're changing the design on the fly. Should I do it for all of them? Let's see. It doesn't fit; doesn't fit. Um, all right, guys, just ignore what I'm doing; don't do any of this; I'm just messing around at this point. So this is really great to have; it really is. And what we want to do is—there are other elements; there are other things that people would like to—feel—a—to filter by and be able to look at, but it's not in this visualization. Um, to be more specific, one field that's could be really interesting is married versus single. Are single people buying more or um married people buying more? You know, it—it'd be nice to filter on it. So we're going to click on uh any of these actually, and we're going to go up to PivotChart Analyze, and we'll click Insert Slicer. Now we can choose which ones we want to be able to filter on—all at the same time or one at a time. I'm just going to do the first one by itself, and then I'll show you how to do other ones. Um, but this one is the marital status, so this is the married—single—the one we were just looking at, and we can drag this right over here; bring it in a little bit. All right, and we don't need all that space, so we're going to boop boop boop boop all the way up. Now while we're doing this, um, it only—because we selected this uh this visualization—it only is working on that one right now. We, of course, wanted to apply to all of them; it's not hard to do. All we're going to do is we're going to click on—we're going to make sure we're clicking on this; we're going to go up to Slicer; we're going to hit Report Connections. Um, and if you remember, we have this um this pivot table that we're working with, um, and this is where all of our pivots are coming from, so we're going to actually apply it to all of them. This is our sheet U, and this is the name of the pivot table. Now, again, we created that fourth one; we're not using it, but we're going to apply it to all of them. So now when we click on it, it's going to apply to all of them. So at a quick glance, let's see what single people are doing. Interesting, interesting. Um, you know, when I'm looking at the—just these numbers right here—married people—these individuals are making a lot more—like eight—sometimes eight to like 10,000 more on average than their single counterpart. Um, you know, again, that's a rough estimate, but it's—it's interesting. So now what we can do is we're going to create more of these, so we're going to go to uh PivotChart Analyze; we're going to go to Slicer. Now we already did marital status, but what if we want to look at things like uh region and maybe something like their education? So let's bring up both of those and look. Now two of them come up, so let's add the region right here; we'll bring that in just a little bit; see if we can match it. Nailed it. All right, now we're going to put that up; we'll bring this one down just like this; bring it over; see if I can match it again. Come on. N—almost nailed it; I don't know if I nailed it, but it's close. All right, kind of bring this up a little bit; bring this up, and we have to do the exact same thing that we did with this one because right now, again, it only applies to that one um chart. So what we want to do is we want to go to Slicer—Report Connections—add it to all of them. Okay, do the same thing with education—or connections—bada bing bada boom. We are looking good. And now uh let's get rid of all of them; it's just going to be everybody. So now we can kind of slice and dice and choose what we want; we want to look at people who have a bachelor's degree who live in Europe and are single, and this is the information that we have on those people. So now we can narrow it down by certain demographics even further and look at this key information. So we may not, you know, look at counts and averages of these things, but we're able to filter on them, uh, and that's really great to know. So bachelor's degrees on average are making 60s—70,000. Um, let's look at um let's look at graduate degrees. Okay, a little more. Um, but you know, again, I'm just looking at random.

Stuff, um, but you can mess around with this. Take a look at some stuff, um, this to me. I want to make this color darker; I feel like it looks nicer darker. There we go. Oh yeah, that's way better. This, to me, is—it's a good dashboard, right? You have key information that you're looking at, nice visualizations, it's color-coordinated, you have these slicers on the side, um, to me, this is a fantas-fantastic, just simple dashboard. And there are so many other things that you can do with this data, and you can make it unique, and you can add your own spin on it, and I highly recommend that you do that. Push yourself; go past what we just did today and add your own stuff and and use this. And then you can add this to your portfolio website and show this off and show people that you know how to use Excel, which is a fantastic thing to know how to use and show off.

So, with that being said, I hope that this project was helpful. I hope that you learned something along the way. I know I did; um, I was learning things as we were going, and I hope that you didn't mind that I took some detours along the way, um, for your amusement as well as my learning. Uh, so with that being said, thank you so much for joining me. I really appreciate it. I hope you have a good day and [Music] goodbye.

What's going on, everybody? Welcome back to another video. Today we are starting our Tableau tutorial [Music] series. Now, this series is for absolute beginners, so if you have never used Tableau before, you are in the perfect place. I'm going to take you all the way from the very beginning of installing it and just understanding what Tableau is and how you can use it all the way to creating dashboards and sharing it.

Now, personally, I hate those videos that are like 3 hours long, and they just expect you to go through it. Uh, I like to break my videos up in chunks, so if you have ever done my SQL tutorials, you'll know that I like to break things up, so it gives you time to try them out and do them yourself, and then you can move on to the next video. So I'm going to be breaking this up into five separate videos, but in this video, I'm going to show you how to install Tableau for free. I'm going to show you the user interface. We're going to download a data set that you can find on Kaggle, and then we will build our first visualization together. With that being said, let's jump over my screen and we'll get started.

All right, so the very first thing that we need to do is you need to actually download Tableau. So we're not going to be using Tableau; we're going to be using a free version called Tableau Public. It has a lot of the same features, except, of course, it's not—every single feature that regular Tableau has, but it is absolutely perfect for learning it and for using it, and and you can even build—um, you know, dashboards and share those for your portfolio. Um, I'm going to put this link in the description so you can just go and click on that, and and all you have to do is input your email right here. We're going to click download the app, um, and then it should start to download, and then you can save that, and then you're going to open this up. Now I'm going to open it up; I don't know what it's going to do; I already have it downloaded, um, but it should open up and look hopefully like what you're seeing on my screen in just a second. Let's see what it does. Um, I hope you can see this, but it says Tableau Public; um, it says I already have it set up, but you're going to click install and go through all that—all that setup stuff. Uh, so I'm going to exit out of here, but I'm going to go over here and type in Tableau Public, uh, and it's 2021.3. That's the current version that they have out. If you're doing this in the future, they may have, you know, different versions, um, so you should be able to pull this up right here now.

Um, I'm going to go and get our data set that we're going to be using, and I'm going to show you how to get that as well, and then we will actually jump into Tableau and start uh using it. So let's go over here. I'm going to get a data set from Kaggle. I wanted something pretty generic, uh, to show you. In future videos, I'm going to show you some special—or not special, but just different visualizations that you might use, um, and we'll get different data sets for those because, of course, not one data set covers all these other types of visualizations. So, um, we're starting off pretty simple right here. We're going to be getting one called Video Game Sales, um, and we can take a really quick look at it. Um, here are some of the fields that you're going to be having—uh, like Rank, Name, Platform, the Year, Genre, and then some sales data, and this is what it actually looks like. It's called VG Sales, so Video Game Sales; it's then a CSV, and um, you know, here are the fields, and we have our data, and all we are going to do is we're going to download that, and I will save it. Now, when you download it, it's going to be saved into a zip file, so we need to go to our downloads. Uh, let's refresh this. Here's our archive. We need to go in here. You can just copy it and paste—paste it right back into here, um, and just so you know that is a—a CSV, so be aware of that. So what we want to do is we want to come in here now. Since it is a CSV, this is not—we're not going to be using Microsoft Excel; we're going to be using the text file, so we'll come in here; we'll take VG Sales. Now, uh, one thing I want to do before I do that is I'm going to rename mine—VGC Sales1. Um, I've already prepared for this, and so I already have that in there, um, but so I want to make a distinct one for myself. You do not have to do that. So we'll come back here, um, and then we're going to do text file and VG Sales. We're going to open that up, and when it pulls up right here, um, you can bring in other tables, and then you can start to join them together and create those relationships. We are not going to be doing that in this video; we'll do that in a separate one, um, as for, you know, just getting started, you know, we're not going to be using that, but you can see some of these things or some of these fields, and if you notice they—they—they're either ABC or they're a number, so it starts to categorize what this field type is. So is it a string? Is it numeric? It starts to automatically do that, and that's all done within Tableau, and so it just kind of reads it, and that's what it does.

Um, what we're going to do is I'm going to click right down here; it's called Go to Worksheet. Um, the worksheets are where you're going to actually start being able to build your visualizations, your charts, your graphs, all these things, um, and so, you know, we have this in here now, and so we're just going to click right here on Go to Worksheet. As you can see here is VG Sales1. You will not have the underscore one if you did not add that like I did, uh, but right down here you can see all the fields that we just imported from that data set, and they even created one right here for us—they just generated that field, u, based on the file, so it's a count of all the rows really. So what I'm going to do is I'm just going to walk you through—uh, basically what we're looking at, some of the things that we're going to be using today. There will be things that I don't talk about, but I'm going to highlight those in—in—in future videos when we start using those or going over them, um, and so let's just start with the most obvious one. It's way over here; I'm sure you saw it when we—this first came up on the screen because it has all these different charts and visualizations and graphs and—these will become available as you start dragging and dropping our data into this sheet. And so if I go right here, it says for Scatter Plots, try zero or more Dimensions, two to four measures. So what our dimensions are are right here; what our measures are are right down here. And so typically—uh, things like—like you say Genre or Names or or strings like that are going to be these—uh, dimensions, and then a lot of—lot of times the numerical is going to be our—going to be measures.

Next, what I want to show you is right here. So you can take something like Global Sales and you can drag it right here into your rows, and then it takes your rows, and so it automatically created a sum of Global Sales. Now if we take that away and let's say we drag it right here, it's going to give us a column. Now you can also do it right up here; you don't have to—drag it on screen; you can also just add it to the column or the row. That's typically what I do; I—it's just more intuitive to me, um, or you can drop it in this section right here, and it does its best to assign it some type of—some type of visualization. And so that's what it always is trying to do; it is trying to say, okay, this is what you're trying to do; let me try to—to get the best visualization for the data that you're giving me. Now, while we are here, um, it went down here into Marks, and Marks is a very important area; it's where you can add color, size, text, detail, and Tool Tip, and I'm not going to go into what all those are cuz I'm just going to show you. So let's start pulling some fields in here and creating a visualization, and then I'm going to show you how all of that works, including filters as well. So the first thing that we are going to look at is Global Sales, and let's put that in the rows, and then I'm going to take Year and I'm going to make that the column, and this is basically exactly what—I wanted to do. Now, as of right now, it has only the year, and it's looking at Global Sales for everything, but we want to break that out a little bit better. I want to break it out by—let's do Genre, so different genre of games. Now if I add that right here to this column, s it is going to break it up by year and genre. If I add it right here, is going to break it out by the year, of course, but then in each individual row has the different genre. That's not what we want; we want to keep this type of line graph, uh, and what we're going to do is we're going to add it to Marks, and you can't really see it based off of these colors, but they're all different, so we have Action genre, we have the Sports genre, Racing, uh, Role Playing, all these different genres within it. Now we can get rid of that cuz we don't need it anymore, uh, and this is where these—these Marks really come in handy because you can start basically doing what you want with them. So for the Genre, I want to be able to see all these different genres with different colors; to me, that just makes the most sense. So I'm going to put Color right here, and automatically it assigns every single genre its own—own color and gives us this Legend right over here. And so it's really easy to see—well, when you have smaller numbers, it's much easier, but I know that red is Sports, and I can go right here and find red, and that is Sports, so it makes it a lot easier than when it is all the same color blue. So what you can do after that is you can also add things like—a label to it. So if we take Label and we—or we take Genre, put Label, you can click right here, and you can get rid of the labels that you have, and you can see them right down here, or you can also change—the font. So if you want to make it orange or or whatever color, you can do all those same things, and you can also do things like changing where you see these things. So for Action, you're going to see it a ton because for each year Action is—is at the—is on the higher end, and so you're seeing those in those mins and Maxes. You can also do it for a selected area. So if I come in here and I select it, it's then going to show me what those are. So Label is really—really—uh, useful, really helpful. Let me get rid of that really quick. Uh, you can also do it where the lines end. So Line Ends is at the beginning and the end, and you can also take that away or put that back on. So Labels are really important. Labels aren't very helpful when you're doing—at least I don't find that it's super helpful when you're doing things like Genre. So when you're doing your Dimensions, so I'm going to get rid of that, and I'm actually going to bring our Global Sales over here, and let's label that, and right now I think it's labeling the—uh, line ends. We want to do the Min and Max. Now if we do Min and Max on the table, it's just going to give us the Max and the min, which is zero and then 139.0. It's a little bit more useful if we do it for each line. Uh, this at least gives us some context. I probably wouldn't do this in an actual visualization, but to give you some—um, understanding just how it works. So now I know that—um, right over here the min and the max—or the min, sorry, the max for these—for Action and for Sports is right around 138, 139, so it's pretty easy to see, um, and you can again go in here and you can remove the max or remove the mins, whichever one you feel is best. Uh, you'll probably keep the maximums in there for each category. And so this is really quickly becoming—a pretty usable visualization, and that's not the only label that you can add. We still are using Year over here, so we can always drop Year in there as well. We'll create a label, and so now we have—let's see, for this one is a Puzzle genre, so we also have the year that it had the maximum—uh, sales, and so, you know, just some things that you can do. You don't have to add that.

Now let's go up here, and we're going to take a look at filters because filters are really important. You know, if you are making this for a client or you're making this for somebody, you want them to be able to filter down—to very specific information that they want to see. So let's take—the Platform. Lots of different platforms—as you can see, you know, PS4, Xbox—if you're familiar with these. We'll click all of these, um, and we'll click Okay. So now this is an option as a filter, and all we're going to do is we're going to click on this Arrow right here, and we're going to say Show Filter. Now, right now, all of them are selected, so every single one is being taken into account for this visualization, but let's say we come down here and we say, okay, I don't want to see sales for any of these—PS, the original PlayStation, 2, 3, or 4. So I'm going to get rid of this one, this one, this one, and this one, and you could immediately see the—the changes that were happening. So now none of the numbers, none of those sales are being accounted for and—and being added to the sum of Global Sales right here at all. So that is just how a filter—can work, and you can also do that, and you can get rid of all of them, and you can go in and actually just pick very specific sales. So if you only want to see the PlayStation sales, you can go in there and do that as well. So really, really handy. Filters are things that you—at least want to have as an option for most of your—your visualizations; at least that's what I found, especially when you're doing client-facing work. They like to—get in there and mess around and look at different—look at it in different ways. And so that's one that I—I think is—is really useful to—to have.

The very last thing that we want to do is we want to actually add this to a dashboard. Now let's say we add—come right down—down here and we add a new worksheet, and actually we might change one more thing on that last one, but we'll just make a really simple one. Um, we'll just give it Genre and we'll give it Global Sales as the rows, um, and this Nifty button right up here, which is a sorting button. So I'm going to sort like that. I'm going to add the Genre in just as we did. I'll give it different colors. Perfect. Now we have two really quick different visualizations, right? What I want to do is just show you how to combine those because what you are going to do is you're going to actually come in here, and you're going to do New Dashboard. That's what this button is right here. Now when we come in here, the size is extremely small; it's very easy to fix that. All we're going to do is click right here; we're going to go to this range or this dropdown, and we're going to click Automatic. So now it is a much larger size for us to actually drop our visualizations into, uh, and let's put Sheet—Sheet one, and we'll put—let's put it up top. So now it looks a little bit like this—not perfect, but again, if I wanted to make this look a lot better, I definitely would, and then you can go over here, and you can rename these things. You can also do that back when we were in our actual worksheets, but you can also do it here as well and then start—um, you know, customizing it and building it out. That's not what this video is for; that is the last video. We're going to build an entire dashboard; it'll be kind of like a small project. You put that in your portfolio. Um, if you have gotten this far and you want to jump straight into it and you don't want to wait for these other videos to come out or you don't—you just want to jump straight into creating an entire portfolio project, I have an entire portfolio project series that covers SQL, Python, and Tableau. And so go check out that series. I have one video dedicated to Tableau; it's like 45 minutes or an hour long, and it covers a lot of the things that we're going to hear in here as well as a few other things. But I appreciate you checking out this video. In future videos, we're going to be going over things like creating bins, calculated Fields, doing joins, and then creating a final project and putting it all together. So thank you so much for joining me. I really appreciate it. If you like this video, be sure to like and subscribe below, and I will see you in the next [Music] video. [Music]

What's going on, everybody? Welcome back to the Tableau tutorial Series. In this video, we're going to be going over bins and calculated [Music] Fields. All right, so let's jump right into it. The first thing that we're going to look at are bins, and bins are basically just groupings or ranges of numerical values. So we cannot create bins—for Genre, Name, Platform, or anything like that. We have to do something with this sign right here, which means that it is a numeric—so Year or all this sales data or this ranking data. And we're going to use what we worked on in our very first tutorial. And so what we're going to be using to kind of demonstrate how bins work is this Year right down here. So right now we have a range of 1993 all the way up to 2018, and we're going to create some bins to group and create ranges for these years. And it's pretty simple; all we're going to do is I'm going to come right over here to Year and this little dropdown on the side, and

We're going to go down to create and go down to bins now. It's going to say the size of bin, and it's going to give you a recommendation based off of the information that is already provided: the min and the max, the ranges of these values. You know, you don't have to do this, but usually, um, it it does give some good estimation on what you might be considering. If you were thinking, hey, maybe do a bit of like 20, and they're recommending two, think about why they might be doing that. We're going to change ours to five, and you can always change what this field is going to be. I'm just going to give it an old exclamation point just to, um, really spice things up here. So we're going to click okay, and as you can see, it adds it right up here. It is no longer, um, it is no longer a numeric; now it is a categorical. So it now it's this is no longer just uh 1, 2, 3, 4, 5; its ranges, its groups. And we're going to get rid of this year really quick. Actually, let's keep it up there for a second, uh, see what happens. But we're going to bring this up, and we'll get rid of this year. And this is is what kind of it spits out for us now. I did look at the data, um, when I was prepping for this; there are some nulls in the years, um, and so all we're going to do for this is we're just going to go like this, and we're going to exclude the nulls. Probably not something you should be doing, uh, if you're doing this for work, but this is for demonstration purposes, so we can do it ever we want. But as you can see, we now have these ranges. So this range starts at 1990 and it includes 1990 all the way up to 1994, and then it's 1995 to 1999, and so just really quickly we can tell that the years 2000 to 2004 were a huge, huge, huge uh season or group of of years for game sales. So these are the global sales for for these video games, and so it is really helpful; it's very useful. Um, you can do this on a lot of different information. We could do this on the sales data; you can do this on age; you can do it on years like we did, and it can be very, very useful. And so, uh, really quickly, that is how bins work. I would say it's pretty straightforward.

Now this is a perfect time to segue into the next part of the video, which is calculated fields, uh, right over here on this left-hand side. We see that the global sales, which are in millions, goes all the way up to 900 million and created these beautiful bins right down here. But let's look at within these, from 1999 to 2015. Let's see which of these has the highest percentage. Of course, it's going to be this one, but we can do something called a quick table calculation. Uh, we'll create a our own calculation later; I'll show you how to do that, but we're going to do a quick table calculation, and we're going to do the percent of total. And so now we have these bins, and instead of just seeing the total amount of sales that they had, we see the actual percentages based off these year ranges, which is really useful, something that you could absolutely put, uh, in some real work that you do for a client. Now really quick, just to show you something that you can do: if you click control and you drag this over here, you can actually save that calculation. So we can say percentage of global sales, and that actually saves it as, uh, you know, a measure for us. So that was a quick calculation, but let's look how to actually create a calculated field. So if we do this right here, what is going to come up is just the global sales, and you can do a lot of what you would basically do in Excel: multiplication, division, subtraction, a few other things. But we're going to keep it super, super simple today. All I'm going to do is I'm going to take global sales, and I'm going to subtract; I'm going to do an open bracket, and I'm going to say EU sales, and it auto completes for me. I'm going to click okay, and created calculation 2. I'm going to come in here, and I'm just going to say global sales minus EU sales, and let's drag this over. These are different, um, one's percentage, one is in terms of sum, and so I'm just going to bring this in right here. And so now we are comparing against the same thing, and if we look at the global sales, we have probably right around 950 million-ish in this 2000 to 2004 bin, and for global sales minus the EU sales, we're looking at, you know, 650 million. So there is a noticeable difference, and this is just one of the ways that you can use calculated fields to actually just show the difference between two numbers, or you can do more advanced calculations depending on the data that you actually have. So that's it for this video. I hope you learned a little bit more about bins and calculated fields. In the next video, we're going to be looking at a ton of different visualizations and graphs and charts and just exploring what options really are out there for visualizing our data. Thank you guys so much for joining me. I really appreciate it. If you like this video, be sure to like and subscribe below, and I will see you in the next [Music] video.

What's going on everybody? Welcome back to the Tableau tutorial series. In this video, we're going to be looking at lots of different visualizations, including the scatter plot and density [Music] Maps. Now, before we jump into the tutorial, I have some very exciting news. In just two days, on October 7th, I'm going to be partnering with alter X to host a webinar. This webinar is completely for data analysts who are wanting to change careers to become a data analyst. Now, you did hear that right. I will be the host of the event, but but we will be bringing on guests as well, who are industry experts who actually changed careers to become data analysts, much like myself. They'll be sharing their stories of how they actually transitioned careers, along with the tools that they found extremely useful and helpful to make that switch, and they'll be giving lots of advice along the way. So if you are somebody who is wanting to change careers to become a data analyst or just wanting to learn about data analytics, this is an absolute fantastic place to learn a lot more about that. I will leave a link in the description, so be sure to go and sign up for that. Again, I'm going to be there, so so it should be really fun. Without further ado, let's jump onto my screen and start the tutorial. Now we are about to look at a ton of different visualizations, uh, over here you can see just an array of them, but not all of them are ones that I actually think are useful or ones that I would actually recommend using. And so I'm going to take you through some of the ones that I absolutely think are worth learning and using and trying out, uh, and I'm just going to kind of just show you how I might use them, how they might look, how you can navigate them a little bit. Now, before we do that, we do need to go download one data set; it's this Starbucks location worldwide. Yes, we're going to do a little bit of longitude latitude here, and all we have to do is click this downloads button, and it will download. We're going to do that into downloads; we'll save that, uh, yeah, I've already done that, but you know, I'm doing this with you guys; I'm doing it for you. So let's go to our downloads. Now we have have here; we want to come in here; we're going to copy it or, um, you can cut it, and then we're going to paste it here. Yeah, replace it, perfect, and now we have it ready to go. We'll come in here; let's do a new sheet, and I already have it in there, but, uh, I'm just going to show you what I would do: do new data source; we'll do text file; we'll do directory, and we will open it. And let's see what data we have in here before we actually begin, uh, just super quickly: we have the brand, so, um, whatever company has it, and then a bunch of, um, location information: street address, city, the state. This is all in the United States, so that's basically it. And what we are going to do is we're going to go over to this sheet three, and we have this directory 2; that's the one I just pulled in, exact same thing as directory, but so the first VIs visualization that we are going to look at is a bar and line graph. So what we're going to take is the year right here, take these global sales and these NA sales, and we're going to be doing this one right here. So this has a combination of two separate, uh, types of visualizations. So sometimes you just have lines; sometimes you just have these, uh, these bar graphs or the bar charts, and we're combining the two, and it's very nice; I like how this looks. Now, if you notice, if I put this NA sales behind it, now it kind of cuts off. So now this global sales is in front; we're going to, you know, put that back. I just wanted to show you that, uh, right here, there's all some of global sales, some of NA sales. So if we go into this, all we click this drop down, we can change it to a line; um, we can change it basically whatever we want. I just hit ctrl Z to reverse that, but what we can do is we can go in here, and we can change this color, and let's see if we can just make it red. Is that [Music] possible? See what I did? I made it orange; that works for me, um, just something to stick out a little bit more. Choose whatever color you want, and this is a really nice visualization; this is one that I have used in the past. We're looking at global sales versus the NA sales, and so it's very easy to see the distinction between the two and how one was doing a specific year versus how the other one was doing in that same year. So I really like this. If you want to do something, uh, like keeping it consistent, you can do two bars; I don't really like this one as much, um, and you can again you can really change it up; there's lots of different ones that you can do. Again, I prefer the line, but you know, do whatever you think is best. I'm going to change it back because this is not how I want to keep it, but there you go. So that is the first one that we are going to look at. Let's move on to the second one, and we actually will be using our our Starbucks data here. Now, when you bring in data that has, um, any type of map or or, um, address or postal code or things like that or or country, it's typically going to create this latitude and longitude; it's going to generate that. Now what we want to do is bring this longitude right up here and this latitude right there, and if you do the show me right now, it's giving us this, but what we want to do is add what we're looking for. So what will we actually be trying to search for on this map? You can do anything from like a postal code, um, and it will drag us right here. Let's come over to this; this allows us to kind of scroll around a little bit, um, we're going to mess around with this one for just a little bit, and me see if I can; that's nice; that might be too big; let me back up one. So at least in the Continental US, a little bit down here, this these are the postal codes. So right now we're looking at post codes, uh, and there are a lot that you can do with this, um, really color will make almost no difference; it just becomes this mess, so you don't typically want to do something like that, at least not for this. Let's go to size, and if we make it really small, you can kind of see these groupings, these pairings, um, typically of like larger cities or major, major metropolitan areas. And so you can do this, and it's and it's really, really easy. I don't recommend, uh, labeling this; I don't even know if it'll do it; um, it would be an absolute mess to try to label all these postal codes. Well, let's bring this out, and let's bring these state and provinces in. Now, right now we have these little tiny, tiny, uh, dots on here, and I think what we want to do is not increase the size size but over here we want to actually do this and make it a map. So now it's going to fill in all the states. We can, you know, why not, we'll add some color here, um, but we can; it hasn't numbered; I didn't think they were numbered, um, oh, that's interesting; I haven't seen that; I didn't look at that before; I was just found that interesting. But now we can see what, uh, what states Starbucks is in, and as you can see, they're in all 50 states, but it's something interesting to, um, look at, to think about. Now, if we go right up here, we can again choose a different type, and we're going to go to the density. Now, right now it's just doing a density on the, uh, the state; we're going to get rid of that; we're going to bring back postal code; I'm just switching it up on you a little bit, and you can do it as small or as big as you'd like, um, you know, I like to do somewhere in the middle, um, probably right, right about there is fine, um, I don't think it's going to make sense to really add any color here; again, all these postal codes are different, so it's just going to be complete mishmash. But this is kind of how you can use a density map, and you can do this with, uh, countries; you can do this with postal codes; you can do this with any type of kind of like address or location-based data. So that is how you can use a map; again, there's lots of different ways to use a map, and so I'm not going to show you every single way, but in a really brief way, this is how you can use a map to actually visualize your data that does have location, uh, based information in it. So let's go over to sheet three, uh, and this data that we have over here, it just allows for a lot of different types of visualizations. So we're going to use this one, um, and there are lots of other ones that you might see out there, like this one right here, uh, we obviously wouldn't be using this; we might do something like this, change the label, um, and maybe add why have both of these in here, um, let's get rid of this; oops, that's not what I meant; let's actually add that; let's do the sum of global sales, and we'll just make that into a label as well. So what you can do with these and and how you're able to use them and visualize them; again, these are not you'll see these often, but these are not often ones that I would recommend you use; that's very similar to these packed bubbles, um, you can as these global sales in here again add the label; it just, uh, it sometimes is not as straightforward the information that it's trying to tell you; right, you kind of have to search for it a little bit; you kind of have to look around, um, but you can find some good visualizations in here for very specific types of data. And so these are just ones to consider, uh, one that you'll see all the time is, uh, this guy right here, and, uh, let me see if I can expand this a little bit because this is very small, um, let's see; we have the I just want global sales, and let's label that the size; I how do I expand this? Haven't done this in a while; let me just expand this; I don't use pie charts; what is happening? This is an incredibly large pie chart; oh my gosh; I am making this, um, this is becoming a problem; there we go, uh, and what I actually wanted to do was label the, uh, genre as well as I've been doing in all the other ones, and we'll label this. Now, look, whether you are a fan of pie charts or not, you have to understand that people use them; some people just like how they look, and for certain data, it can do well for things that have a lot of different, um, groupings or categories; it usually isn't super great, but it does give you some type of order of things; give you a quick glance, and people use them, right? So let's not pretend like it's like the the the hideous stepchild; all right, people use it; people have it in their dashboards and their visualizations all over, so it's best to just know what they look like, know how to do them, know, um, how to use them best; again, I'm not a super huge, huge fan of it myself; I've used it once or twice, but one to look out for. And again, you can come over to here and use is called a box and a whisker plot, um, it's good for these large, um, distributions; you know, this is like the median, upper, upper, lower, lower; I don't use these a lot, but I know a lot of people who love them; something to just look at and or mess around with it a little bit; it's pretty I think straightforward, and it does give you some good insight into your data if you know how to use it. Now there is one last one that I want to show you; I'm just going to create it on a new sheet; make it easy; uh, we'll do year here; we'll do some of let's do NA sales; why not? And we are going to make this like this. Now it's very similar to a line chart, but when we break it out by the genre and we add some color, you know, it's just a different way to visualize this information; you can, uh, you know, potentially add some stuff in here like some labels if you, uh, want to, depending on how it looks for you, but this is just another way to visualize the data. So wanting to give you guys some options, wanting to give you some things that you might want to look at if you haven't already used these before; four these are ones all every single one that I've showed you are ones that I've at least used once, um, this one I maybe have literally only used once, but the first ones that I showed you, the ones I pointed out as the ones that I really wanted you to know are great visualizations to learn how to use and learn how to make useful for the data that you have. With that being said, that is all that we are looking at in this video; again, I tried to keep it super easy; just wanted to show you some different visualizations, the data that you can use to get those visualizations, and just some other options in case you wanted to get a little bit, uh, spontaneous, a little bit out there, a little bit funky, uh, to show your boss or something like that. Thank you guys so much for watching; I really appreciate it. If you like this video, be sure to like and subscribe below, and I will see you in the next [Music] video.

[Music] What's going on everybody? Welcome back to another video. Today we're looking at joins in [Music] Tableau. Now, before we get into the tutorial, I want to give a huge shout-out to today's sponsor, and that is Udemy. They were having a massive Black Friday sale, and so everything is about 85% off. So if you've been looking at a course, now is the time to buy it. If you are looking at learning and taking an actual full Tableau course, there are fantastic ones on Udemy that I have taken myself. So be sure to go and check out Udemy while they're having this huge sale. I will include a link in the description if you want to check them out. Now let's get into the tutorial. All right, let's get started, and first we're going to start off in Excel. I'm going to kind of walk you through the data that we're working with, and then we're going to put it into Tableau, and I'm going to show you how to do all those joins in Tableau. So the first table that we have is this demographics table. We have employee ID, name of employee, employee age, and employee gender. Now look right here because this will be

Important. Uh, going forward, in the demographics table, we have 10, uh, individuals, and they each have an employee ID. Now, when we go to the job title, we have our employee ID, employee name, and the job title, but this one is missing. Ryan Howard is missing his employee ID. And then the very last one, there are only seven employee IDs and no names, um, and so we're going to use all of that, and I'm going to show you how to actually do the joins into Tableau. Tableau does a really fantastic job of visualizing for you, so it takes a lot of the guesswork out.

Um, I am going to include a link to my joins video in SQL because these two are very closely connected, and and if you understand how the joins work in in SQL, you'll understand how the joins work in Tableau. It's almost the exact same thing. So, with that being said, let's jump over to Tableau. So I'm going to pull this up, going to go right over here, and now we have uh, where where we can connect to our data. And so we're going to click Microsoft Excel. I'm going to scroll down here to Tableau joins file. I'm going to open this up, and I have it open so I can't use it, so let me get rid of that, and let's open it again. Perfect.

So now what we're going to do, and I'm going to show you how to actually open up the joins um in a second, but what you need to understand is when you first come here, Tableau doesn't automatically allow you to to use the joins. They use something called relationships, and there are joins on the back end, but they call it relationships because they are inferring all of these things; they're trying to go in and make that inference for you, so it takes a lot of the work off of you. And most of the time that works, and and you know, you just plug these two things in here like a demographics and the job title, and it is going to, you know, help you build those what they call relationships. And you can click on this and learn how the relationships differ from joins. Again, there's not a huge difference, but it's not as custom customizable, and you can't as easily do left joins or full joins or all these things that we're about to look at.

So, uh, I'm going to take this one off, and what we're going to do to actually be able to look at the joins and and choose what joins we want to use is we're going to do this dropdown; we're going to click open. And so now we are in a place where we can actually create the joins, uh, and again, it's just much more customizable. And so, um, back when I was using regularly, I would use the relationships when it was pretty simple and straightforward, cuz almost they almost always got it right, but uh, you know, the joins, it it just makes more sense in the way it visualizes it for me, so most of the time I'd be using the joins. So let's pull over this job title right here, and it's going to make this connection. Now, before, if you remember just about, you know, 30 seconds ago when it connected them, it was just a line, and and so it gave us the this option down here to kind of edit the relationship, but now it's giving us this visualization. And so let's click on it really quick, and what is going to come up is the different types of joins that you can do. You can do an inner join, a left join, a right join, and a full outer join, and then you can actually choose the different uh, data sources and how you're connecting them.

So again, um, I'm going to walk through a little bit of this, but I think the SQL video that I did on this shows it so well, um, I would highly recommend using that, um, and I recommend learning SQL too, so you know, two birds, one stem. So I'm going to get into each of the joins, how they work, what data is going to be displayed, um, and these visualizations are really going to be helpful, and I think that it's it's just nice that they have it because it's a little reminder, okay, um, you know, this is what this join is, or this is what that join is. So super super simple. So right now we have the demographics table and we have the job title table. And so what it's doing right now, and let's get rid of this, what it's doing right now is it's doing an inner join, and so it's pulling everything that overlaps if it matches on the employee ID and the employee ID. And so right now you only see one through nine, but if you remember in the demographics table we had uh, 10, all the way through 10, so where's that 10th one? Well, the 10th one is not there, and that is because in this job title employee ID it only went up to nine, and then Ryan Howard just didn't have an employee ID in there for whatever reason. So that data is going to be missing.

Now, when you are using actual data sets, very large data sets, which we will use in the next video when we walk through an entire project, um, when you use large data sets, this can be the difference between clean data and very wrong data, and and visualizing it correctly and showing completely wrong numbers. And so you really need to be sure you understand how your data works together when you're doing these joins. So how can we fix this? How can we um, make it to where we can see all of the data? Well, right now we're only making it to where if the employee ID is equal to the employee ID, so we only are going to see through nine, and through nine we're never going to see Ryan. So there are two different types of joins that we could do to make it see it, and then there's something else that we can join on to where we can see that data. The first that we can look at is the right uh, join, and what this does is it's going to take everything that is the same, but also everything from this job title table regardless of if it has a match in the demographics table. So it's pretty, you know, this visualization does it all; it's going to show everything in the right table regardless, and it's only going to show things from this table if there's a match. So let's try this one, and we should see Ryan Howard in the job title table. So let's click on it, and if we scroll down, there's going to be nine, nine, nine, nine, nine, until we get to over here where we now have the data that we had in that actual table, but again, this wasn't a match, and so we weren't able to see that data. So this gives us a way to where we can see all of it, um, all everything from that right table, this job title table. And now we're going to click on the full outer. Now the full outer is going to take everything from both regardless of if there is a match at all. And so right here you're going to see Ryan Howard and Ryan Howard. Now, why are there two different rows for it? Well, because in the demographics table there was an employee ID, so we're seeing the employee ID, Ryan Howard, his age, and his gender, and over here there was no match, right? But in the job title table, again, this one didn't have an employee ID, and so we we are going to be able to see this data, but over here it has no match, and so that's why it's showing us two different rows is because there was no connection; there was no match there. That's what a full outer join is going to do.

Now, just for uh, the purposes of seeing what this one does as well, we have the left and table, um, and now we are able to see the 10 that we didn't see before, um, and it's putting in nulls over here because there's no match. So that's that is um, what we have so far. Now, like I said just a second, going to go, there is a way that we can do this without using the employee IDs. We're allowed to use a different join clause. Now, there is the name of the employee in both of them. This one is called name of employee, and in the job title it's called employee name. They don't have to have the same column name in order to join it; you can do whatever you want. So I'm going to get rid of this one, and now we are only tying it on the employee name, and let's do an inner join, and it should be basically everything, um, except the only piece of data that wasn't filled in, which is that 10 over on the job title table. And so this way was a slightly different, maybe uh, less thought of way, because normally you do it if there's an ID, you go on the IDs, but because we had a lack of data for in in one of the tables, in the job title table, we decided to use a different column to to join on, and now we're able to look at all the data together.

So super quickly, that is an inner join, a left join, a right join, and a full outer join, and it's pretty easily visualized here, and you're able to uh, change what you're joining on right here, but you're also you can do multiple. So if we want to do the employee ID and the employee ID, you can do that as well, and you can keep going as as many as you'd like, um, and right here, or you can change some of these things. Uh, I don't there aren't a lot of use cases for this, um, but you know, you can absolutely do this, um, and mess around with this, as seen. I'm not going to go through it in the tutorial because again, 95 plus percent of the joins you're doing, you're going to want to do it to where this equals this, um, and if you want to get into where it doesn't equal or or all these other things, which is more complicated, I think it's much better to learn that in SQL; that's my personal preference. And so, um, again, all in the SQL tutorial if you want to check that one out. So you're able to join on multiple things. Now let's get rid of that one because we can actually bring in this salary one as well, and what you'll see right down here is that we have our employee ID, and this is all coming from the demographics, so employee ID, name of employer, employee age, employee gender, then right over here we have the job title table, so employee ID, job title, employee name, job title, and then right over here was or is our salary table, and so we have employee ID, salary, and employee salary. So again, this is a way that you can put all of this data into one place, and and just a second we'll go into the worksheet right down here. I'm going to show you kind of how it looks because it looks a little bit different um, than previous tutorials, and so I want to show you how that actually all works together, um, but again, you can create these joins um, as well and do the exact same thing that we just looked at and customize the joins, customize what you're what you're um, uh, joining on, and then you have your finished product. And so right now we have our demographics plus Tableau joins file, and we can rename that if we want. I'm going to call this um, demographics plus joins demo and click enter. And so now that is saved. So so now let's go down to the go to worksheet; we're going to click on that. And so up here on our left side, this may look a little bit different than it normally does um, because it's broken out um, on the measure names and the measure values; it's broken out by the tables that they were joined on. So we can pull in the employee gender now, and we can pull in the employee name now, um, and we can pull in the employee ID again if we want to from the job title table, and we can pull in the employee ID from the salary table; we could do that if we wanted to. It makes no sense uh, uh, for actually creating any visualizations, but you know, you can do that. And so you probably you wouldn't be able to do that if you hadn't joined these together. And so down here in the measure values, the values that we have are from the demographics table and the salary table. All of the um, all of the stuff from the employee title, none of those things were um, values, and so we can't use; there are going to be no values down here. And so really quick, let's take the name of the employee, let's take their salary, sure why not, um, let's order that, let's take the employee salary, we'll do color, and uh, expand this out a little bit, maybe one more time, oops, just like that, and there you go.

So that is how you do joins in Tableau, and I think Tableau does a really fantastic job of making it pretty simple. They have the different types of joins when you click on that that join button, and it shows you the inner and the left and the right and the full outer, and they make it pretty simple, um, and and and it's just really useful to be able to see that while you're creating it and see the output below like we just did a second ago. It it just makes it so simple to create those joins and then just keep going because you already know what your output is going to be, and you can kind of mess around with it and make sure you're getting the data that you need. In the very next video, we're going to be doing an entire project in Tableau; we're going to be using a lot more data, and it's going to be a a complete project that you can add to your portfolio, and it's going to be a really good time. So I hope that you joined me for that one. I appreciate your time. I hope that this was helpful. Thank you guys so much for watching. I really appreciate it. If you like this video, be sure to like and subscribe below, and I'll see you in the next [Music] video.

What's going on everybody? Welcome back to the Tableau tutorial series. This is our very last video in the series, and today we'll be doing an entire [Music] project. Now, if you're watching this video, I hope that you watch the other four videos in this series, just so you can get the basics down; you kind of know what you're doing. Uh, this won't be a crazy hard project; this is a beginner tutorial series, so I'm trying to make this super easy so you can follow along. Nothing super complicated, I promise. And if you were wanting to go above and beyond and just make a lot of different dashboards or try a lot of different things, there's a ton of data in here, and so I'll show you some of the things that I would do, you know, as we go through it, of the things that I would be looking at and some of the different visualizations that I might do as well. But again, in this video, we're going to be sticking to a lot of the basics, but I'll switch over my screen in just a second. I will show you the final product, and then we will actually walk through step by step of how to do the entire dashboard, and at the end you should have a completed project that you can add to your portfolio or, you know, just share on LinkedIn if you want to do that as well. With that being said, let's jump over to my screen and let's get started.

All right, so let's get me off screen and show you what we're going to be working on today. This is the final dashboard that we're actually going to be building, and so it's nothing crazy, right? I'm sure you have seen all of these things before, um, and I'm just going to help you kind of build it out, show you what to do, the buttons to click, um, and it's really going to be a simple walkthrough. By the end of this, you should be able to do all these things very easily, and I highly encourage looking at at the data and looking at these visualizations and seeing what else you can do with it. There's a lot of different colors, a lot of different visualizations um, that you can do with this data. I'm just showing you this today, and so the more you go out there and the more you do this on your own and you mess around with stuff and and choose different things and see how it all works, the better you're going to get, and so I highly highly encourage doing that. Uh, so what we are going to be working with today is an Airbnb data set. I'm going to show you that in just a second, and I'm going to show you the data, and we're going to just jump right into it.

All right, so this is the data set that we are going to be using. This is the Seattle Airbnb open data set, and let's scroll down really quick, um, there's three different CSVs in here, and so this is some of the data that we're going to be working with, um, some data on listings and some pricing, and then there's the actual listing that shows um, the actual street address, the location, the price, the bedrooms, all of these good stuff stuff, and then there's a reviews, um, and it has, you know, some comments and, you know, talks about some of the reviews. So this is what we're going to be working with, but you don't have to go in here and download it. I have already combined all these CSVs into one; I've put it on the GitHub, so I'll have a link below so you can just click on that, and you don't have to do all the stuff that I did to get this set up. Um, just so you know, this is from 2016, so this data set is a little bit old. If you want to, you can come right here, and I will leave this link as well, and you can get the data set from, you know, what is this, a couple weeks ago, uh, this is they they are continuing to update this; this is always updated, and so you can go ahead and download these, but some of these are the CSV Dogz, um, so you may need to like convert it. I don't want to go through that process um, on, you know, in the video, and so I am just going to go with what is literally in Kaggle, um, and use that, but if you want want to have an updated one for your project, I just advise you to go in here and grab it yourself, and that should be perfectly good. So go ahead and download the data set from the GitHub, and we should be good to go.

So this is the Excel that I was just talking about; this has all of our CSVs in one place. This is, you know, an Excel workbook, so in this reviews, actually, let's start with the listings because that's kind of where it all stems from, uh, we have our listing, and the DAT or the data in here is um, you you know, really extensive; there's a lot of data in here. So let's get over really quick, um, the listing refers to the actual home that they're renting out, the Airbnb, so it shows their location, um, and there's a lot more location information over here. I'm getting into it in in just a second. So there's the neighborhood, the city, state, um, zip code, all stuff that, you know, may be useful. There's a latitude and longitude; it shows what type of property it is, so that's really really good, um, right over here it has, you know, how many bathrooms, bedrooms, and beds, um, you know, sometimes if it's a five-bedroom house, it has seven beds, so that's why there's those two different um, fields. I don't know if you're familiar with Airbnb and and you know what they have on there, but just something to note, uh, they have the price; this is the price per day, this is a weekly price, a monthly price, and if there's a deposit needed, uh, and then a cleaning fee as well. So a bunch of financial data that's, you know, super useful; we go into it a little bit, but there's so much you can do with that, um, you know, if you want to dig into that. And that's kind of it; the rest of it's pretty uh, pretty useless, um, and there's a lot; so there's so much data in here, almost, you know, more than half by far is nothing you would put in any type of visualization, um, and this is pretty common; you're not going to get data every column where you're going to be able to use

It's a lot of times; it's just a lot of useless junk. And so you have to know what you're looking for and know, uh, you know, what's actually useful. So that's the listing. Then we have reviews. Now what's really a little bit confusing in here, and something that you just need to kind of understand about the data, um, and something that if you're, if you get a data analyst job, you need to understand your data because it's very easy to come in here and say, okay, there's an ID ID field and here's an ID field, so that means that those are the same. Well, not in this case. Um, this ID field is actually the review reviews ID, not the reviewer ID that refers to like the person. This is the reviews ID. This listing ID is the actual ID right there. So really important to note. Um, and then the L and so then they just have their comment there, what they left as a review.

And then on the calendar, um, I don't know why I'm scrolled down, uh, we have this listing idea again. So again, that listing ID is equal to the ID in this listing table, and we have a date and a price. So this refers to a specific location, and on this day they got $85 for it; somebody rented it out. Um, and so then there's these like T's and F's. Um, let's try to find a blank one. Really quick, here's a blank one. So there's these T's and F's. Uh, the T means that it was taken; the F means that it's vacant. I don't know exactly what it means, uh, what a T F means, but that we can deduce that much from this. And so you can see when and how much this person was making or this homeade uh in that time. So really, really good data in here; there's a lot to work with. Um, and and so we're just going to be kind of, I'll give you a little bit of a use case for it in a second, and then we're going to start trying to answer some of those, the building out some of the visualizations for that use case. Uh, again, you could have 20 different use cases for this data or more, um, honestly, for this data where you can build out different dashboards and different reports literally with just this data, but you know, we're doing a pretty general broad project, and so it's hard to answer all of them. So let's jump over to Tableau; we're going to get started on this, and we are going to build out everything. All right, so let's come right here. Uh, this is a Microsoft Excel; we'll open that up, do this one, we will open it and give it just a second. It says it's executing the query; it's pulling the data in. All right, so we have our calendar, our listing, and our reviews; those are the different tabs at the bottom. We're going to start with the listing; this is the, the kind of the main one has, um, you know, the there's, I didn't show you, but there's about 3,600 locations that they had in there. Uh, let's just have it update automatically. I don't know why we need to click on that, but um, so we have this list listings, we have our calendar and our reviews. What we're going to do is going to come in here, and we're going to open it as we did in our very last video, uh, for the joins. So now that we've opened it, we can kind of go in here, and we can do the joins as, um, as needed. And so let's go over here, and we're going to, uh, let's start with calendar, put it right there. That was super slow; I apologize. All right, let's wait for it to get the data, start setting everything up. Did not think it would take this long; I apologize. No, take your time. So let's click on here, and right now it has the, uh, the join based on the price, which obviously is not going to work. Um, and if you remember, there is no ID in this calendar; it's just, just the listing ID. Um, we can actually look right here; there's just the listing ID. So we're actually going to put listing ID is equal to ID, and right down here we can see that we have a lot of, of, well, you can't see it, um, but we show that there is a lot of data. Um, and so we know that that is correct; we know that that is now pulling in data correctly because it's showing up down here. So that's a good thing. Now in this listings, there, there are about 3600, um, about 3600 listings, and so that all the data that's in listings is going to be in there, but on the calendar, because we converted from a CSV to an Excel workbook, it isn't able to store as much information, so some of the ones in calendar may have gotten cut off. So we can just keep at this inner join because we know that if it's in listings, it is going to be in calendar. We know that it, if it, um, there may be some in calendar that aren't in listings. So if we really, um, you know, if we really, really wanted to, we could do a full outer or something like that. I, I haven't really thought through this as I'm talking through it in my head, but we know that, uh, everything that's in listing is going to be in calendar, and so you know, we don't really need to do anything other than an inner join. And we can also pull in these reviews, and it's going to do the same thing as before where just kind of pulling in the data, and it defaults to ID equals ID. Now we know that that is not correct, um, because the ID in here is referring to the review ID. We need to go to the listings ID. So we need the ID be able to, you know, be part of that listings ID. If we do the ID, it goes down to 2,555 rows. If we do how it's supposed, and because that's just, you know, it's random luck; there happen to be some numbers that are in both fields, um, that tie together. If we do the correct one where we hit the listing ID, it bumps it up to I think 2,373,000, oh, maybe more than that, uh, 23 million rows. Right, a lot, lot, lot more. And so it's super important to get these joins right, to tie them together on the right fields. If you just do it based off what Tableau tells you, because it has that automated, um, you know, it goes into these fields and says, okay, these are the same exact column name, so they're most likely going to be what you're looking for. Well, it was incorrect in this point, so it's really important to check those things and make sure you're pulling in the right data. Again, we're going to keep it that inner join. Um, you know, if you wanted to, you know, try to see if there's any other data that correlate, we're keeping it simple today, but sometimes you need to join on multiple things, uh, so just a, you know, a tip. So let's get out of here, um, and we are good to go. So this is our listings plus Tableau full project; that's what we'll, that's what we'll be working with, um, and we, we were able to tie all three of these, um, you know, as you call them tables or sheets or whatever you want to call them, we were able to tie them together. So let's go over here to our first worksheet, uh, let's see. All right, so this says Tableau public only works with less than 15 million rows of data; we have 23 million rows of data; that is, uh, that's a problem. Um, and when I did this before, it didn't do that, so I, you know, we're going to work through this together. So this is date reviews; I believe this is date for, um, this is date for the calendar, which is going to be a lot of rows of data, and so I'm sure that's part of it. Let's see, let's do years; we only want 2016. Oops, we only want 2016. Let's do, okay, let's see what that does. Let's see if that gets us under what we need. Um, we only want 2016 data anyways, so if it's in 2017, we were going to take it out, um, anyway. So we'll see if that gets us underneath. I have absolutely, if this T ends up taking like 20 minutes, I will just cut it, and you know, you won't have to wait as long as I'm waiting. So let's see how long it takes. All right, so it took about 20 minutes, and it did absolutely nothing. Um, one thing I do know is that we don't actually use this review tables at all, um, just for demonstration purposes. So we're going to remove that, and let's see if that helps us in any way. If it does, we're just going to keep it as is. Um, you know, the reviews table is really just for demonstrating how to do the joint, but we weren't actually using any of the data for any of the visualizations, although you could, again, I'm going to see how long this takes, uh, and I'll cut ahead. All right, so that worked, uh, perfectly. It apparently took out all the data that we needed, all the rows that we needed to get under that level. Again, I was just doing that to show you the, that, that joins how you needed to change the columns to make sure that it joined properly. We don't actually use for any of the visualization, so their end product is going to be totally fine. I don't know why, uh, this didn't happen to me when I, when I created this whole thing already, um, so just going to move forward because, uh, I make mistakes, so, uh, let's keep moving. The first one that we are going to make is that, uh, is that colorful one; I'll probably pop it up on screen so you can see it, uh, well, if I remember, I'm going to pop it up on screen. Um, it's the colorful one; it's the price by ZIP code. So we're going to be looking at these zip codes and kind of see, um, you know, how expensive is each zip code. Um, and before we actually start, I just remembered I want to talk to you about the use case for this data. I want to imagine you to imagine that you're working for somebody; they're like, hey, where, you know, I want to start an Airbnb business; I want to know where I should go, where should I buy up buy a home, put it up on Airbnb and start renting it out; where's the best place? You know, what are some of the fact, fact that I should be looking at? Uh, and so that's kind of what our use case is. So we're going to some of the things that he cares about are things like bedrooms, um, location, which is really important, and how much price he's actually going to get, how much money can he charge. And so he's trying to optimize that to make sure that whatever rental he gets, he can make a the most profit from instead of choosing something that, you know, he thinks would work, but you know, in the end, he's actually not making that much money. So those things are important. So that's our use case; we're trying to help this guy out, help him find a really good Airbnb. Um, so let's take a look at these zip codes real quick. We have, uh, quite a few of them, and there's one that's null. Uh, we'll exclude that, or if, if it doesn't have a zip code, we'll just exclude those because they're not going to show up on the these visualizations anyways. Um, and so we want to look at the price, so we just want to find, uh, the price, which should actually be down here and not the sum, uh, no, we want to look at the average price, and let's order that. This is great. Um, so this is the most expensive one, uh, ZIP code 98134 at $26, uh, per for the average price, uh, but let's give that some color really quick. Let's, where's the ZIP code? It's up here, so let's take that zip code; we're going to put it right over here; we're going to do color, and it's going to give it some, uh, assorted colors. Now these colors are going to, um, when we do the map in just a little bit, these colors will, um, match what we're doing in there, and so you know, I, I like to try to color coordinate things. Um, we're not doing going too crazy with the colors today, so this is our very first visualization; congratulations; it is, uh, it is complete. So, uh, we can label this one, and we can just do price by zip code, and I'll make that bold. I don't know, I usually like it bold. We'll apply, we'll do like that, and boom, first one is done. Uh, and this is our starting place to say, uh, Hey person who's looking to buy this Airbnb, here are the zip codes where they are able to charge the most, um, for, for their Airbnb. So let's go over to the second sheet, and we are going to be doing the map. And so, um, map is pretty easy, but it, it's pretty easy once you actually get the data that you need, although there's a lot of different data that you can use for the actual U map right here; you need something that shows, um, the location, and there's a lot of things that show location in here. In fact, they already, um, provide a latitude and longitude, and then at the bottom they generated a latitude and longitude from, from some different, um, fields, and then there's just a bunch of different, um, State; there's, um, States; there's zip codes; there are, uh, I think another one, I yeah, like country; there's a lot of location data in here. So which one do we want to use? We want to stay consistent; we don't want to deviate from that and start using different, um, L long longitude and latitudinal, uh, coordinates because that could throw off our, our results completely. We want to stay consistent with what we're using, so we actually want to use this ZIP code, but when we pull it up here, it's going to give us, uh, basically the same, um, you know, it's going to show these zip codes, but we were going to, right over here, we're going to click on this one, and now it's going to separate them out. So now we have all of these, um, you know, kind of separated out. What you might get when you first do this, um, is it might look like this; you may have to zoom in. Um, I know that that happened to me the other time. Excuse me, go to here; that's what happened to me, uh, just when I first did it. So, uh, know that that may happen, and we want to change the colors the exact same way that we did them before. So we're just going over here; we're doing color, and these colors do, um, they do should match up with the, um, with the other ones. Let me, um, exclude this; let me see if it does. 98134, that's the blue, and right over here 98134, that's a blue. I, I, I believe, believe they are going to be the same. Yep. And so just scrolling back, if you look at the ZIP code on the far right, uh, they are the same. So if you're looking like this section right over here, I, I'm just wanting to make sure I'm not going crazy, uh, before I get into this and realize I'm not correct at all. So, uh, now what we want is, you know, this doesn't really give us any information. If I was just to glance at this map, I would have no idea what you're trying to show me, um, any information off this. So we want to show some actual information. So first thing that we're going to do is we're going to actually add the label to this so that you can see it, you know, when you're going over here and you see, okay, here's this, um, zip code, um, in the dashboard when we create it, you can click on this, but if you just want to do it visually without having to click anywhere, you'll be able to see, okay, 98134, that's right here. So this location right here is, you know, able to charge a lot of money; it's probably a really nice neighborhood. So, um, and we can back that up by putting the average price. So these, these two visualizations are really, they really go hand in hand. We're going to add, oops, not the sum, this one needs to be the average. So you go to this measure, the sum, go to average, and there you go, and these should match. So this should be 206.125, 206.000. So this all matches, um, and we can, we can actually change that size a little bit if you want to actually get it in, um, get it within each of these things, you know, adjust it as you see fits. I think that's fine right there, um, no need to mess with it anymore. All right, so let me see; I think that is everything for this one. I don't know if I want to add anything else, uh, no, I'm going to keep it how it is. So that is our second visualization. Again, these ones are directly, uh, correlated, and, and you know, this, there's just different ways to visualize it. This one you can see actually on the map where it is and the average price; this one you can see from highest to lowest. So again, you know, sometimes when you're doing these visualizations, you're going to have these accompanying, um, uh, these accompanying visualizations in your dashboard; that's very normal. So let's move over to the third one, and for this third one, um, you know, something that our guy was looking at is he's like, okay, well, you know, I'm thinking about listing it on Airbnb, but I also want to live in it, so I want to know the best times to actually, um, you know, put it on the market for people to be able to use. And so I was like, okay, man, no problem, uh, let's, let's take a look at when, when are people spending the most money in airbnbs, and we actually had that calendar, um, if you remember, let's look, let's see this calendar. So we have this available, the date, the listing, all of that stuff, um, and let's look at the date in here, uh, and we obviously don't want it like this; we want it to be more, uh, more of a time series, and we're going to do be doing that based off of, uh, the price for the calendar. So let's go see if we can find that really quick. Okay, here's the price; where is that calendar one? Let me see. Okay, there's the calendar. Oh, here, I totally forgot where that was supposed to be. Oh, that looks terrible. Okay, um, let's see, let's, let's start working on this because this needs some work obviously. Uh, this is the worst visualization I have ever seen. Um, so we need to work on this a little bit. What we need to do is we need to change, oh, whoops, we need to change some the way that these dates are, are seen. So right here is a, these are two separate things. So if I go right here and I do by quarter, it's just going to change the quarters here, right? That's, that isn't really helpful. We actually want to keep the year here; what we want to do it is by year; we want to separate it by year, um, but we want to separate it. Let's just do, I don't know, let's try week and see what it looks like. Okay, this is great; this is, this is what we're looking at. Again, um, if we went back and changed this like quarter, it, uh, changed it quarter, and then changed it to week, it would show the quarters, but it wouldn't show everything, right? This isn't all the data that we need. And so, you know, you really need to make sure that you're doing this correct. I, by default, it's almost always year, but if you're looking at it via quarter, so like, let's say somebody comes in, you say, hey, what quarters? I want to break these out by quarters, um, and not year-over-year; that's how you would do this, but in the year, we want to break it out by, uh, the week, and you see this huge drop off, um, at the end. Well, that is actually because the data doesn't go past that; there's just like one day of data or one, one, um, week of data in here with actual, um, with January of 2017 data, so it just drops off because this is an, this is the sum, so it only adds up to like, um, 591,000 compared to like the 2 million. So we want to get rid of that, um, and how do we do that? Uh, let's see, I think it's filter; how's it format? No, it's not format; what am I thinking? Bear with me, uh, let's a filter. Well, I was looking for it; I just couldn't find...

What's going on everybody? Welcome back to another video. Today, we're going to be starting our Power BI tutorial series. Now, I am super excited to start this series with you guys. We are going to be breaking this up into about six or seven videos. I don't really like those super long videos where it's like four hours long. I like breaking mine up into chunks, so that's what we're going to do. This is the beginner series, and so we're going to start with the very basics and we're just going to work our way up. I'm going to walk you through every single step of the way. It'll be very easy to follow. Everything will be provided for you, so that all you have to do is really follow along. By the end of it, you should know Power BI a lot better; you should have a lot more comfort using it.

Now, before we actually jump onto my screen, I want to give a huge shout out to the sponsor of this video, and that is Udemy. You guys know that I absolutely love Udemy. I've been using them for years, and that is no exception when it comes to Power BI. I have taken some of the best Power BI courses ever on Udemy, so I highly recommend you checking out the ones that I have in the description. These are ones that I actually took and I loved the most. So if you're looking for a full Power BI course, I highly recommend checking out Udemy. Thank you so much again to our sponsor, and now without further ado, let's jump onto my screen and get started with the tutorial.

All right, so the first thing I'm going to do is download Power BI Desktop. I will leave this link in the description so you can just click on it, go to it, and download it. We're going to click this "Download free" button, and once we click it, you can go to the Microsoft store. I already have it downloaded, so when you see it, it'll already say "Downloaded," but for you, you can go in here, you can click "Download," and it will download it for you. I'm on Microsoft, but it may look a little bit different for you if you're on a different system. But once that is done, we are going to open up Power BI. So let's go right down here to our search, let's go to Power BI, and it is going to open up for us.

All right, so right away, this is what it's going to look like when you open it, and we're going to go right over here to "Get data," and let's click on that. It's going to open up this window, and it's going to give us a lot of different options for where we can get data from. Now, some of these are free, and some you need to upgrade for, but just taking a quick glance through here, you have a ton of options. There's databases, there's blob storages, there's post create SQL or different SQL databases, there's Google Analytics; there's a lot of places, and you can go through the process to connect to that data, and you can pull that data in from those data sources. Now, for what we are doing, we're just going to be using an Excel. I'm going to leave the Excel that I'm going to be using in the description; you can go and download it and walk through this with me. So what we're going to do is click on "Excel workbook," and we're going to click "Connect." So we're going to...

it uh let's bring it back to the 31st. Let's see if that fixes what we need. Perfect. Uh, that's all you had to do. Um, and the reason that this is helpful and often times you'd have several years worth of data in here, um, and then you could have, you could do even do something like this, um, like this one where it has multiple lines. The reason that this is helpful is because if I'm telling my friend—let's, I mean, just I'm going to say it's a friend or business partner, whatever you whatever you want to use this use case for—I'm gonna tell him, "Hey, the beginning of January all the way until like, you know, even February, it's like really low; it's half, so there's not a lot of people traveling because everyone travels when at the end of the year, so in November, December for the holidays to visit family, um, and then in the summer for vacations." I would tell him just based off this one thing, I would say, "Hey, over the summer and then at the end of the year and during the holidays, that's when I would be renting out your Airbnb." Okay, so just this one very simple visualization can help him understand the best times um to do that. That may be an intuitive—you may have already known that—but you can prove it with the data, which is always really helpful. Um, and let's see, is there anything else that we need to do with this? Uh, I'm just going to label it, and I'm going to say, um, "Revenue for year." Let's do bold; do apply. There we go. Do I label this last one? I didn't. Let's label that last [Music] one, and we'll do "Price per zip code." "Price per zip code," we'll just keep it at that, keep it simple. Um, and let's do that. All right, I believe we have two more, so we have done, um, we've done three of them. Um, we got the zip codes, we've got the, um, you know, the time of the year. Now, something else that he was wanting to know is, um, you know, just how things affect it. And something that's going to affect the price of the actual Airbnb is going to be the amount of bedrooms. So the the larger the house, the more bedrooms, the more it's going to cost typically. So we can take a look at that. Let's pull in these bedrooms, um, and that will be our columns. Uh, no, it won't. What we need to do, um, and so I I knew this was going to happen; I just forgot it until right, uh, until right now. What we this right now is actually a, um, it's a a value, right? So it's a number, and that's totally, um, reasonable because if we go right here, we do "count distinct," that's because there's only seven values, right? It goes there's zero bedrooms, 1, 2, 3, 4, 5, 5, 6, 7, all the way up to seven bedrooms. Right now, it has it as a numerical value. We want to, um, change that to create it as, um, these measure names, not a value. So we're going to, um, we're going to remove this. We're going to go right down here; we're going to click this drop down, and we're going to say "Convert to Dimension." And so now we're going to add it as a dimension. So there, that looks, um, much more normal. Really quick, I'm going to I'm going to keep these in here for a second, but we're going to get rid of these nulls and zeros because if a home has zero bedrooms, that's a problem, um, and so we want to look at the price again. Let's go down here in the listings; it should be the price. Now, this is the price for the location per day. Um, if you want to look at monthly or or you know, stuff like that, they have that data, um, but we're just going to do the price, the average price, not the sum, although this is is helpful. So just really quick before we change it, this is going to show you which ones make the which ones are bringing in the most money. It also may show you which ones are the most common. Those are all different visualizations that we can do, but the one that brings in the most money, uh, that brought in 63 or that has $63 million worth of, um, worth of listings, so they all add up. Those one bedrooms are doing phenomenal. Half of that are two bedrooms at 30 million, three bedrooms at 18 million, and so on and so forth. So there's a ton of one-bedroom ones. We may even keep, we could even keep that in there, um, you know, if we wanted to, um, and then we do something similar later, but you can keep something like this in there. What we will do really quick though is we're going to do the same thing that we've been doing is keeping average, um, and we are going to get rid of this, 'cause if it doesn't have the bedrooms, you know, that's not helpful to us, and if it has zero bedrooms, that's that's genuinely a problem. I will not be renting an Airbnb with my family, uh, that has zero bedrooms in it. So now we have this, and it would be really helpful to be able to see that in the visualization. I mean, it's just kind of hard to see it as is. I mean, it just does not hurt to add that right here, do a label. Why is it angled like that? Maybe I just need to move it out more. That looks much better. Um, that's the average price. That cannot be right. That's the sum; that's why. So let's go over here; let's make that average as well. Much better. Because, uh, if the price was $3 million for a three-bedroom, I would not be going there. So this is really, really useful information for our friend, right? If, um, he wants to start, you know, get into those one that one-bedroom area, you know, you're not going to be making a lot of money. It may be low cost up front, but he's not going to be making a lot of money. It significantly goes up when you reach these five and six-bedroom homes, which makes sense. I mean, if it has five or six bedrooms in it, it's probably a really large, really nice home, and you can charge a lot more money. And our friend is, uh, extremely wealthy; he can buy whatever he wants, and so he may be looking at these, um, larger, on seeing that there's a much higher return, um, on his investment the higher and the more bedrooms he goes. So we're going to keep it just as it is, um, and let me see, is there's anything else that we want to do with this? No, we're going to keep it just like this. Uh, and the last one is by far the easiest, and we actually just discussed it a little bit. We want to know, you know, what's his competition look like? So, um, for those for the bedrooms specifically, so let's go back up to the bedrooms; we want that one to be right here in our rows, so we show, um, these, and then we just want a count of, um, how many listings there are. So we can do that via the listings ID. So here's our listings; each ID represents one location or one home. So we're going to do that right here. Uh, that looks absolutely terrible. That looks terrible. What am I doing wrong here? Um, let me see. Uh, one thing we need to do is we want to get rid of these nulls and zeros. Do that really quick. Um, and then we don't want to do just the ID because I I'm realizing now, uh, what I'm doing. I need to convert this to a numeric so we can do a count on it. So let's, um, oops, let me see what what is happening. This is terrible. All right, let's put this back. Let's make, let me see if I can just, um, do an attribute. Let's do the [Music] count, and let's do text. Um, no, it needs to be a distinct count because that's that's basically like, um, a count of the numbers themselves, not each individual ID. Okay, it took figuring out. I'm going to keep that in there because you guys need to see, uh, a lot of you guys like seeing when I make mistakes, so you know, makes it feel like when you make mistakes, it's okay. Um, and I'm all about that, so I'm leaving that in there. You guys can see me fail a little bit. Um, I just forgot how to do that for a second. And this is exactly what we're looking for, right? We want, we now it showed us in that visualization that we were looking at earlier before we, um, switched it to the average price. This is showing us that there are for one bedrooms, there's 1,800 one bedroom, two that 483, three that have 206, four that have 55, only five that have 20, and six that have five. So the more you go up, the less and less it is, or the less and less competition there's going to be. Now, is there a lot of demand for four-bedroom, five-bedroom, six-bedroom? That's for our friend to figure out. Um, well, maybe we'll help them out with that later, um, in the with the data. You know, we could look at the reviews that we had. There's so much data in here, and we could absolutely figure that out. But for what it's worth, giving him this initial stuff, and he'll have follow-up questions for us later. That's how it always works; I promise. Um, so now we're good with this one. Let's label this one. Did I label the last one? I will go back and look. Distinct, I I'm going to butcher this one. I'm going to do a distinct count of of bedroom listings. I don't that may not make sense at all, but we're keeping it, so we're going to do "bedroom," apply. Okay, let me see if I added the label on this one. I didn't. Let me do that real quick. We do "Average price per bedroom." Again, I'm oops, you didn't see that. I'm just going with whatever is coming to my head. This probably wouldn't be what I would keep if I this or like an actual project, but it works for now. So we have our five visualizations: 1, 2, 3, 4, and 5. And let's create our dashboard. That's going to be this button right here. So we're going to click that. We are going to, uh, go right here, and we're going to say "Automatic" because we want to use this entire area. And so now we're just going to start, um, you know, pulling them over, and I'm just going to start from the very first one and go to the very last one, keep it really simple. So this very first one, we'll pull it over; it, you know, it's going to take up the entire space until you start adding all the other ones. We'll include this one right here, um, and well, let's leave it as it is. You know, we'll adjust it once it gets to its final place. Now we have number three. We'll add this one on this side. It looks terrible right now, but give it a second. Uh, then we have number four. We're going to add that across the top. Okay, it's already starting to look a little better, and, um, maybe I I you don't have to keep this in here, um, but you definitely can. Uh, let's start to adjust things a little bit. Oops. Okay, let's see if I can zoom in one more. Nope. I'm going to do it just like that, actually. Let me [Music] see if I can make it even just a little bit closer. Perfect. Uh, that's the the best you're going to get. Um, if you didn't see, I use this, um, magnifying, and then I could click on the area that I wanted to see. So we're going to keep that just like that. We're going to move this over because that is, um, definitely not as important, um, and then we're going to move this way over as well. So keep it just like that. Again, this is something where if you want to, you can click on this, um, it didn't I don't know why, uh, I can't remember how to get those connected, but it's you definitely can, um, but okay, I was just clicking on the wrong one; that's why. That is why. But you can click over here, and you you know, it'll filter, um, based on. So if I go to this one, oops [Music] dang. Oh, jeez, what am I doing? Oh, this is a travesty. Okay, let's try to get this back. All right, I'm not touching it, guys. You get the gist; you can mess around with it yourself. I'm not messing this up. Okay, so the next thing we need to add is the very last one. That's going to go right up here, and then we're just going to kind of move it off to the side. And let's see, going to add, yeah, have this caption. Um, if you've never seen something like this before, um, and I actually want to make this bigger as well. Oh, jeez, give me a second. It's it's kind of lagging a little [Music] bit. And make this a little bit taller. Maybe I don't want it as wide, but I definitely want a little [Music] taller. Give it a second. Yeah, let me scooch this [Music] back just like that. That's fine. Uh, we can keep it like that. In my original one, I didn't have this, um, um, you can get rid of this if you want, you know, you can, um, you know, just exit out right here if you want to do that. But there you have it. Uh, this is the entire thing. So we started from the very start, um, we started with this one, then this one, uh, did some, um, and this is, you know, all the zip all of our zip code work. Then we took a look at the calendar where we looked at the price and did some time series visualization, and then we're looking at the bedrooms and and the count of bedrooms. And so this should be really helpful for a friend. It should be an initial dashboard to get him going. And once he sees us, he's going to have a million other questions, and he's going to want another dashboard for different data that's in there. He's going to ask about, okay, well, what if I want to do it weekly, or you know, I want to rent it out for the month, or you know, how many, um, reviews are people, five-star reviews are people giving on, you know, one-bedroom, two-bedroom, three-bedroom? These are all things that, you know, he may ask, and then we'd have to build out. In the real world, this is what happens all the time. You know, they make a request, and then they're like, "Oh, this is great, but I also want this." So, um, you know, your friend is is going to be right in line with just about everyone else, um, that has ever gotten a dashboard, uh, for work or for personal use. With that being said, this is it. Um, we have done the entire thing. Now, if you want to share this, it is super, super easy to share, um, and I'm going to try to remember how to share it. Uh, so we're going to do "Save to," tap "Public As," and we're going to do this, and we're going to make it, um, let's do "Airbnb." Is it like is it a capital B? Is it like that? No, that doesn't look right. "Airbnb," we'll do "Full project," and we'll save. And that is being created right now, um, and I will save this, so if you guys want to go look at this, you can, um, and I'll provide a link in the description as well for that and see if yours looks, um, similar to mine or better than mine. Give it a second. CU, it's thinking. All right, so here it is. So here's our final our final project, um, and if you followed step by step, then you should get this exact or very, very similar to this one. Again, I encourage you to, if you want to have the up-to-date data, to go to that, um, link in the description that has, um, the the most recent data, and they update that I believe monthly, so you can go there, get the most recent data, and then you can do stuff, and you can create a beautiful project just like this, um, but with the, you know, the most recent data. Again, I use the Kaggle data just so you guys can remember, and I encourage you to look at the different data points that are in the Excel. There is so much in there, and you can use, uh, honestly, like there's probably 30 or 40 other fields that you could be using in there that we never even touched, um, but for this project, we're keeping it pretty simple. And so so go do that, make completely unique dashboards and and visualizations and create projects and add it to your portfolios so that you can create, uh, a fantastic portfolio website and get a job. And that's what this is all about, um, it's about upskilling and and getting these skills that you can, you know, get a job or or do better in your job. So I hope this has been helpful. I really appreciate you guys joining me and and doing this entire project with me. I have no idea how long this is; this probably this could be like an hour for all I know, um, so thank you so much for sticking with me this entire time. If you like this video, be sure to like and subscribe below, and I will see you in the next [Music] video.

To go right here in our Power BI tutorials folder, and we're going to click on "Apocalypse Food Prep." So let's click on that, and it is going to connect and pull that data in. Now, right here we have our Navigator. And so, if you had a lot of different sheets, you can click on that and choose which ones to pull in. I just clicked on it right over here, and we're able to preview the data, but I can't load or transform it yet. I need to select which sheets I'm bringing in. So we only have one; that's the only one we're going to bring in. So you can go ahead and load the data, or you can click on "Transform Data." It's going to take us to Power BI Power Query, which is going to allow us to transform our data. So I'm going to have an entire video on how to transform the data, but I'm going to give you a really quick glance at it to kind of show you what it is.

So right up here it says "Our Power Query Editor." This is the window to basically transform your data and get it ready for your visualizations. Now, you can do this in Excel if you want to and do that before, and/or you can do it here. And there are lots of things that we can do in here, as you can see at the top. Again, I'll have an entire video dedicated to just Power Query, but let's take a quick look at the data and see if there's anything we want to transform quickly before we actually go and start building our visualizations. So over here we have the store where we purchased it, we have the product that we purchased, the price that we paid, and the date that we bought it. Now, the first thing that jumps out to me is that this just says "Date" on it. Um, we might want to say "Date of Purchase," and we're going to hit Enter. And if you noticed right over here on these applied steps, it says "Renamed Columns." Everything that you do, every single step that you apply to transform this data is going to be right over here. And if I want to—if I go back and I say, you know, I really didn't want to rename that column—I can just click "X," and it is going to get rid of that and take it back to its original state. So again, I'm just going to say "Purchase," and we're going to Enter that.

Now, this is our "Apocalypse Food Prep," so this is food that we are buying for the apocalypse, um, for this example. And if we look at our products, we have bottled water, canned vegetables, dried beans, milk, and rice, and all of that stuff makes sense except for the milk. Milk will not stay or last long in the apocalypse, so I think what we're going to do is we're going to filter that out really quickly, and we're going to click "Okay." And right over here again, it says "Filtered Rows," and so now if we scroll down, there's no milk. So what we are going to do is we are going to go over here to "Close and Apply," and it is going to actually load the data into Power BI Desktop. So on this left-hand side, it immediately takes us to the "Report" tab, and what we want to do is go right here to the "Data" tab and take a look at our data. So again, there's our "Date Purchased," and as you can see, the milk is not in there. Another tab that we're going to take a look at—um, and again, in this "Report" tab, this is where we actually build our visualizations; the "Data" is where we can see the data and and change it up a little bit and change some small things about it, like sorting the columns or even creating a new column—and over here we have this other tab, and it's called "Model," and this is especially useful when you have multiple tables or multiple Excelfiles and you need to join them to kind of connect them together. We don't have that, but in a future video, I'm going to walk through how to use this entire "Model" tab. So now let's go back to the "Data" tab, and I want to just look at the data really quickly before we go over to the "Report" tab and we start building our first visualization.

As you can see, I've been buying these different products in different months. So this rice, I've been purchasing in January, February, March, and April, and I've been buying it from three different locations because I wanted to see if I was spending less money at one location on all of the products, so then I would just shop there in the future and save a lot of money; or if there were specific products that were really cheap at one location, but others they were cheaper at a different location, so I should just buy like the dried beans at Costco, but everything else I should be buying at Walmart. And so that's what we're going to look at in just a little bit. So let's go over to the "Report" tab. Right up here at the top, there's this "Data" section, so you can kind of choose if you want to add any more data. Now that we are here, we can also write queries or transform the data like we were looking at in the Power Query Editor window. Over here in the "Insert," we can add a new visualization or a text box. And then in the "Calculation" section, we we can create a new measure or a quick measure. And then over here we have "Share," where you can actually publish your report or your dashboard online. Now, over on the visualization section, on this far right, this is a very important area; this is where a lot of the actual creating of the dashboards happens. So let's take a look really quick, and we'll get into a lot of these things as we're actually building our dashboard, so we're not just sitting here looking and talking; we're going to be actually building and doing.

All right, so we're going to click right here on this drop-down on "Sheet One." It's going to show us all of our columns. Now, two of the things that we wanted to look at were: where are we spending the least amount of money buying the exact same product? That'll help us determine where we want to shop. And the second thing was: should I be buying all my products at the same place, or are there certain products that they're going to be cheaper at a specific store and I should buy it there? So let's start out with the first one, which we're just going to see uh with the store and the price—uh, where we're spending the least amount of money—and just at a quick glance, we can see we're spending the least amount of money at Costco at $210 versus Target at $219 and Walmart at $225. And that really answers our question, but we want to visualize it better, be able to see it in an easier way. So we're going to go right over here, and we can click on a lot of these, but the one that probably makes the most sense is the stacked column chart, and it's going to show Walmart, Target, and Costco. Now, they're all the same color. Let's add a legend, so we're just going to drag "Store" over here down to this "Legend," and let's make this larger while we're working on it. So now we can see we're spending the most amount of money at Walmart, right in between at Target, and then at Costco is the lowest. And so right there we know that Costco is the place to go for our apocalypse food prep, but is it going to be that way for every product? I don't know. Let's take a look. Let's put this up in this corner, and let's start a new one. We're going to need to select the product for sure and the price and probably additionally the store as well. And let's click on—let's not do this one; we need a clustered column chart; that's what we need. Let's bring this over here. Let's expand this quite a bit. And so really, at a glance, this is giving us everything that we need. We can see each product right here, and we can see how much we're paying per store. And so for rice, we're paying—it looks like a lot more for our rice at Walmart, while at Target is actually where we are paying the least. Now, if we look at all of these, it looks like for Costco, the only one that we're really paying a lot more on is on our rice, but for our dried beans, our bottled water, we're paying quite a bit less, and really it's pretty negligible for these canned vegetables; we're paying maybe what 60 cents, 50, 60 cents more per can, so that's pretty negligible. But for the big ticket items, um, we're really spending a lot less at Costco. If we wanted to—to save just a little bit more money—we could go to Target for our rice.

Now, if I want to make this more like a dashboard, and we're only keeping these two things, I'm going to kind of size them kind of like this—whoops, going to show you that in a little bit—I'm going to size them a little bit like this. So now that we have that looking good, we want to change the title of both of these. So what we're going to do is go over here in our visualizations and format your visual, uh, and we are going to go to this "General," go to "Title," and now we can name it anything we really want. For this, we're going to say "Best Store for Product," and while we're in here, one other thing that I wanted to do is I want to go to this visual, go right down here to these data labels. Now, we haven't added any data labels, so I'm going to click on, and you'll see exactly what it does—uh, it just puts the labels and the numbers above it, so you don't have to actually like hover over it and see what it is. Now, it is actually rounding these numbers, so what we're going to do is go down here; we're going to go down to "Values," and we'll go down to "Display Units," and it's on "Auto," so it's auto-rounding those numbers, and we're just going to say "None," so we can see the actual value of these numbers. And we can do the exact same thing over here; it probably is a good thing to do, um, and it just is going to visualize it a little bit differently in here, but you can always change that if you want to. Go over here to "Title," and we're going to say "Total by Store," and now we're going to take a look. And so in a matter of minutes, we were able to take our data from an Excel, put it into Power BI, transform it a little bit, then we're able to create these visualizations that gave us concrete answers to some very important topics. We now know that Costco is the place to go for basically every single product except if we're buying rice, and if we want to save just a few dollars, we're going to head over to Target. And that's genuinely going to change my shopping habits for the next several years until the apocalypse happens. So in future videos, we're going to dive into a lot of the things that we looked at today, but just in more detail. And then at the very end of the series, we're going to have an entire project where we really use every single part of Power BI and create a beautiful dashboard. And so that's all we have for our very first video in our Power BI series. I hope it was helpful. If you like this video, be sure to like and subscribe below, and I'll see you in the next video. [Music]

What's going on, everybody? Today we're continuing our Power BI tutorial series, and in this video we're going to be looking at Power [Music] Query. Now, Power Query is really great because it allows you to actually transform the data before you actually get it into Power BI. So if you want to make any changes, like adding or deleting a column, or changing the data type, or a ton of other things, you can do all of that in Power Query. Now, without further ado, let's jump on my screen and get started with the tutorial. All right, so before we jump over to Power BI and start using Power Query, I wanted to take a look at the data, and this is the Excel from our last video called "Apocalypse Food Prep," and in that video we went through and we bought some rice, some beans, water, vegetables, and milk, all for the apocalypse, getting prepared for that. Now, we decided to buy some additional things like rope, some flashlights, duct tape, and a water filter—several water filters—and after we purchased those, uh, our boss, or whoever we're working with, or somebody decided to go and make a pivot table. Now, in this pivot table, they kind of broke it out by Costco, Target, and Walmart, and had all the items, had some subtotals as well as some grand totals right here. And then they decided to kind of copy and paste that into this, and you'll see this a lot when you're working with uh people who use Excel; they like to kind of make things like this, maybe make it into like a table or or format a little bit differently, but you'll see stuff like this a lot. So this is what we're going to actually pull into Power Query and work with. Now, we're going to imagine that this is all we have; this is the only thing we were working with, and I'll kind of reference this pivot table a little bit, but we're going to pretend this is all we have, and we want to transform it to make it a lot more usable to where we can make visualizations with it. So let's hop over to Power BI and pull this Excel in.

So what we're going to do is click "Import Data" from Excel. We're going to click "Apocalypse Food Prep" and click "Open," and then it's going to bring up this window right here. Now, this is where we can choose what data to bring in. So we can take a preview and just click on it real quick, and this is the pivot table that we were looking at. So it does have that pivot table, so we are able to pull in just a pivot table, and then we have the "Purchase Overview," where it's kind of that formatted um thing that we're just looking at with all the colors. We're going to pull both of those in. So we're going to pull in the pivot table and the "Purchase Overview." Now, we could just load it, or we could transform it, and we're going to click "Transform," and that's going to bring us to Power Query. So let's click on "Transform Data." So now, really quick, before we actually jump into working through this and transforming it, I want to show you what the Power Query Editor looks like. So if we go right over here, we have our queries, and these are the tables that we actually pulled in, and we can click on those and kind of go back and forth between them. Now, up top we have our ribbon, and the ribbon offers a lot of functionality. We have things like "Remove Columns," "Keep Rows," "Remove Rows," "Split Columns"—these are all things that we're likely to use when using this Power Query Editor. There's also another tab called "Transform," where there's a lot of functionality here as well—things like unpivoting a column or transposing columns and rows and using a first row as a header—some of the things that we'll be looking at today. There's also another tab called "Add a Column," and this one's pretty self-explanatory, where you can add additional columns, like deleting a column, creating an index column, or a conditional column; those are the three main ones. There's also "View," "Tools," and "Help," but we're not going to really be looking at those today. And then on the far right side, we have our query settings. You can do things like change the name, so we call it "Pivot Table 2022," and it'll update right over here on our query side. And we have our applied steps. Now, our applied steps are extremely important and very, very useful. Anytime we make any change to transform this data, it's going to be documented right here, and then we can go back and look at it, or we could even delete that change in the future if we want to and go back to a previous version of what we just did. So when we loaded the data into Power BI, it did a few things for us: it shows the source, the navigation, and it promoted the headers, and then it also changed the data type. So if we want to check, we can actually see those things or change those things, like this "Source" right here. We can click on this little icon, and it's going to bring up the actual path where we got this file. So if we wanted to change that or or it changes in the future, we can come here, and we can change this file path, but we're not going to do that right now. So let's click on "Cancel," and let's go back down to "Change Type." So it promoted these headers, and obviously these headers are not correct; we're looking at this pivot table and not the "Purchase Overview," but it changed these column headers. And so in the future, if we wanted to, we could easily change those, but it did that for us, and it changed the type as well. So if you look right here, it says "abc123" all the way over here, it's where it just says "ABC." "ABC" means it's only going to be text, where "abc123" means it could be basically anything—uh, text or it could be numeric. So now let's go over to "Purchase Overview," and this is the one that we're actually going to be working on the most, but we might be looking at "Pivot Table" just a little bit to kind of reference it and see some of the differences.

So before we do anything, let's just take a look at how Power BI decided to take this data in. So it chose this "Apocalypse Food Prep Overview" as kind of the first column, and that was kind of our header or the title of what we were looking at before, and then all these other columns are basically "Column 1," "Column 2," "Column 3," "Column 4," "Column 5." So that's something that we're going to want to change in just a little bit. There's also all these blank uh columns right here at the top and kind of these null values as we go along, and we'll take a look at those, and we kind of—we're going to want to get rid of some of this and just clean this up to make it more usable for our Power BI visualizations. This may be perfectly fine and acceptable in an Excel, but when you're pulling it into Power BI, the real reason you're pulling it in is to create visualizations, not just—to look good in an Excel. So we're going to need to clean this up quite a bit. So let's go right up top. The first thing that I want to do is I want to get rid of these top rows. So we're going to go to this top ribbon, and we're going to click "Remove Rows," and we're going to select "Remove Top Rows," and we're going to select "two" because we have one, two rows of all nulls, and those are completely useless; we just want to get rid of them right away. So let's click "Okay," and it removed those. The next thing that we want to do is these—this "Location," "Product," and all these dates; these are actually the column headers that we wanted. So what we need to do now is we want to go over to "Transform," and we want to say "Use First Row as Headers," and just like that, we have "Location," "Products," and these dates as our headers, exactly how we wanted them. Now, let's say for whatever reason, you know, we made a mistake and we needed to go back, we would just select "Remove Top Rows," and that would be perfectly fine. Now you can see over here it promoted the headers, but it's also changed the data type. So before, if we went to—before we removed the headers—these were all "abc123," "abc123," because it had a lot of different data types in there, so it just kind of made a generic data type. But when we promoted these headers, the first thing that it decided to do was also change this data type for us, giving us its best guess as to what this data type is, and it decided to do this "Decimal." So this "1.2" is a decimal, but we're actually going to change that, and all you have to do is click on this "1.2," uh, or or the data type that it has right here for you, and we're going to click on "Fixed decimal number," and let's do "Replace current," and now it's just a little bit better. So now it's 2.70, 2.5, and that's normally how we would read uh values like this because this is money, so we would normally read it to the second.

Decimal, just like that. And if we have it on the second decimal for some, we should probably have it on the second decimal for all, all of them. So really quickly, I'm going to go through, and I'm just going to change that, and it should be pretty quick. So hang with me for just a second. All right, that is perfect.

Now, for the purposes of what we're about to do, we don't actually need these subtotals, or this Costco total, Target total, and Walmart total, as well as the grand total. Really, we want to get rid of those. And so what we're going to do is we're going to go right over here; we're going to click on this drop-down, and we're going to try to filter this data before we actually load it into Power BI. So we're going to filter, and we're going to say "remove empty," and let's remove those, and it's going to take out all of those nulls. If we wanted to try to filter this out by saying something like "Costco total" or "Target total," we could do that by going right here, clicking this drop-down on products, going to text filters, and saying "does not contain," and let's do insert, and we're going to say "does not contain," and we want to say "total," and let's click "okay." Okay, and again, it filtered out all of those things. So there's a few different options that you can do if you want to filter out rows that contain either null values or specific values.

Now, the next thing that we're going to do is actually get rid of a column, this grand total column. And so what we're going to do is we're going to click on the very top part where it says "grand total," we're going to go back over here to home, and we're going to click on "remove columns," and it says "insert," that's because we're on this filtered rows one right here, um, but what we're going to do is just insert that, and it'll insert right there. That's totally fine; we can just move it to the bottom. Now we got rid of this column entirely.

Now this looks really good visually. I like how this looks; I like how everything is set up. The biggest thing about this is that when you're actually wanting to use this for visualizations, these columns as dates doesn't really work too well. And so what we're going to want to do is we're going to want to transpose this or pivot this to where these dates are actually rows. So what we're going to do is select the first date, which is January 1st, all the way through April 1st, and we're going to hit Shift and click on that April 1st right there to select all of them at the same time, and then we're going to go over here to the Transform tab, and we're going to click "unpivot columns," and let's see what this does. And so now what we've done is we've basically recreated our original Excel that we had. So let's go back and take a look really quickly at that. So this looks almost identical to what we have in Power BI right now, and this is extremely usable and very good for visualization and is much, much better than this. But again, we were pretending that this is what we were given at the beginning, so you have to imagine, you know, somebody just handing you this, and you need to make it much more usable for visualizations in the future, which happens a lot, and we actually wanted to create this; we just weren't given this.

Now, a few last things that we might want to do is we want to clean this up just a little bit. We're going to select the data type and change this to date, and then we're going to select the value, and I double-clicked on the value, and I actually want to call this cost, uh, or product cost, product or cost, and then for the location, I actually want this to be called "store." So now this looks really good, but I want to show you one thing really quickly on this pivot table 2022. So let's go back here; this looks very similar to how we had it when it first started. One thing I wanted to show you, uh, really quickly, and I want to click on this first one; we're going to make, make this our column header, and then we're going to try to pivot or unpivot this January, February, March, April. So really quickly, let's do that. So we're going to transform, use first row as headers. So now we have this January, February, March, April. Now, if you notice, these are not dates; these are actually texts. It says January, February, March, and April. So if we go to do this and we click "unpivot," and here's the columns that are cre, cre, when we unpivot it, it is January, February, March, and April. These are not dates, so we cannot go and change this to a date because that would error out because it's actually text. So it's something that you want to look out for; it's something that you need to be aware of, and you can change that in the pivot table. So you want to be aware of how it actually sits and looks in the Excel or whatever data source you're pulling from before you actually pull it into Power Query to transform.

And now the very last thing that we need to do to finalize all of this is go over here to "close and apply," and once we click that, everything that we've worked on is going to be applied to the actual data, and it's going to load into Power BI to create our visualizations. So let's go ahead and click on that, and so now the data has been pulled into Power BI. Let's go right down here to data, and we can see the data right here. If we need to transform this data again, we can bring it back into the Power Query Editor window by just clicking the "transform data" button, and it's going to bring us right back. So I hope that this was helpful. Thank you so much for watching. If you like this video, like and subscribe below, and check out all my other videos and everything data analyst related. I'll see you in the next [Music] video.

What's going on, everybody? Welcome back to the Power BI tutorial series. Today we're going to be taking a look at building [Music] relationships. Now, when you import multiple tables from either the same data source or multiple data sources, you want to tie them together so that when you're creating your visualizations, everything is connected. So in this tutorial, we'll be walking through how to create those relationships to make sure that all of your tables are connected properly. And without further ado, let's jump onto my screen and get started with the tutorial.

All right, so before we jump over to Power BI and start creating our relationships and our model, I want to take a look at the data in Excel. We realized we were buying so many products for the apocalypse that we decided to start our own store, and we have several customers and some client information down here. And so I wanted to take a look at some of the columns and these tables that we're going to be looking at. First thing we have is the Apocalypse Store; these are the things that we are selling. I know it's a very limited inventory, but these are the really high sellers; these are the ones that I wanted to sell. So we have this product ID, our product name, price, and production cost. Then we have this Apocalypse Sales; this is how many sales we've actually made to our customers. So we have this customer ID, our customer name, product ID, order ID, unit sold, and the date it was purchased. And then we have our customer information right here; here are all of our clients. So we have this customer ID, customer address, city, state, and zip code.

So now that we've taken a look at our data, let's go and load it into Power BI. So we're going to say "import data from Excel," we're going to choose this model right here, we're going to click "open," and we are going to want all three of these, so I'm going to click on all of them, and we're just going to load it; we're not going to transform the data at all. So now the data has been loaded. Let's go right over here on the left-hand side to our Model tab, and let's scoot this over just a little bit and move back, and we're going to move these tables up to where it's a little bit easier to see. So right off the bat, you can already see that there are these lines between these tables, so there are already relationships that Power BI has automatically detected and created. From my experience, Power BI actually does a really good job at creating these relationships automatically, but we're going to go in and take a look at these and kind of see what everything means, and then we're going to go back and create these relationships from scratch just to make sure that we know how to do every single part. So to get it started, let's double-click on this line connecting the customer information table to the Apocalypse Sales table, and it's going to bring up this "edit relationship" page right here. So this line right here connecting these two tables actually gives us quite a bit of information without actually having to click into this "edit relationship" page. What this is showing is that we have a one-to-many relationship, and there's only one or a single cross-filter direction, and you can find both of those things right down here, and I'm going to walk through what those mean in just a little bit. On this page, you can also see the columns that Power BI decided to choose in order to tie these two tables together. Now, for our example, they decided to use the customer and customer right here from the customer information table, as well as the Apocalypse Sales. But I don't really want to use those specifically because on this Apocalypse Sales table, I might remove this customer information and just keep the customer ID. It may have chosen these customer columns because they have the exact same name and really the same information, but I want to use this customer ID anyways. So what I'm going to do is I'm going to click on that column and click on this column, and then I'm going to click "okay," and if we go back into it by double-clicking again, we're going to see that, and now save that. And if we did what we just did before, which is kind of hover over it, it's going to show us what those two tables are joined on. So opening this back up, let's go down here to this cardinality and cross-filter direction. Cardinality has several different options that you can choose from; you have one-to-many, one-to-one, one-to-many, and many-to-many. Now, for this example, we're looking at Apocalypse Sales, and we're going Apocalypse Sales down to customer information. Now, there are a lot of rows in the Apocalypse Sales, but there's very few in this customer information, and there's only one customer per row, whereas in the Apocalypse Sales up here, the customer can have several rows for several different orders. So that's why the cardinality is many-to-one. Now, if we flip this and we say we want the customer information here and we want the Apocalypse Sales down here, we tie that together; now it's going to flip, and it's going to say one-to-many. Now let's look at the cross-filter direction, and there's only two options here; it's either single or both. And if we choose both and we click "okay," this now goes from a single arrow pointing in one direction to two arrows pointing in both directions. But what does this really mean? So in order to demonstrate this, I'm going to put this back to a single direction, and what we're going to try to do is connect the data over here or the columns over here to the columns in this Apocalypse Store. So let's go over here to build a visualization, and what we're going to do is we're going to take this customer information, and let's just say we want to look at state. So I'm going to click on "state" right here, and I'm just going to make this into a table, and the customer information table is only tied right now to the sales table. So we're actually going to go over to the Apocalypse Store, and we want to see how many product IDs are being bought in these different states. So really quickly, we're going to come up here and create a new measure, and all we're going to say is this measure is the count of Apocalypse Store product ID, and we're going to create that, and now we're going to select it, so it's added to that table. So now what this is showing is that there are 10 products, which there are 10 products for each of these states, but that's not actually technically correct because not every state purchased these 10 different items. If we go back to our model and we change both of these to a both direction, and then we're going to go back and see what changed in our numbers. So now let's go back to our visualization, and now we can see that Minnesota actually only ordered seven different product IDs, Miss, Miss 8, New York 99, and Texas 10. This is actually much more accurate than before. When you use the both option, it takes these tables and treats them as if they are a single table, but the single option is not going to do that. And so for our example, if we're trying to connect this table to this table, and one of the last things that I want to show you is this option right down here, which says "make this relationship active." Now, if we don't click this, and there are other options in here that connect these things like the customer to the customer, then that may be the active relationship, but if I select this is the active relationship, that means this is going to become the default relationship between these two tables. So now let's come out of here; we're going to click "cancel," we're going to zoom in just a little bit and bring these tables a little bit closer, so we can zoom in just a little bit more. Now we are going to go ahead and delete these, so we're going to say "delete," yes, and "delete," yes. So just for demonstration purposes, we're going to build these relationships from scratch. So we're going to come over to the customer information table, and we're going to drag it all the way over here and put it on top of this Cust ID or the customer ID in Apocalypse Sales, and it's going to automatically create that relationship, and we can open this up, and as you can see, it created the relationship between this customer ID in the Apocalypse Sales and the customer ID in the customer information. It also defaulted the cardinality from many-to-one and the cross-filter direction to single, so we're going to go ahead and change that to both and click "okay," and then we're going to come over here to the product ID in Apocalypse Store and drag this over the product ID in the Apocalypse Sales, and again, if we open it up, it created that relationship for us; it created the cardinality automatically, and we're going to change this cross-filter direction to both and click "okay." And so on a really small scale, that is how it works. Of course, it becomes a little bit more complex the more tables that you add and the more relationships that are created, but this is how you're going to actually create the relationships in the Model tab within Power BI. I hope that this tutorial has helped you understand this concept a little bit better. Thank you guys so much for watching; I really appreciate it. If you like this video, be sure to like and subscribe below, and I'll see you in the next [Music] video.

What's going on, everybody? Welcome back to the Power BI tutorial series. Today we're going to be taking a look at DAX [Music]. Now, DAX stands for Data Analysis Expressions, and it's basically a library of functions and operators that help you build formulas. You can use DAX to create measures and calculated columns within Power BI, which can really give you a lot of insight into your data. Honestly, it is not super complicated, and hopefully, by the end of this video, you'll have a lot more confidence actually using DAX and Power BI. So without further ado, let's jump onto my screen and get started with the tutorial.

All right, so let's take a look at our tables and data before we get started. So we have two tables: the Apocalypse Sales, the Apocalypse Store. For this Apocalypse Sales table, we have the customer, product ID, order ID, unit sold, and the date it was purchased. And then for the Apocalypse Store, we have product ID, product name, price, and production cost. Now, these are joined together, or they do have a relationship together via the product ID. So what we're going to be using are these new measures and new columns to create our DAX functions. So really quickly, let's go over to this Report tab, and let's drop down our fields over here so we can see everything. And so to get us started, we're going to go right up here to Apocalypse Sales, we're going to right-click and click "new measure," and it's going to open up this right here, which is basically our bar where we can create our functions. And so right here, it's automatically given us the name "Measure," but we can change that, and we're going to say "Count of Sales." So now we can start writing our DAX function; that's just going to be the name of it, and what's going to show up right over here once we click Enter. So let's go over here, and we're going to say "count," and as we're typing, it's automatically giving us options; it has something called IntelliSense. If you've ever used other Microsoft products, IntelliSense is their kind of autocompletion that helps you look at other options very quickly. And so we're just going to click on this "count," and it's prompting us to put in a column name. And so we can come down here, and we can select one, or we can type it out, and it'll try to predict and help us choose which column to select. So for us, we're going to use this order ID, but let's just start typing it out; we'll say "order ID," and then we can click on it, and we're going to close this parenthesis and click Enter, or you can go over here and click this check mark, but we're just going to click Enter. And so over on this right side, it finalized that and saved that, and we can actually look at that by clicking on this box next to it, and we want to look at this in a table. So now we can see that there are 74 sales. Now, for this, we want to see who's buying our products; we want to see what our, what our client name is. So we're going to go over here; we're going to choose "customer," and we're going to put "customer" on top of sales, and we're just going to take a look at it like this. So now we can see that our number one customer is Uncle Joe's Prep Shop; he has 22 orders. Now, they have the most orders with us, but it doesn't necessarily mean that they're spending the most money with us, but we can take a look at that later. The next thing that I want to take a look at is how many products we're actually selling; what are our big products that we're selling? We have 10 different items, but I don't know exactly which one is selling the best; if, if one is doing really poorly and getting no orders, this is something that I want to look into. So all we're going to do is go right back up here to Apocalypse Sales again, right-click, and select "new measure," and for this one, we're going to call it the "sum of products sold," and all we're going to start out with is by doing "sum," and if this seems familiar to something like Excel, you're 100% correct; it is very similar. And remember, these are both Microsoft products, so there's going to be similar functionality in both of them. And so this DAX is going to have a lot of similarities to exactly how it has it in Excel. So we're going to do an open bracket, and now what we're going to choose is this "units sold"; we want to sum up all of these units sold and see how many we actually selling. So we're going to say "units sold," I'm going to hit Tab; it's going to autocomplete that; I'm going to close my parenthesis, and I'm going to come over here and click this checkbox. So now it's created that measure, and we're already selected in this table, so all we have to do is click the check mark, and it's going to show us that we have 3,000 total products sold, and we can go through here and see what the big sellers are, and probably the biggest one that I see right off the bat is this Multi-Tool Survival Knife. So these DAX functions that you can write can be very simple, and

Lead to really good insights that you can use for the visualizations later on. Now I want to take a look at the difference between something like SUM, which is an aggregator function, and something like SUMX, which is an iterator function. Because if you add X to some of these aggregator functions, you can create them, or make them into an iterator function. So you can have SUM and SUMX, or AVERAGE and AVERAGEX. Adding X onto the end of them can make them an iterator function. So let's take a look and see how that actually works. I'm going to show you the difference, and then I'm going to talk through the difference at the end.

So really quickly, let's go back to our data and let's go to the Apocalypse Store. Now what we have right here is we have the price and we have the production cost, and we want to see how much profit we're getting from each of these. As well as we can take a look at the unit sold and see how much money we are actually making. So what we're going to do is we're going to come back over here; we're going to go to Apocalypse Store; we're going to right-click and create a measure. In just a little bit, we're going to be creating a new column, and that'll kind of show the difference really well. So we're going to create this new measure, and we're going to name it Profit. We're going to come over here, and what we're going to do is we're going to take the SUM—oops—we're going to start with our SUMs; we're going to take the SUM of the price, and then we're going to close that parenthesis, and we're going to subtract the SUM of the production cost. So all that does is it says, if something cost $20, if we sold it for $20 and it only costs us $10, that's $10 in profit for that item. And then what we're going to want to do is we're going to actually want to encapsulate that really quickly because we're about to use MULTIPLY, and then we're going to SUM, and now we're going to take the units sold. So how many units were actually sold at that profit that we just made? So let's see if that works, and let's click the check right here. And so we have the profit. So let's click on the profit—oops, that's not what I wanted to do—let's use a new one, or let's create a new uh table. We're going to click Profit; let's make it a table, and I'm going to pull this right over here. Now we have our profit, but I really want to know is which customer is spending the most money at my store. So we're going to come right over here; we're going to click on Customer, and I'm going to put Customer at the top, and just at a glance we can see that Uncle Joe's Prep Shop is spending the most money at the store. Now, now what I want to show you is the difference between SUM and SUMX. So what I'm going to do, so I'm going to go back to this Profit, and going to copy this, this entire thing, and we're going to go back here to this table. Now we just created a measure, and we were able to break it down by each customer. So let's go back over here. Now let's go up here to Home, and we're going to create a new column, and we're going to call this Profit_Column, and we're going to literally paste the exact same thing into here, and we're going to hit Enter. And each row is the exact same thing. So what it's doing is it is going through the price and it's adding all of it up and calculating it at the bottom; it's adding the production cost; it's going all the way down and calculating it at the bottom; and then it's going over and looking at how many units it sold, and then it's performing this calculation up here, and then it gives us the total, and it's doing it for every single row. But that's not really what we wanted to show. What we wanted to show is the profit for each row. What we wanted to say is, here's the price for the rope, the production cost for the rope, and then how many units we actually sold, and then it'll calculate that and give us the actual profit for just that row. But we cannot do it by just using this SUM. What we need to do is use something called SUMX. So let's add another column; let's go back to Home; say New Column; and now we're going to say Profit_Column_SUMX, and now we're going to use SUMX and hit Tab, and we need to choose the table that we want to put this in. So we're going to say Apocalypse Sales because that's the table that we're looking at right here. We're going to say comma, and now we need to input an expression, which it says it returns the sum of an expression evaluated for each row in a table. Before, when you're just using SUM, it's looking at all of these combined. Now it's taking it row by row. So what we're going to do is basically input the same thing as we did before. I'm going to copy; I'm going to paste that; it's not going to be correct; I need to get rid of these SUMs; but it's basically the exact same equation. Give me just a second, and let's get rid of this SUM, and let's see if this works. So let's click the check button, and now this looks a lot better. So what this is now showing us is at a row level; this nylon rope made us 51,000, almost $52,000; the waterproof matches made us $115,000; and we can go down and look at each item and see how much that actually made us versus this Profit column. And so that is the biggest difference between SUM and SUMX. Hopefully that made sense. I know that SUM and SUMX, and the difference between an aggregator function and iterator function can be a little bit confusing, especially if you've never done it before, but hopefully that was a good example for you to understand that concept.

Now let's go back over here to Apocalypse Sales. Right here we have a Date Purchase. Now in the DAX function, we have some ways that we can interact with dates, and so I want to take a look at those really quickly. So we're going to go right up here and click on New Column, and we're just going to leave that as Column, but what we're going to say is DAY. So there's a few different ones we have: DAY, DATESYTD, NEXTDAY, PREVIOUSDAY, and WEEKDAY, and they all are pretty self-explanatory. If you click on it, let's click on WEEKDAY; it says it's going to return a number from 1 to 7 identifying the day of the week of a date. So let's use this really quickly, and so we're going to say Date Purchased, and click Tab, hit comma, and it's going to give us a three different options; basically it's a one, a two, and a three, um, right here. If you hit this button, Read more, you can read more on it. This is going to say Sunday is equal to one, Saturday is equal to seven. I like this one personally, which is Monday equals one; in my brain it just makes more sense. So I'm going to click on two; I'm going to close that parenthesis, and we're going to—I guess I'll say uh—let's say Day of Week for the column. Let's click that checkbox, and now Saturdays are equal to sixes, Mondays are equal to one. This allows us to see which day of the week people are buying the most products on, or which day of the week is somebody submitting their orders on. And so let's go over to our report; let's get rid of this; we just going to move this—oh jeez, I hate moving stuff sometimes—all right. Really quickly, I want to show you the difference between what we just did and what we already have. So we have this um Date Purchased, and let's make that into a bar graph, and what we're going to be taking a look at is actually the units sold. So right here we have this, and obviously for—we don't want 2022; we're going to get rid of the year; we only have one quarter right here; we can see January, February, March; so we can tell that January has the most sales, or the most units sold in that month. If we get rid of that, we go down to Day, we do have some information, but we don't know what day of the week it is; it could change from month to month, and it's really hard to tell exactly what, if there's any pattern there at all. That's where what we just created comes in handy. So let's recreate this exact same thing, but instead we're going to use Day of Week. So we're going to select Day of Week and Unit Sold; let's drag that down and move this over right here, and this Day of Week should be on the x-axis, and it's really easy now to see if there's a pattern here. There's really not, at least not for this fake data that we have, um, but just—I—I want these uh data labels on really quickly—it's not easy to see if there's any pattern again. Monday has the most, so maybe that—I mean it goes down a little bit and then it picks back up—so maybe middle of the week is our least uh sales day; our Wednesdays and Thursdays are a little bit lower than the rest, and the beginning and the end of the week tend to be the highest. Again, not a huge pattern, but you know, it's much easier to see if there is a pattern from week to week, or what day of the week, now that we use this WEEKDAY function. And so this can be really, really useful.

Let's go back here to our data. Now we're going to look at our last DAX function for this video. Let's go up here and create a new column, and we're going to be looking at something called the IF statement. Now if you've ever used Excel, I'm sure you have heard of this, and you can do the exact same thing here in Power BI. And so we're going to name this one Order_Size, and so all we're going to say is IF—we're going to click on this one right here—we need to perform our logical test, and then we want to say if it's true, what's our value, and if it's false, what is our value. So what we're going to be looking at is Units Sold. So we're looking at order size, so we're going to say IF Units Sold is greater than 25, what's going to happen? If it is true, if the order is larger than 25, you want to say it's a big order, and if it's not, we want to say it's a small order. Super simple. We'll close that parenthesis; we'll click okay; and now really quickly we're able to see if this is a big order or a small order. And so that is all I have for you today. There are a lot of other DAX functions, but the ones that we looked at today are ones that are very common, ones that you'll see the most, and there can be a lot of really complex and intricate DAX functions that you can create. And in our project at the end of this series, I will be sure to include some more complex DAX functions, but hopefully this gave you a good introduction into DAX, so you know how to use it a little bit better. Thank you guys so much for watching; I really appreciate it. If you like this video, be sure to like and subscribe, and check out all of my other videos on everything data analyst related. I will see you in the next video. [Music]

What's going on everybody? Welcome back to the Power BI Tutorial Series. Today we're going to be looking at how to drill down in visualizations. So when I say drill down, I mean you're basically adding another layer beneath the top layer of the visualization, and when somebody clicks or drills down in that data, they can see more insights and more information on the top level of data. When you drill down, you can also drill up, and I will show you how to do that in this tutorial. So without further ado, let's jump on my screen and get started with the tutorial.

All right, so before we get started, I wanted to remind you that you can find the data that we're going to be working with in this tutorial in the description. You can go and download it from my GitHub. Now the two tables I'm going to be looking at are Apocalypse Sales and Purchase Tracker. And if you've ever created any visualizations, you've probably seen something like this, where you'll have the store and the price, and this is the—the things that we actually bought. So this is the total amount of Apocalypse prepping uh equipment that we bought, and we'll put the store in this Legend right here, and you've probably seen something like this. And if you're anything like me, you're going to be in a meeting, and you're going to be presenting this, and some higher-up is going to be like, "Hey Alex, that looks great, but I want to, you know, see what things we actually bought in Target and how much this cost. Can you create a visualization for that?" And you're going to be like, "Well, I could, or I could use drill down." So you could have done this in the first place, uh, which you should have. So what we're going to do is all we're going to do is we're going to say—we're going to say the product right here, and these are going to be the actual things, and we're going to put it right under Store. Now you can't see these things right, but there is a—a hierarchy here. So once we added this, these options became available. Let's take it out, and all those just disappeared, and then if we add it back right here, they came back. And so you can do right here, which is—is click to turn on drill down; you can go to the next level in the hierarchy, or you can even expand all down one level in the hierarchy. So let's look at each of those really quickly. So let's click on this one; it's just going to turn on drill down mode. So now if I go and I click on Target, it's going to drill down into these, and if we want to, I can then put Product under this Legend, and we can see all of those things. But of course, if we go back up, it's going to be all broken up into this clustered column chart, which is more like—um—this, which isn't exactly what we were going for, but it works. Now uh let me get rid of this; I actually want Store in the legend. Now if we turn that off and we click it, it doesn't do that anymore. So what it does now is it just highlights Walmart; it highlights Costco; it highlights Target. So we're going to keep that on, uh, but we can also do something called going down in the next level of hierarchy. So let's click on that, and so now this is going to go down to the next level, down to this Product level, because that is the next level, and now it's going to show us each of those things, but it's going to have it broken out by the store. And so it's a completely different visualization, but all within the same realm of the data that we're looking at and what we actually care about. So let's go back up in the hierarchy, and then let's use this one right here, which is Expand all down one level in the hierarchy. And so this one is again extremely similar, except it just visualizes it differently, and now what it's doing is Walmart rice, Target dried beans, Costco rice. So instead of having an all—like this one where it's stacked on top of each other—it's breaking it down individually. So this one column would become three separate columns. Now I'm going to minimize this right here; I'm actually going to go back up in the hierarchy just for visual purposes. Now I'm going to show you one more example. We're going to use this Apocalypse Sales up here, and this is one that I actually use all the time. So the one you've seen—you know, you'll get stuff like that, especially if you're working with like sales and stuff—but I work in operations, right? So I have a lot of order IDs, product IDs, stuff like that. Now this one—this one genuinely I use quite often. I'll have a customer—U—let's make it—we'll just go like this; we have a customer, and we have Unit Sold, and let's use the Customer as the legend. So let's make this one quite a bit larger, and I'll have something like this, and they'll say, "Okay, well we want to see the order IDs that go with it, because we want to know what orders are actually happening for each of these people." Obviously I'm not using this exact data, but very, very, very similar. And all you have to do is take these order IDs and slide it right under here, under Customer, and this visualization right here is something I've done a thousand times, because what happens is is someone—some stakeholder in our company is saying, "Hey Alex, we want this, and we want to know—we want to drill down on this IP address; we want to drill down on this certain database; we want to drill down on something, and we want to see the order IDs within them." So then all you do is you turn on drill mode, or drill down mode; you'll click on it, and you can see every single order ID that's in there, and then they can go and look those up in their system and resolve them, or whatever they're trying to do with it, and it helps a ton, and it's very, very useful. This one is extremely applicable, and that's really all drill down is. Again, you have these different hierarchies as well, um, but for different things it's not as useful, as you can see. We also have this hierarchy, which again is not as useful, so it just depends on the data that you're using and how you want to use this drill down effect. But I promise you that drill down is used all the time, especially when you're giving presentations where people want to know more information than just the—the visualization that you're presenting. So I hope that this has been helpful; I hope that you understand drill down a little bit better. If you like this video, be sure to like and subscribe, and check out all my other videos on Power BI. Thank you, and I'll see you in the next video. [Music]

What's going on everybody? Welcome back to the Power BI Tutorial Series. Today we're going to be taking a look at conditional formatting. Now conditional formatting may sound familiar because we looked at it in the Excel series, and it's very similar how you use it in Excel versus how you use it in Power BI. Conditional formatting allows you to take a table or a matrix within Power BI and use those cells to color code them and create gradients and different visualizations within the actual table or matrix. I'm excited to start this one, so let's jump over my screen and get started with the tutorial.

All right, so before we get started, if you want to use the data that we're using in this video, you can find it in the description on my GitHub. Now conditional formatting is super simple, and you've most likely used it in Excel before, but you can also use it in Power BI, and let me show you how to do that. So the first thing we're going to do is come over—over to our Apocalypse Store, and we're going to pull up our Product Name as well as the Price. And what we can do is come over here, and we're going to go to Price, and it has to be under the columns, so you can't come over here and do this. We're going to come right over here to Price, and we're going to right-click, and let's go to Conditional Formatting. And we have Background color, Font color, Icons, and Web URL. Let's take a look at Background color first. This is most likely the one that we'll look at the most. So we're going to get this pop-up, and I'm going to slide this over. Now there's a lot of different things we can customize in here, and the first thing I want to take a look at is Format style. We have the gradient, and what it's going to say is the lowest value will be this color, highest value will be this color; it'll give us this gradient color scale. And so we'll use that in just a little bit, but we can also create rules, kind of like an IF statement, and if it is between this range and this range, we give it a color, and if it's between a different range…

And a different range, we'll give it a different color. So we'll also try that one. And then we have this field value, uh, and this one is one that, uh, honestly I don't use that much. I've used it maybe once. And what you can do is select a text field like customer, and you can do some summarizations on the first and last. And that is it.

So what we're going to do is we're going to look at gradient specifically for not the customer, but we're going to go back to the apocalypse store, and we're going to do it on the price. Now what I'm going to do is keep it as the count because this is what the default is, and we're going to go back and fix it later. But what we want our lowest value to be is this bright green, showing that this it's a cheap product; it's easy to purchase. The high value ones are going to be just the shade of red, more expensive. And we'll do it on the count. Now remember, the count is on each of these, and we're not doing a count of how many are sold; we're doing a count of each product, so it's just one per row, so it all should be the same color. Let's take a look. So it is all the same color, but what we really want to show is the actual price, not just the count of the price.

So let's go back to conditional formatting. We're going to click the background color again, and this time we're going to change the summarization. Now you can do sum, you can do average, minimum, maximum; it really doesn't matter for this example, the number is the same regardless of really which one we choose, so we can just choose the minimum, and it's going to choose the minimum of each row, which is the price. So we're just going to select minimum for this example. We'll select okay, and it should correct it accordingly, which means the bright green is the lowest, and it goes all the way up to the highest, which is the red.

Now let's go over here to apocalypse sales. We'll add in the units sold, and let's move that out a little bit. And I'm doing that on purpose because we're about to look at something within the conditional formatting. So let's go to unit sold, and we'll look at the conditional formatting for this one. Now if you noticed, we now have a new one on here called data bars. Now we're able to see data bar bars on unit sold and not price because unit sold is something like a sum, an average, something that's aggregated. But let's take a look at data bars because I want to show you how to use this, and then we'll go back to the background color. So for data bars, we are going to be taking a look at the lowest to the highest value again. We're going to go from bright green all the way to this exact red. It's going to be from left to right, and what it's going to show you is if it is a positive number, which all of these are, is going to be a green bar basically representing the number that you see in here along this line. So let's click okay, and we're going to be able to see the highest numbers. And let's scooch this over quite a bit so you can kind of get a better understanding, and we're going to do it from highest to lowest. So we sold the most multi-tool survival knives at 477, and so this entire bar, this row, is entirely filled up, or almost all the way filled up, while as it gets lower, and as we sell only 182 solar battery flashlights, the bar is going to represent that and show that.

Now I'm about to completely mess up this visualization on purpose because it's about to get very messy to show you that you can do a little bit too much. Uh, it is possible. What we're going to do is we're going to go right over here to this background color, unit sold, and instead of gradient, let's look at rules. Now with the price we just did a gradient scale, but we can do basically groups of these and say if a number is greater to or equal than this number, then it's going to be a certain color, and then if it's in a different range, we can give it a different color. So we're going to say if it's greater than or equal to zero, and we're going to say number, not percent, and if it's less than 266, because we have 265 right here, let's make it a nice, uh, like gold, a beautiful lovely mustard gold, just just great. Now we're going to say if it's greater than or equal to, we'll do 266, because this is less than 266, so it should be greater than or equal to 266, number, and if it is less than, we'll say 500. Now we want to do this one, and we'll give it, uh, let's do like a peach, and we'll click okay. And now we have another conditional formatting on top of that that can give us more information. Now again, you should not do this; it's just too many.

Now let's go one step further and make it even more ridiculous and show you one more thing before I show you how you may actually want to use this. Uh, let's go back to unit sold. We're going to right-click, go to conditional formatting, and you can do something called icons. Um, font color is the exact same thing as background color except it changes the the font, and so I'm not really going to look into that one. Icons are very simple, extremely similar to Excel and how you've seen them, and the rules that you can apply to them are basically the same as if you're doing like a gradient, and it's these if statements that we saw before. Now it auto gives us this right here, which basically says 0 to 33%, 33 to 67, 67 to 100. If it's in the bottom 3%, it gives us this red; the middle is yellow, and the top is green. So we can go through and change all of this, but honestly, this looks pretty good, so let's click on it, and so the ones that are our least sellers are these red ones right here, and the top sellers are up here. Now this is just based on unit sold, and this looks absolutely terrible. So let's kind of take this exact information but make it a little bit better. So we're going to create a new visualization, or at least a new table. So let's click on product name, and we'll take the price, unit sold, and revenue. And what I think makes the most sense for looking at revenue is these data bars right here, but there's only one problem: I can't do that because it's not summarized like unit sold was. But what I can do is to get that those data bars is I can come right down here, instead of saying don't summarize, I can summarize it, and I can just click the sum. So it now was summarized; it's the exact same number. But if I right-click on here as sum of Revenue, I go to conditional formatting, I can now use those data bars. And so we're going to use those data bars, and we're going to say for the lowest value and the highest value, and let's just make it a nice, maybe a darker green. I don't want it to—well, that's that's hideous—let's make it this color right here, a nice dark green, and there's no negative, so it doesn't really matter. We're going to go left to right, and you can show the bar only, but we're going to keep it because I want to see it, and we're going to go just like this. We're going to order, and this is pretty telling. Um, honestly, I did not think the weatherproof jackets were performing so well, but I mean, they are by far a number one seller, so you know, our weatherproof jackets, multi-tool survival knives, and the nylon rope are outperforming all of our other products. So those might be the ones that I focus on the most, while duct tape, the N95 masks, and waterproof matches, I mean, those are those are garbage, so I might be looking to replace those in the near future with some other items that might sell a little bit better.

So that's how you use conditional formatting, and it's actually pretty useful. There are a lot of times where I've done something like this in an actual visualization for work, and it looks something like this. It just depends on what you're visualizing, but this is very much a simple thing that you can do to just add a little bit more information and and actual visual to this little chart or table that you're going to create. Sometimes it's just better to have these simple visualizations on this table rather than just having the numbers themselves; makes it a little bit more easy to read and understand. So again, I hope that this was helpful. Thank you guys so much for watching. I really appreciate it. If you like this video, be sure to like and subscribe and check out all my other videos on Power BI, and I'll see you in the next [Music] video. [Music]

What's going on everybody? Welcome back to the Power BI tutorial series. Today we're going to be taking a look at bins and [Music] lists. Now bins and lists are really useful because they allow you to group things together to analyze and visualize them easier. So in this tutorial, I'll show you how to create your bins and lists, and then we'll create some visualizations to show you how it can be helpful. So without further ado, let's jump on my screen, start with a tutorial. All right. So before we get started, I wanted to let you know you can go and download the data that we're going to be using in this tutorial in the description below. Is on my GitHub. So we are going to be looking at bins and lists today, um, and for this we're going to be going over here to this apocalypse sales, uh, and let's open up our data right over here, and we want to look at apocalypse sales really quickly. I feel like more people would know what a bin is, so we'll kind of start with a list, just go a little bit backwards than we normally would. Uh, I'm going to use this customer, or we're going to use this customer column right here for a list really quickly, and you can do that in two ways: you can come up here and you can right-click on the customer and go to new group, or you can come over here under this, uh, the Field section on the far right and go to customer, right-click, and click new group. So let's click on that now, and right now is only giving us the list type; it's not giving us bins because bins have to be numeric, so we really can't do that at the moment. Um, so we're going to call this just customer groups, just or or we'll actually call it list just so it's easier to recognize when we create it. And so all we're going to do is we're going to basically group these, but it's going to be called a list. And so what we're going to do is we're going to select, and we're going to select, and we're going to say group and click on this group button, and then it creates this Alex the analyst, apocalypse Preppers, and uh, this prep for anything, prepping store, so that it kind of named it for us. But if we double-click on it, then we can rename this, and we can call this the best prepping stores. And then we have these last two, and we can we can click on one and then click control and click on the other one, so we get both of them, and then we can click group, and we can call this, and we'll double-click and we'll call this the worst prepping stores. Um, and then that's it, and that's all we have to do. And what we're then going to do, and if you want to undo this and you want to switch it up and do whatever, you can click on group, but we're not going to do that. We're going to click okay, and here is the column that it created, and it basically tells us what list we put it in. If it's Uncle Joe's Prep shop, that's in the worst prepping stores list, and if it's the Alex the analyst, apocalypse Preppers, that is in the best prepping stores. So it's kind of like an if statement; you could even create a calculated column, do it on this customer, create an if statement. This is just a lot faster and a lot easier than doing that, but it basically would do the exact same thing. Now you can use lists as well on things like numeric. So let's say we have order ID, and we'll go to new group, and it's going to auto go to bin because typically that's what you'll use, but you can do list as well. And let's say, you know, we want to say we want to call these like we'll group these and call these the first, um, we'll call this the first customers or the first orders because we're looking at order IDs, look at the first orders, and then we will go back here; we're on the left side; we're going to click oops; we're going to go back to the top; we're going to hit shift, group all of these, and we'll say the latest orders, and you absolutely can do this. Um, again, this is kind of like an if statement, right? So you're saying if it falls between this range and this range, then it's called the first orders, and if it's between this range and this other range, it's the latest orders. Um, again, it's just a much simpler version of an if statement, and so you don't have to write it all out; you can just have this user interface kind of do it for you, uh, and and it's really really useful. So now let's talk about bins, and by far the easiest way to demonstrate this, and I'll show you one other way, uh, but by far the easiest ways to show this is by using age. And so, uh, for absolutely no reason whatsoever, these customer IDs, uh, who are right here in this customer information, they decided to give us some of their buyer information who are actually buying their products on their website or in their store; they just decided to give it to us as well as some, uh, simple demographic information. I I don't know why, but what we're going to use bins for is grouping these age brackets. So you know, you might be interested in, say, well, I want to know if my core population who are buying my products are within a certain range, and you don't want to look look at every single age because then it just, you know, in your visualizations it's not going to look right; you want to kind of group them, make it easier to visualize. So what we're going to do is we're going to go through here, and we're going to basically go by tens: 10, 20, 30, 40, 50, 60, and see what age bracket these people fall in. So we're going to go to age, we're going to right-click, and we're going to say new group, and we're going to go to bin, and we'll leave it as a default age bins, um, and you can do two things: you can do the size of the bins, which splits it, uh, uh, which splits it by this number right here, or you can go based on the number of bins. So if you only want to do five different bins, it'll calculate that for you, and it'll say, okay, if you only want five bins, you're going to have to do it at 12.2. If you want 10 bins, it can be 6.1, but it is completely up to you on how you want to do that. Um, you can do the size, and we'll just say every 10, which is what we're going to do, or you can go through, and then you can create, you know, the how many many bins you actually want. So let's go ahead and click okay, and it's going to create those bins for us. So if somebody is 78, they're going to be in the 70s bin; if somebody's 41, they'll be in the 40 bin; if somebody is 29, they'll be in the 20 bin, and so on and so forth. So when we go to visualize this, we don't have, you know, 71, 72, 73, 74 have a lot more things on our visualization; it'll just be the 70, or it'll just be the 20. Now we can also use bins on dates as well. So let's go back to apocalypse sales; we have this date purchase, so we can create a bin for this as well. So let's go to date purchased, let's go new group. Now you can also create a list, and that's totally fine if you would like to do that, um, and it would look kind of like this where you can go through and you can select it and you can say, okay, this group all these dates, you can group those and say this is going to be January, uh, and you can do that, and that's totally okay, um, but for this one we're going to do bins; I think it's a little bit easier to do bins because what we can do is go right here, and we can specify if we want seconds, minutes, hours, days, months, or years. And so, um, for the data that we have, it goes January, February, and March, so we're going to do months, and we're going to say the bin size is going to be one month, so each month should have its own bin, so it'll be three bins total. So we're going to select okay, and as you can see on this right side, we have January of 2022, and that correlates to the January over here, then it goes down to February, and then it goes down to March, and then when we visualize this, uh, we don't have to do this the hierarchy stuff that we do in here where we filter it down down to months; we can just use this right here, and that will be our month's column. So now let's go over to our visualizations, and we'll see how this looks really quickly. We're not going to look at all of them, but we will take a look at a few of them. So the first one that we can look at is age. So let's look at the buyer ID, and then we'll do age as well, and so let's spread this out, and we can see our distribution of our buyers. So it looks like we have very few, uh, who are in the 10 range, thank goodness, and we can even put the age right under here under the age bins, and we have this. Now we kind of have this drill down, and so if we go right here and we drill down right there, this will actually give us the breakdown. So this is what it would have kind of looked like; our visualization would have looked like if we had just kept it the age, cuz now we're drilling down into the age, and so it looks like we have one 18-year-old and maybe a 20-year-old as well. Let's go back up. Yeah, so it looks like we only have one buyer ID, yes, so there's only one 18-year-old, so of legal age to start buying, you know, all these prepping equipment and probably, uh, buying online and stuff like that, which makes sense, right? So, uh, this gives you kind of a quick breakdown in the bins rather than, um, doing it the alternative way. So now let's take a look at the customer list as well as the unit sold, and it looks like the best prepping store, uh, is actually performing much worse, surprisingly, uh, than the worst prepping store. And so I hope this gave you a really good idea of how to use bins and lists within Power BI. Thank you so much for watching. If you like this video, be sure to like and subscribe and check out all my other videos on Power BI. I'll see you in the next [Music] video. [Music]

What's going on everybody? Welcome back to the Power BI tutorial series. Today we're going to be taking a look at all types of [Music] visualizations. Now when you're working in Power BI, there are a lot of different options to create visualizations, and you may not always be sure which one to use, and so that's what this video is for. I'm going to walk you through a lot of the visualizations that I like and I use a lot, as well as kind of point out some of the ones that I don't like as much, so that you get kind of a feel for the ones that I think are really popular and that are used the most. So without further ado, let's jump into Power BI and start taking a look. All right. Before we jump into it, there is a link in the description where you can get the data that we're going to be using for these visualizations if you want to practice them yourself. Before we actually get into it, we do need to combine this, and if you download that Excel and you see

This you'll have to do the same thing. All we have to say is that this product ID is the same as this product ID purchased, and now we are good to go. Do one to many, and it's okay if it's one way. So right over here, under this visualizations tab, there are lots of different options, and it can be a little bit overwhelming. You don't really know which one to choose. There are some in here that I have almost never used for my job, ever, so I'll point those out as we go through. But the main focus is going to be focusing on the ones that I do use, that I have used, and showing you how to actually create that visualization. Maybe spice it up just a little bit, but we have a lot of them to go through, so let's jump right into it.

And the very first one that we're going to start with, probably the easiest one and the one that you'll recognize the most, is a stacked bar chart. And what we're going to do is go ahead right over here to the product name, and we want this unit sold as well. So we're going to click product name, and it's going to go straight into the Y-axis for us. And then we're going to click unit sold, and that will go into the x-axis automatically. It just kind of intuitively knows, but sometimes it will make a mistake, and then you can just fix it or flip it. And we do want this—uh, let me make this much larger—we do want this to be a little bit more color-coded. That is what this legend is down here. So what we're going to do is drag this product name down to the legend, and now we have each product as its own color.

In previous videos, we have gone through and looked at some of these visual and general options that you have when you're actually creating these visualizations, but we're going to do some of them while we're in here as well. So we're just going to go down here; we're going to choose data labels, and we're going to shrink that. And if you go higher, the higher you go, the less you see. So if you want all of them all the way down to the green, we're going to go right about there, and we're going to make it smaller. So now we can go ahead and click anywhere outside of that visualization, and now we can create a new one. If we had just kept it like this, where we were still interacting with this visualization and we clicked on a different one, it would have then changed our visualization completely, which we don't want. So let's hit Ctrl Z, click out of it, and now we can create a new one. Let's go right over here to this 100% stacked column chart. I'm going to click on it, drag it over here, and make it much larger. And we're going to come right over here to this customer information, and we're going to click on customer, and then we're going to go up to unit sold and click on unit sold. And we want to break these out. And so basically what this is doing is it's breaking it out by each of these shops, and we can see the total of what they're buying, the units sold, but we want to see exactly what products make up this percentage of this 100%. So we're going to go right over here to product name; we're going to drag that down to the legend. And as you can see now, we have each of these products, and each of the products is up here. So this backpack, we can see the backpack right here, backpack right here, and right here, and we can see which customer is buying what percentage of their purchases. So for this Prep for Anything Prep store, they have a very large percentage—40% is duct tape—so they're buying a lot of duct tape. So really quickly, we're able to see what clients are purchasing, or which clients are purchasing what products the most.

So just like this, Alex Analyst Apocalypse Preppers, they're buying a lot of water purifiers. We like drinking clean water; um, you know, that's just what my audience likes. And so, you know, we can easily get a quick glance of that. Again, we're going to go in here. I tend to like putting these data labels on here; that's just what I preference. So, you know, something like this, it looks nice, it looks clean. Um, we can always go back and change these names, which we'll do for this one. So we're going to go over here, go to title, we'll go down to the text, and we'll do customer—oops—customer purchase—oh jeez—breakdown. Pretend I'm really good at spelling, and we're going to do it just like that. We'll get out of there. So now we have customer purchase breakdown, and that looks really nice. It's a good—a good visualization. And we're going to bring that right over here. We're going to have a lot on the screen, so I may have to uh make them smaller or larger to fit everything. All right, so let's go on to our next one.

Another really common visualization is this one right here, which is the line chart. And the line chart is great, especially when you're using things like dates. I have found this one to be the best—best—and a lot of people use this as well. So we're going to go right over here and click on date purchased, and then units sold. And on the x-axis, you can see it's broken up by year, quarter, month, and day. So we don't want to do it that high level; we only have three months of data in here. So we're going to get rid of the year; we're going to get rid of the quarter, and then we at least have this. And let's break it out, because right now we're looking at all of the units sold. So we're going to drag the product name right down here to the legend, and now it breaks it out by the actual product. And for each month in January, February, or March, you can follow these products and see how they did in each of those months. And if we wanted to, we can come right over here to the filter on the product name, and we could filter it by maybe the top three. So let's do multi-tool survival knife, the nylon rope, and the duct tape, and we can have it just like this. And you know, you can do those for any product that you want, but again, we just want to do it for those three, just for an example. And that really doesn't give us a ton of information. We could even go down to the day, and you know, it might give us a little bit more information. And so we'll keep it like that, and we can go over here, change the name as well. We're not going to do this for all of them; again, we're just looking at the different types of visualizations I think are really good to know. But we'll change this one as well to products purchased by date. We'll keep it just like that; again, nothing fancy; we're just trying to look at a bunch of different stuff. So let's put this over here, down here. Now let's click out of there.

And there are other ones in here um that are definitely useful and you absolutely can use—um, like this one is a stacked bar chart; this one is a stacked column chart; it's basically the same thing, just a different orientation. Like we went to here, it's just a different orientation; it's the same thing—um, just like this clustered bar chart, clustered column chart; it's just its orientation, either horizontal or vertical. Then we have things like an area chart, uh stacked area chart—not really things that I've used too much in previous positions. One that I have used though is a line and clustered column chart. So it kind of combines a few of these with, you know, you have these bar charts as well as line charts into one visualization. So let's look at this one, because this is one that I have used several times in my actual job. So for our x-axis, we'll use the product name; then we'll look at something like the price. And so let's make this a lot larger so you can actually see it. So now we have the price, and now we can look at something like the production cost, and that can be our line Y-axis. So now we're looking at the price of it, how much someone is actually paying for it, and then we're looking at how much it's costing us to actually produce that product. And so really quickly, at a glance, you can kind of see that it's around the halfway to 2/3 point on most of these. You can see that the production cost is always lower than the actual price, because of course we're out here to make a profit on these products. So let's minimize this one; we're going to put this one right down here; let's make it even smaller; let's click out of that.

And the next one that we're going to take a look at is a scatter chart. So let's click on that and make it much larger. Oops, there we go. So let's use the price and the production cost again. And so our x-axis is the price; our y-axis is the production cost. But now we need to fill in this values right here. So let's go over here and click on the product name and drag that into values. And so now we have our values; we just don't know what they are, but we can see it. So let's drag this down to legend as well, and it breaks it out, and we kind of have this scatter plot. And you know, for this fake data that we're using, it doesn't really show a lot, but if you're using real data, you can definitely find outliers and trends and patterns using this type of visualization. Let's go ahead and make that one small as well, drag it right down into the corner. Now let's go right over here, and we have the—the dreaded pie charts—um, and donut chart. Now look, I think it's kind of a joke in the data analyst community about pie charts and donut charts, but at the same time, people use them, and they request them. And so sometimes you're going to use it, whether you like it or not. So let's click on the donut chart, and let's make this one a lot larger. And let's go over here, and let's click on state, and we're also going to click on total purchased, and that's really all you have to do. These ones are pretty straightforward. You can change a few different things, like where these labels are; if you want them inside, you can also do that, and that would look totally fine. Um, again, I'm just not a super huge fan, but you will get this one requested; people like this and want to see it. And the reason a lot of analysts don't like using this is because when you start glancing at these, it's really hard to tell the difference between these sizes. If you look at something like this, you can easily see that this is larger; like if you're looking at this one, the multi-tool survival knife is obviously the longest, and it gets shorter, shorter, shorter, shorter. But when you start getting in here, it's really hard to approximate the size. I would not be able to tell the difference between this 5.63, 5.78, 2—7.72; I would not be able to tell really the difference between these or—or kind of the—the difference between them very easily. That's why a lot of people don't want to use them in general. So again, I want to show you this one because I think it's worth noting and worth knowing how to use, but I don't really push people towards this because I don't think it's the best visualization available most of the time.

All right, the next two are super easy but are used all the time—uh, maybe more than some of these even—but they're just so easy to use, so I'm kind of saved them for last. This one is the card, and all the card is is it displays one number or multiple numbers if you want to use a multi-card, but we'll just look at the card for now. All we're going to look at is the total purchased, and it's just going to display it just like this, and you can make it as large or as small as you'd like. And normally it goes on like the top, and you'll put card here, a card here—um, just for example, I'll kind of show you how this might look. So it looks something like this, right? And at the top it'll have different, usually high overarching information, and this is super common to see. And I'm sure if you've looked at other people's visualization, you'll see something like this. This is usually totals or averages or something like that in here, where it's super easy to look at. So like right here, this is total purchased, and we can go in and look at the minimum, and then we can go over here, and this one can be account, and so it gives us a lot of information just at a really quick glance. And then we have all of our more in-depth, colorful visualizations that kind of have more information than just a single piece like the card does.

And then the very last one that I'm going to show you is this one right here, which is the table. And this one is obviously extremely popular; it's like an little Excel table. And we can go in here, and we can get the customer, wherever that is, and then we'll also get the unit sold, and this is what it looks like, and it's super easy. And oftentimes you'll have it like on the side as well—uh, and all the other visualizations over here. And so, you know, if we're going to take all these visualizations and pretend they were like a real thing, you know, there's a lot in here, but we'll just kind of really quickly do this—um, you know, we might have something like this, and we'll make this larger and make this wider, and you know, we have a lot of information just in here. And this is not a project, so don't go put this on your portfolio. I'm just threw a ton of random visualizations on, you know, this dashboard. But you can already see a lot of these you most likely have seen in other people's work, in other people's visualizations on LinkedIn or on YouTube. These are very common, very, very popular. And again, we did not go through all of the ones over here. There are maps that you can use, but I haven't used maps ever in my job. There are things like gauges and decomposition trees and waterfall charts and uh tree maps and all these different things, but I really have never used those in my actual job, and I don't see them a lot in other people's work either. Otherwise, I would be telling you to learn these and use these. But again, try them out, see which ones you like. If you like this video, be sure to like and subscribe below and go check out all the other Power BI tutorial videos that I have on my channel, and I will see you in the [Music] next what's going on everybody. Welcome back to the Power BI tutorial series. Today we are going to be working on our final project. Now this is our final project of the Power BI tutorial series, so if you have not watched all of those videos leading up to this, I recommend going and watching those videos so you can make sure that you know all the things that we're going to be looking at in today's project. I am really excited to work on this project with you because I think it is a really good one, and it uses real data that we collected about a month ago where I took a survey of data professionals, and this is the raw data that we're going to be looking at. And so I think it's just really interesting that we collected our own data and now we're using for a project. We're going to transform the data using Power Query, and then we're actually create the visualizations and finalize the dashboards as well as create a theme and a different color scheme to kind of make it a little bit more unique. Without further ado, let's jump onto my screen and get started with the project.

All right, so before we jump into it, I wanted to let you know that you can get the data below. It is on my GitHub; you can go and download this exact file that we're going to be looking at. Now in the past several projects, we have been using this fake apocalypse data set. You know, it was fun; it was, you know, whatever. This data set is real; this is a real data set. It was a survey that I took from data professionals. I posted on LinkedIn and Twitter and all these other places, and we had about 600, 700 people who responded to the questions. So before we actually get into it and start cleaning the data and doing all this stuff in Power BI, I just wanted to show you the data.

All right, so this is the CSV that I downloaded from the survey website that I used, and this is completely raw data. I haven't done anything to it at all. Let's go through the data really quickly, and we'll kind of see what we have, and we are not going to make any changes at all in Excel. We're going to do all of our transformations, or at least a few transformations, in Power BI, because again, this is a Power BI tutorial and project, so I want you to kind of learn how to use that and not use Excel, because you can go through my Excel tutorial if you want to do that. So let's just look at it in Excel, and then we'll move it over to Power BI and actually start transforming the data. So we have this unique ID; these are all the people that actually took it—oops, don't want to do that—we have an email, which this was completely anonymous; I didn't collect any data or user data on this. Then we have the date taken—um—and let's get into the actual good information. Then we have all of these questions. So we have question one, which title fits you best, and they can choose things. Now—uh—let's add a filter really quickly that we can look at this. Now you had the pre-selected ones which were like data analyst, architect, engineer, but then there was an option where you could say other, and you could specify what that was. So if you look in here, we're going to have all these different other, please specify, with different titles, right? And there were a lot of them. Now typically what you want to do is really clean this up, and we're not going to be doing a ton, ton, ton of data cleaning, but we are going to do some in Power BI, but none in here. But typically with this amount of data and the way that it's formatted, we would do so much data cleaning—um—with this one, I mean, I mean, there is a lot of work to be done—um—like this current year salary; this is one that I would absolutely be cleaning up because it's ranges, and it has a dash and a k and—and all these numbers. This is something that I would be cleaning up and using, but we're not going to be cleaning this up right now. So anyways, let's just get into it. Let's see what questions we asked. Uh, we have the yearly salary, what industry do you work in, favorite programming language. Then there were a lot of different options; this is like one question where they picked multiple options. So is how happy are you in your current position with the following: you have your salary, work life balance—um—then we have co-workers, management, upward mobility, learning new things—um—and they could rank it from zero to 10. So some people ranked upward mobility a 10, some ranked it a zero or a one—um—and again, they can answer however they want. How difficult was it to break into data: very, very difficult, very easy—um—if you're looking for a new job, we have, you know, what would you be looking for: remote work, better salary, etc. We have male, female, which country you from, and then this is more like demographics. So if you're a male, how old are you? And this was in a range, so this is like a—a—a sliding bar, so you could slide it to the exact age you had. There's some people who are apparently 92—um—which if that's true, I mean, good for you, man or woman. Actually, really quickly, I'm going to see just—just while we're here—I'm going to see if this is a male, male or a female. Oh, it's a female from India. Very cool. Um, so we have all this information, and it is a lot of information. When you have something like this, I mean, there is so much data cleaning that can be done. I mean, I already see like 20 plus different things that I would—

Need to do to make this a lot better, um, and we also have date taken and the time taken, as well as how long it they took on it, like the time spent. Really just really interesting data, but again, this is a beginner tutorial series; this is the beginner project, so we're not going to get do anything too crazy. I will be using this exact data set in a future video, doing a lot more data cleaning and creating a much more advanced visualization with what we have and what we're looking at right here. But for this video, we're just going to be doing a pretty simple visualization and dashboard that you can use, uh, to practice with or put on your portfolio if you know that's where you're at right now. So let's get out of here and let's put this into Power BI.

So let's exit out and let's come right over here to import data from Excel. We'll click on Power BI final project and open; give that a second. Doing this all in real time; we only have the one, so we'll do be; we won't be practicing any joins or anything, but we're not going to load it; we're going to transform this data. So let's put it into Power Query editor, and now we have all of our data in here, and it should look extremely familiar. Now, when I'm looking at this, when I start looking at this information, I kind of need to know beforehand what I want to get out of this. Do I need to clean every single column? Do I just need to clean a few of them? Do I need to get rid of columns? That's kind of where my head's at. And so right off the bat, I can already tell you that there are columns that we can just delete to get out of our way, so we're going to do that at the beginning so that we don't have to do that later on, or they're just in our way.

So I'm going to click on browser, and then I'm going to hit Shift and I'm going to go over here to refer, and I'm just going to go up here to remove columns. And everything that we do is going to go over here to this applied steps. If you've been following this series, um, you know we can remove things, add things, but anything we do will show up right over here, so we can track it and go back if we need to. Now, one column that I know for sure that I'm going to be using quite a bit is this: "Which title fits you best in your current role?" Because I, I specifically wanted to do a breakdown of different people's roles and how much they make and different stuff like that, so I know that I want to use this. But as we saw before, there's kind of the issue is, is it's not very clean; right? It has data analyst, data architect, engineer, scientist, database developer, and then like a hundred different options, and then a student, or or none of these, right? Um, and so for the purpose of this video right here, we are not going to take every single one of these options because this involves a lot more data cleaning. Let me give you an example: This says software engineer; this also says software engineer, and with AI, these two would typically be combined or standardized to software engineer, but it's not very easy to do that in Power BI. We could do that in Excel, but not really in Power BI or even SQL if we pull this from a SQL database, um, and you can find lots of different, you know, options of that. We have data manager and data manager; if we separated these out, these would be different options when we created our visualizations, and we don't want that.

So what we are going to do, uh, and this is going to be kind of an easy way out to just make sure that this is pretty clean and doesn't, we don't have a thousand different options, we're going to create this to other, so we're to simplify this a lot, and then we're going to use this, so we'll have maybe six or seven options instead of the, you know, let's say 50 that we would have if we actually did the harder work, which just break it out, standardize it, and clean it up that way. So what we're going to do is we're going to click on this right here, and we're going to go up here to split column in this ribbon up top. We'll go to split column, and we want to do it by a delimiter, and if you notice, let me see if I can move this over; if you notice, we have other, and then we have this parenthesis, and in no other option or way is there parenthesis. So what we're going to do is we're going to use a custom, and we're use this open parenthesis. What that's going to do is it's going to separate it by this parenthesis; it's going to leave the other; it's going to create separate columns, um, just one separate column for each of these, and we can do that at each occurrence, or we can do the leftmost, and we really, we only need it for the leftmost because there's only one of these, uh, left-handed or left-sided, uh, brackets, or or what is it, whatever this is called, and then let's go and click okay, and it should create another column. So it's going to have 0.1, Point 2, and now we have; if we click on this, now we only have these options: We have analyst, architect, engineer, data scientist, database developer, other, and student, looking or none. That is what we want; it makes it so much simpler, and it's not perfect, but again, I'm trying to show you what we are able to do in Power BI. So now we're just going to remove that column, and we're going to go and do the exact same thing to this one as well, because I know that we want to use this, and I really wanted to use this one as well. But if we look at this one also, um, there's a lot. So I said, "What is your favorite programming language?" And people, there were pre-selected answers like JavaScript, Java, C++, Python, R, things like that, and then there was an other option, and in this other option, I mean, it was free text, so they can fill it in as they want. I mean, there's four, five, six different ways that people put SQL; that is something I would standardize, and you know, that would be the way I cleaned it, but that's not how we did it in here. So we're going to do the same thing; we're going to keep that other, so we're going to split this column again; we're use a delimiter, and for this delimiter though, we're going to use a colon, so we're going to say we're going to do a colon right there; we'll just do the leftmost; we'll click okay, and then we have our options, and it's much simpler now. I really would have rather kept all these and because SQL's in there quite a bit, but you know, a lot of people don't think SQL is even a programming language, so, uh, we're going to delete that column.

Now, one that I just skipped and I kind of wanted to go back to is this current yearly salary. I really want to use this. Let's see if we can use it. I here's what I want to do with it, and this is not perfect, um, for this video, I want to try it. What I want to do is break up these numbers, 106, 125, and then take the average of those numbers, so then we'll use some docks in there, so we'll take 106, 125, create that into two separate columns, then we'll create a third column that will give us the average of those two numbers, so we'll do 106 plus 125 divided by two, and then we'll have the average of that. Now that is not perfect, but it's going to give us at least, you know, an average of kind of roundabout number because they gave us this range; they said my salary is between 106 and 125,000. So if we say that their salary was 112,000, at least gives us, it makes it usable; it's a numeric value instead of being this, which is text, which we really, we could use and and I'll show you how to do that because we're going to keep this column. I'll create a copy of this, and I'll show you the difference between this and using the average, but for but for this data cleaning portion, let's just try it; let's see what we can do and see if we can make it work. So first, let's create a duplicate, so we're going to, uh, duplicate the column, so now we have this copy at the very, very end, and we can use this one instead of having to use the original way, way, way back here, so we're going to leave that one how it is, and we're going to use this one. So let's go ahead and split this one up; we're going to click on the column header, then we're going to click on split column, and we'll do it by digit to non-digit, and if you look at it right here, it's broken it out kind of, um, in the fact that now in this one we just have numeric values, and in this one we have k-numeric or just dash numeric, and now this can be easily cleaned, whereas this one we can just completely get rid of because it's only K, so we'll just remove that column, and then in this one we're going to right-click; we're going to click on replace values, and so if it just has, we're just do a k, we'll replace with nothing; we'll do okay, and then for the last one we'll go to replace values, and we'll do the dash or the minus sign, and we'll place that with nothing, and so now we have our values as well. Oh, we also have a plus; let me get rid of that because that's when some people had 250 or 225,000 plus. So for that one, the average is just going to be 225; we'll have to specify that in our dock; I forgot. But actually, if somebody has 225, let me find this plus really quick, uh, let me filter by it because that's a lot faster. What we actually want to do for the purpose of this one is we want to put 225 here, so that when we do 225 plus 225 divide by two, it comes out to 225; that's just what we're going to put it as, and there's only two people, so, uh, I'm actually going to replace this; I'm going to do replace values; I'm G to say Plus with 225, and we'll click okay. Awesome. We can unfilter these; select all. So we're going to go right up here to add column; we're going to say custom column, and we're going to go right over here; actually, let's make it, uh, average salary; let's make it average salary. So we're going to insert this; I'm going to say parenthesis, and we're going to say plus this, insert, and close the parenthesis, divided by two, and it says no syntax errors have been detected; let's click on okay, and it's giving us an error, so it's saying we cannot apply operator plus to types text and text, which makes perfect sense; these aren't, uh, numbers. So let's make it a whole number, and let's make it a whole number, and then let's see if this will actually work; no, or maybe we just need to try a whole another one. So let's try transform or add column, custom column; let's try this all again; see if, uh, I can make it work; insert; do this one plus this one, and we'll do divid by two, and let's try this one, and there we go. So now let's get rid of this column, columns, and we can actually remove these ones as well because now we have this, um, average salary column, which when we look at this or when we use this, uh, we can, let me see if I can just move this way, way, way over. All right, I might cut because this is taking forever. So if you take the average of these two numbers, you'll get 53; if you take the average of 0 and 40, you'll get 20. So now we have this average salary, and again, when we get to the actual visualization part, I'll show you why this isn't as useful as having this average salary, and just a reminder, this is not perfect; I wouldn't typically do this, especially if I had it in Excel or if I was, you know, creating this survey in a different way; I would probably have a very specific value where they could do it on a slider, but this is how it is. So we've at least made it usable or more usable in my mind, and we have a few other things that we can change, like what industry do you work in, where we can break this one out, so I'm going to go ahead and break this one out as well as this one right here, which country do you live in; I'm going to break, bro, both of those out to where it's the country or other; I'm not going to have these other values, although there are a lot of them because there's a lot of people who live in these different countries, but we can't really do that super well in here because again, the same issue kept happening: Argentina, Argentina, Argentine, a, Australia. So we can't normalize those values unless we spend just a copious amount of time doing that. So I'm going to go ahead and do these; I'm going to fast, I'm going to fast speed this so it goes a lot faster, so I'm just going to go silent and let this happen really quick, and then we'll get to the end and we'll actually start building our visualizations.

All right, so we've split them up, and as you can see, we have all the these options as well as other, and I think, you know, there is, let me tell you, there is so much more that we could do with this; I mean, just so many other things, but this is like what the bare minimum of what we need for this project. So let's go ahead and close and apply this, and if we need to come back at any point and actually fix anything or change anything, we can, so it's not like that's permanent, um, so as you can see, we have everything over here; we have all our data as it is transformed in here as well, and now we can start building out our visualization. Let's go back to our report and let's start building something out.

All right, so let's add a title to our dashboard; we want to make this right at the top; we call this the Data Professional Survey Breakdown, and let's make, make that quite a bit larger; make it bold; why not? And we'll put that in the center, and now let's, um, let's add some effects; let's change that background to something like, it's too dark; something like this, and I do not like that bold; let's take that off; there we go. So something like this, just as a quick title to what we're about to do, what we are about to build. So we're going to start off with the most simple visualizations that we're going to do, and we'll kind of work our way towards kind of the harder ones. So the first one that we're going to start off with is a card, and the cards are obviously like just super, super easy; they usually just display one piece of information. So we're going to go right over here to the very bottom at the unique ID, and we're going to select it, and we're going to say a count of distinct or account; it doesn't matter; um, it says 630, count of unique ID. Now we're not going to keep that as is; we're actually going to go right over here; we're going to say rename for this visual, and it says count of unique ID, but we're going to say count of survey takers, and you can say whatever you want here, but in in general that is what it is; we're, we're counting how many people, um, you know, took this survey, and that's just a kind of a total; maybe I should say total amount or of survey takers, but you can say count of survey takers; how many people took this survey. So let's click out of there; let's click on card; let's make it about the same size; we're going to drag it up here and try to make them about the same; we will in a little bit; we'll make them the same size, um, but for this one we're going to look at age, so we're going to look at current age, so I'm going click on that, and we'll say want the average age, so our average age taker is almost 30 years old. So let's go right over here; we're going to say rename for this visual; we'll say a average age of survey; oop, this might be too long; average age of survey taker; again, name it whatever you'd like. So again, these are meant to be high-level numbers, so when somebody's looking at your dashboard, they can just really quickly glance at this and know exactly what it is, instead of like some of these other visualizations that we're about to create; they don't really have to dig into it, look at the x-axis, the y-axis, the the different, uh, legend colors and whatnot; they can just see these high numbers and get a really quick glance of the data. Now let's create our first visualization, and what we're going to do for that one is a clustered bar chart. So let's go ahead and click on the clustered bar chart; we can create as small or as large as we'd like, and for this one we're going to be looking at the job titles. Now remember we kind of changed the job titles or, you know, U transform those if you want to say that, so we're going to look at job titles, and then we're going to look at their average salary, and if you remember we transformed that one as well; we have a average salary. Now this one is, it looks like a text right now, so it may not work properly, and what we're actually going to do is go over here; I want to see the average salary, so let's click on average salary and see if we can change this data type from a text to a decimal number; let's click yes; I forgot to do that when we were transforming it, and there we go; this is perfect, um, so now we can go back and we can select our average salary, and as you can see, it has this, um, this function symbol, and so now we can click on it, and it'll look a lot better, and although this says average salary as the title, it's actually doing a count or the sum, so we can click average right here, and what we want to do is actually break this down by the job title, and so now we can see data scientists are making the most by far, far; they're making an average of 93,000, at least from the survey takers that took it, then we have our data engineers making 65,000; data architects are making 63, and then where the data analysts, data analysts are right here, making 55. So again, we had 630 people take this survey, and so the vast majority of them were data analysts, so this one's probably the most accurate out of all of them, and I actually don't like how this looks as the cluster bar chart; let's try the stacked bar chart and put this as the legend; that's more what I was going for. I don't know; I didn't want as skinny because when you're doing this one, it typically they have multiple options per, um, uh, x-axis, and so I think that's why it was that little skinny line, but this one is more what I was looking for, but let's make that smaller, and let's definitely change that title because good night, um, this is like incredibly long; let's go over here to this format visual, ual; we'll go to the general, the title, and we're just going to say average salary by job title, just like that, and this looks a lot better. Now we're not going to kind of format all our whole dashboard yet; we're going to create our visualizations, and then we're going to kind of organize everything and kind of play Tetris with it to make it look the best, so we're just going to minimize this and put it right up here for now, um, but we will go back and kind of make everything look better at the end. And actually, while we're here, I also want to change this as well, so rename for this, we're going to say job title; oops, why did I do that? Job title, and for this one we're just going to say name average salary; there we go; looks much better, much cleaner; uh, took away a lot of the anxiety that I was feeling about two minutes ago when we first put that up there. So let's go on to our second visualization; the next one that I'm interested in is actually what programming language people were using the most, so we have salary; there's a

Thousand different things we can look at in here, but I want to know you know what people's favorite programming language is. So let's take a look at that. So we have favorite programming language; let's find that. So we have our favorite programming language, and we also have how many people actually took it, or the unique people. So right now, this is columns; we don't want that. Let's um, let's do a clustered column chart. Click on this right here, and it looks like, here we go, that is kind of what we're looking for. And instead of count of unique ID, we'll say count of, let's do count of Voters, and for favorite program language, we'll say favorite, oops, favorite programming language, and get rid of that as well. And then we're going to go into here also and change the title and say favorite programming languages, or favorite pro programming language, just like this. Now let's make this a lot bigger so you can see it. But really quickly, at a glance, you can see Python is by far the most popular; other C++, JavaScript, Java. Now all we're seeing is the count, so it's all the same; it's just blue. We can see how many people voted for each one, but if we wanted to break it out similar to how we did with the job titles, we could still do that. So all we'd have to do is break it out, uh, or bring this job title down to the legend, and now it breaks out like this. And that's not exactly what I was going for; I was going more for something like this where we can see the still the whole count, but now we can see who is actually voting for these things. So I'm just not a huge fan of the colors that are pre-selected here and kind of the whole theme of this dashboard. At the very end, we're going to completely revamp this, change a bunch of colors, the background, and make this look a lot nicer rather than just the white background like we have it. Um, and so for now, let's just make this a lot smaller and put it into this corner. These will not be staying there, but we need to, we need room to create our next visualizations and just, just a cleaner space to do things.

Now the next thing that I really want to include is a way to break down where they're from, their country, because especially something like salary is very dependent on your country. Whereas the average salary in the United States for a data analyst may be like 60,000, in another country it could be 20,000; that could bring down the average quite a bit. So we need a way to be able to break that down. Now we can do something like a filled map, and there's no problem with that at all, um, but you know, for what we're building, what we're creating, it's not probably going to work out the best. I mean, this looks okay; we could stick it in the corner or something, um, and you can do that, and that's perfectly fine. I think what I'm going to do is something like a tree map, which I don't use a lot, but I want something where they can just click on it, they can look at the values distinctly, they can look at the values and just click on it, and it'll be right there for them, so they don't have to filter it out on their own or know geography. And look at this map; they can just read Canada, other, United Kingdom, India, United States, and click on that. And so, for example, let's click over here on United States; the numbers change quite a bit. Now the average salary for a data scientist is 139,000; for data analyst, it's 80,000. And if we look at India, you know, the average salary for a data scientist is 68,000; the average salary is 26,000 for a data analyst. That doesn't mean that they make less money in India; that just means that the cost of living is probably lower in India; therefore, they don't need the higher US dollar salary, because again, this was all done in US dollars. So just something to think about. Uh, let's click out of that, so we'll keep that one as well.

So now let's create our next visualization, and this is one that I do not get to use enough in my actual job, so we're going to use it in this project, um, and it's going to be this gauge right here. So let's add that one, put it right over here. We're going to add two of those; let's just go ahead and add another one while we're at it because we're going to have them kind of like right here, right next to each other. The first one, and these ones are really good for kind of looking at these kind of surveys, and I don't get to work with surveys enough, but we can see, you know, how happy are they in terms of work-life balance. So we can add that; we're going to add work-life balance, um, and right now it's doing a count, and we don't have minimum or maximum values in there yet, so it's going to look kind of weird, but we're going to look at the average rate, or the, the average score of these. Then we're going to pull this over to the minimum value, and we want to put that at the minimum, and pull this over and add the maximum value. So now it actually has zero to 10, and it shows that the average person is happy with, which one was this? Their average person is happy with their work-life balance; they rate about a 5.74 overall. Now let's really quickly change the title of this because this is ridiculous. I want to say happy with work-life balance, so this is their rating, uh, you know, change it to whatever title you want; that's what I'm going to do. And we'll also do happy with their salary. Let's click on salary. We'll add that to minimum, and we'll add the maximum value as well to make sure that we know how to use that, and then we'll take the average. So not many people are happy with their salary; I'm just finding out. I mean, this is a real survey; this is real data, so I mean, it's pretty interesting. Let's go to the title; let's go to happy with, or maybe it's happiness, happiness with salary, maybe that's what we should make it, and I'm going to change that over here as well. I think it sounds better. Some of this I've already planned out; some I haven't; this is not something I've planned out, so, so we're going to say happiness with work-life balance, happiness with salary; really interesting. Um, we may go back and tweak these just a little bit in the future, but the very last visualization that we're going to do is male versus female; kind of got to have that in there. Um, I don't typically like pie charts and donut charts, but, uh, you know, I'm feeling, I'm just feeling it, so let's try it, um, and we will do, let's see, let's make this larger, so we have male, female, and what do we want to look at, like what do we want to measure? So we have male versus female; we can measure anything, um, but maybe what we'll do is the average salary again. I mean, we've kind of only looked at salary once in this one right here, um, and a little bit of like how happy they are, but we'll look at the average salary between males and females, and then we'll look at not the current age, oops, I meant average salary, and then we'll look at the average, and it looks like the average salary is actually really close versus males versus females: 55,000 for female versus 53,000 for male. So actually the females are a little bit higher; congratulations. So they're just a little bit higher in terms of pay.

So now we need to start organizing all of this, cleaning it up, making it look a lot better than it does right now. It looks great, uh, you know, but we can do a lot more with this. So I'm gonna, we're, we're going to keep these, or all these kind of over on this left-hand side. I'm gonna put this, I want this up here. We also need to change that title. I want this up here, um, and again, we're going to kind of change the theme as we go. I, I just want to format it right; we'll have it just like this. Let's change the title of this; let's go to title, and we're going to say country of survey takers, uh, I'm not, the survey takers, I'm not really stuck on that. If you find something better, you think of something better, I would go with that, but, um, you know, it definitely doesn't look bad. And where did this, where did my other visualization go? There it goes. Um, I think this one I want to make kind of more tall, um, so I might move it this way. Geez, this is such a, I hate, I hate having a lot of visualizations on here; it just really is annoying to me. So what we're going to do, I think we're gonna step this to the side, put this to the side as well. I want to make it to where it's just, okay, I didn't want it to cut off; we'll do that. Might make these, um, make these a little bigger actually, so I want it to kind of match the size, like right there. I'll match this perfect. This one I kind of want to bring over here and bring it down a little bit, maybe something like this, maybe, I'm not sure; I'm not, I'm not sold on that. Um, I added a few different visualizations that I didn't have in my original, so now I'm kind of having to do this on the fly, so I might fast forward some of the parts where I'm like really thinking about it or taking too much time on it, but I'm going to bring this down a little bit actually because I don't like how close that is to, um, the, the text above it. But one thing we do need to do, I'm going to put this up kind of like this; I think that looks fine. I think I'm going to put this at the very bottom, so let's make some room for it. All right, just like that, stretch it to the side, and we'll lower it, and I think we'll keep that as is, kind of like this.

Okay, there's a lot going on in here, and there are some things I'm just noticing as we're walking through this that I kind of missed, um, like I need to change some titles and stuff like that, so let me go ahead and change some of those things. So we're going to do title, do average salary by gender, or by sex, do like that, average salary by sex. I also don't like that it's in the middle; um, I don't like that it's on the outside; I want them on the inside for this. So let's go to the details; let's go to inside and see if that looks any better. Oh, that looks terrible. Um, let me see if I can change that. Maybe I don't, no, I definitely want it, um, I guess we'll do outside. You can't even see the information. Oh, the decimal is crazy long. Um, let me go and see if I can change that decimal to just like a whole number or like 1.1, uh, because that's a problem. So maybe I need to go over here to the value. All right, so I think I want to change this one; it's just not working out exactly how I wanted, and you guys know if I make mistakes, I'm going to keep it in here so you guys can see it. I, I hoped that this was going to turn out better, but it didn't. Um, one that I do want to add because this is kind of a, a breakdown and a nice visualization, I want to add this difficulty piece. So I want to add this, how difficult was it for you to break into data science? Let's get rid of these, and I want to click on this really quickly, see what it gives us, um, values. Okay, so now this shows us percentages, um, of how easy it was. Again, it's neither easy nor difficult, difficult, easy, very difficult, very easy. These numbers make absolutely no sense; we need to kind of order them a little better. So I'm going to come over here to slices; we have our colors over here; we want very difficult to be like the most difficult, um, so we're going to make that red, and then we want difficult to be maybe like an orange. Let's see if we can find an orange; there we have an orange. This does not look red enough; there we go. Oh no, no, no, very difficult is red, difficult is orange. We have neither easy nor difficult, and that's kind of a neutral, um, let's see if we have something neutral in here, kind of like this yellow. I don't know; let's try it out. Then we have easy and very easy, and these will be like our blues. So I'm going to keep that, um, I'm going to keep that kind of like a dark blueish, and then our blue for super easy is just going to be like really blue, u, and that doesn't look bad. The, I mean, look, I'm, I'm not a color person; I, I'm not great with colors, and we're going to kind of organize this in just a little bit, but this looks better to me, um, but we need to change up some stuff as well, like the title. Need to do difficulty to break into Data; there we go. And we're also going to change this title right here; we're just going to say difficulty, difficulty, difficulty. This looks better to me, um, again, not perfect, and there's a thousand different things you could have done, but that's just what we're going to do. I need to go through here and see what I need to change. So right off the bat, I can see I need to change this, um, to, let's see, right here, I'm going to rename this job title just like we did in this one right here, uh, count of Voters, that's fine, progr language, breaking into, difficulty, happiness, happiness, average, count, okay, okay. So what we have here is very close to a finished product. Now it's not 100% complete; I mean, I, I do want to make it look a little nicer rather than just the typical white. So what we're gonna do, we're gonna go up here, we'll go to, uh, what is it? View, and we have all these different filters, and we're just going to play around with it, see if we can find something that we like. Um, this doesn't look too bad; it's not really my style. We can do this one, Frontier; this is pretty neat. I kind of am digging this; we might come back to it. I like the natural tones; I don't know why I said tones like that, but I did. Um, this one's not bad, but I don't, I don't, it's not that, that's not my, I don't like how dark that is, um, and so maybe it's like, you know, we change like the background color of all of these as well as match it with, um, match it with something else, whatever you want. Genuinely, you customize this however you want. I kind of like this one; it's kind of groovy, man, and, um, it's not perfect by any means, but what we can do, and we can customize this current theme; we can come in here, customize this theme however we'd like. I personally don't want color five, which is the data analyst color; I don't like it to, I don't want to go, go and change it because I don't like it, but I don't really like that color per se, you know, I might want to choose a different color, um, but it has to be like this muted like that; it has a style to it. So you can come in here, and you can customize this and make it however you'd like, and, and really mess around with it, play, play around with it. For me, uh, I'm just going to keep it how it is because I don't really want to mess with it and break it or anything like that. So, u, let me just put that up just a tiny bit. So this is it; this is the project. I hope that it was helpful. Um, I am not joking when I say that I'm, because I'm gonna do a different project; I'm gonna go really in depth in another project; it's probably gonna be like a two-hour project; it's going to be crazy long, um, well, for a YouTube video, but I can see doing a thousand different things with this data, creating a really great dashboard, really cleaning the data, which is a large part of, of actually doing this, and we didn't do much data cleaning at all. There's just so much you can do with this, and so really dig into this, see what you like, see what you don't like, see what you want to clean, what you don't want to clean. You could put it in SQL; you could put it in, um, Excel, and just, and just standardize the data to make it a lot more usable. Do whatever you want with it; I mean, I, I took this survey for you guys that we could use it, so go out and use it and make the best dashboard that you can possibly do. So I hope that this was helpful; I hope that you enjoyed this. Thank you so much for watching this video. If you like this, thank you so much for watching; if you like this video, be sure to like and subscribe below, and I'll see you in the next [Music] video.

What's going on, everybody? Welcome back to another video. Today we're going to be starting our Python tutorial [Music] series. Now I am extremely excited for this series; we're going to be walking through all the things that you need to know to get started in Python. We'll be looking at variables, data types, for loops, while loops, operators, and a ton more. After this beginner series, we're going to be going into another set of series where we look at pandas, matplotlib, seaborn, web scraping, and more. Now in this video, we're just going to be setting up our environment to where we can learn Python in future videos. In this series, we're going to be using Jupyter Notebooks for all of our tutorials because I feel like it's a really great place to learn the basics, but then in future videos I'll show you different IDEs that you can use for your Python code. I genuinely cannot wait to get started on this series; I absolutely love Python. So without further ado, let's jump on my screen; I'm going to show you how to install Jupyter Notebooks.

All right, so let's get started by downloading Anaconda. Anaconda is an open-source distribution of Python and R products. So within Anaconda is our Jupyter Notebooks as well as a lot of other things, but we're going to be using it for our Jupyter Notebooks. So let's go right down here, and if I hit download, it's going to download for me because I'm on Windows, but if you want additional installers if you're running on Mac or Linux, then you can get those all right here. Now if you are running on Windows, just make sure to check your system to see if it's a 32-bit or a 64-bit. You can go into your about in your system settings to find that information. I'm going to click on this 64-bit; it's going to pop up on my screen right here, and I'm going to click save. Now it's going to start downloading it; it says it could take a little while, but honestly, it's going to take probably about two to three minutes, and then we'll get going. Now that it's done, I'm just going to click on it, and it's going to pull up this window right here. We are just going to click next because we want to install it. This is our license agreement; you can read through this if you would like. I will not; I'm just going to click I agree. Now we can select our installation type, and you can either select it for just me, or if you have multiple admin or users on one laptop, you can do that as well. For me, it's just me, so I'm going to use this one as it recommends. Now it's going to show you where it's installing it on your computer; this is the actual file path. It's going to take about 3.5 gigs of space; I have plenty of space, but make sure you have enough space, and then once you do, you can come right over here to next. And now we can do some advanced options. We can add Anaconda3 to my path environment variable, and when you're using Python, you typically have a default path with whatever Python IDE or notebook that you're using. I use a lot of Visual Studio Code, so if I do this, I'm worried it might mess something up, so I am not going to do this. It also says it doesn't recommend it. Again, messing with these paths is kind of something that you might want to do once you know more about Python, so I don't really…

I recommend you having this checked. We can also register in AA 3 as my default Python 3.9. You can do this one, and I'm to keep it this way just so I have the exact same settings as you do. So let's go ahead and click install, and now it is going to actually install this on your computer. Now, once that's complete, we can hit next, and now we're going to hit next again, and finally we're going to hit finish. But if you want to, you can have this tutorial and this getting started with Anaconda. I don't want either of them because I don't need them, but if you would like to have those, keep those checked, and you can get those. Let's click finish.

Now let's go down, and we're going to search for Anaconda, and it'll say Anaconda Navigator, and we're going to click on that, and it should open up for us. So this is what you should be seeing on your screen. This is the Anaconda Navigator, and this is where that distribution of Python and R is going to be. So we have a lot of different options in here, and some of them may look familiar. We have things like Visual Studio Code, Spyder, R Studio, and then right up here we have our Jupyter Notebooks, and this is what we're going to be using throughout our tutorials. So let's go ahead and click on launch.

This is what should kind of pop up on your screen. Now I've been using this a lot, um, so I have a ton of notebooks and files in here, but if you are just now seeing this, it might be completely blank or just have some, you know, default folders in here. But this is where we're going to open up a new Jupyter Notebook where we can write code and all the things that we're going to be learning in future tutorials. And you can use this area to save things and create folders and organize everything. If you already have some notebooks from previous projects or something, you can upload them here. But what we're going to do is go right to this new; we're going to click on the drop down, and we're going to open up a Python 3 kernel. So we're going to open this up right here.

Now, right here is where we're going to be spending 99% of our time in future videos. This is where we're going to write all of our code. So right here is a cell, and this is where we can type things. So I can say print; I can do the famous hello world, and then I'll run that by clicking Shift+Enter. And this is where all of our code is going to go. These are called cells, so each one of these are a cell, and we have a ton of stuff up here, and I'm going to get to that in just a second. One thing I wanted to show you is that you don't only have to write code here; you can also do something called markdown. And so markdown is its own kind of, you could say, language, but um, it's just a different way of writing, especially within a notebook. So all we're going to do is do this little hashtag, and actually I think it's a pound sign, but I'm going to call it hashtag; we're going to do that, and we're going to say first notebook. And then if I run that, we have our first notebook, and we can make little comments and little notes like that that don't actually run any code; they just kind of organize things for us. And I'm going to do that in a lot of our future videos, so just want to show you how to do that.

Now let's look right up here. A lot of these things are pretty important; uh, one of the first things that's really important is actually saving this. So let's say we wanted to change the title to—I'm going to do a AA because I want it to be at the beginning—um, so I can show you this. I'm going to do AA a new notebook, and I'm going to rename it, and then I'm going to save that. So if I go right back over here, you can see AAA new notebook. That green means that it's currently running, and when I say running, I mean right up here. And if we wanted to, we go ahead and shut that down, which means it wouldn't run the code anymore, and then we'd have to run up a new cluster. Uh, so let's go ahead and do that. I didn't plan on doing that, but let's do it. So we have no notebooks running, and right here it says we have a dead kernel. So this was our Python 3 kernel, and now since I stopped it, it's no longer processing anything. So let's go ahead and say try restarting now, and it says kernel is ready, so it's back up and running, and we're good to go.

The next thing is this button right here. Now this is an insert cell below. So if I have a lot of code I know I'm going to be writing, I can click a lot of that, and I often do that because I just don't like having to do that all the time, so I make a bunch of cells just so I can use them. You can delete cells, so say we have some code here, we'll say here, and we have code here, and then we have this empty cell right here; we can just get rid of that by doing this cut selected cells. We can also copy selected cells. So if I hit copy selected cells, and I can go right here and say paste selected cells, and as you can see, it pasted that exact same cell. You can also move this up and down. So I can actually take this one and say I wanted it in this location; I can take this cell and move it up, or I can move it down. And that's just an easy way to kind of organize it instead of having to like copy this and moving it right down here and pasting it; you can just take this cell and move it up, which is really nice.

Now, earlier when I ran this code right here, I hit Shift+Enter. You can also run, and it'll run the cell below. So you can hit run, and it works properly. If you're running a script and it's taking forever and it's not working properly—at least it's you don't think it's working properly—you can stop that by doing this interrupt the kernel right here. And anything you're trying to do within this kernel, if it's just not working properly, it'll stop it. You can restart it; then you can try fixing your code. You can also hit this button if you want to restart your kernel, and this button if you want to restart the kernel and then rerun the entire notebook. As we talked about just a second ago, we have our code and our markdown code. We're not going to talk about either of these because we're not going to use that throughout the entire series.

The next thing I want to show you is right up here. If you open this file, we can create a new notebook; we can open an existing notebook; we can copy it, save it, rename it, all that good stuff. We can also edit it. So a lot of these things that we were talking about, you can cut the cells and copy the cells using these shortcuts if you would like to. We also go to view, and you can toggle a lot of these things if you would like to, which just means it'll show it or not show it depending on what you want. So if we toggle this toolbar, it'll take away the toolbar for us, or if we go back and we toggle the toolbar, we can bring it back. We can also insert a few different things, like inserting a cell above or a cell below. So instead of saying this plus button, you can just say A or B, adding above or below. We also have the cell in which we can run our cells or run all of them or all above or all below, and then we have our kernels right here, which we were talking about earlier, where we can interrupt it and restart those. There are widgets; we're not going to be looking at any widgets in this series, but if it's something you're interested in, you can definitely do that. And then we have help. So if you are looking for some help on any of these things, especially some of these references, which are really nice, you can use those, and you can also edit your own keyboard shortcuts.

And now that we walked through all of that, you now have Anaconda and Jupyter Notebooks installed on your computer. In future videos, this is where we're going to be writing all of our Python code, so be sure to check those out so we can learn Python together. Thank you guys so much for watching. I hope you were able to get everything installed correctly. I am super excited for this series ahead of us. If you like this video, be sure to like and subscribe below, and I will see you in the next [Music] video [Music].

Hello everybody. Today we're going to be learning about variables in Python. A variable is basically just a container for storing data values. So you'll take a value like a number or a string; you can assign it to a variable, and then the variable will carry and contain whatever you put into it. So, for example, let's go right over here. We're going to say x, and this is going to be our variable; we're going to say is equal to. Now we can assign the value to it. So let's say I want to put 22. x is now equal to 22. So we won't have to write out the number 22 in later scripts that we write; we can just say x because x is equal to 22; it now contains that number. So now we can hit Enter and say print; we do an open parenthesis, and we'll say x. Now I'm going to hit Shift+Enter, and now it prints out that 22 because we are printing x, and x is equal to 22. This is our value, and this is our variable.

One really great thing about variables is that it assigns its own data type; it's going to automatically do this. So we didn't have to go and tell x that it's an integer; it just automatically knew that 22 is a number. So we can check that by saying type and then open parenthesis and writing x, and we'll do Shift+Enter again, and this says that x is an integer type. Now we only assigned an integer to x. Let's try assigning a string value or some text to a variable. So we'll say y is equal to—uh, let's say mint chocolate chip. I'm feeling some ice cream today, so we'll say mint chocolate chip. Now if we print that again, we'll do print, open parenthesis y, and do Shift+Enter; it'll print mint chocolate chip, and if we look at the type, we can see that the type is a string this time and not an integer. Now, again, we did not tell it that x was an integer and y was a string; it just automatically knew this.

Let's go up here really quickly. We're going to add several rows in here because we're about to write a lot of different variables and really learn in-depth how to use variables. The next thing to know about variables is that you can overwrite previous variables. Right now we have mint chocolate chip, and that is assigned to the variable y. So if I go down here, I say print y, I hit Shift+Enter; it's going to print out mint chocolate chip. But if I go right above it, I say y is equal to, and let's say chocolate, if I print that out, it's now going to say chocolate, whereas up here, I'm reassigning it to y; it's still going to say mint chocolate chip. So if I come right down here and I copy this and I'm going to paste this right here, initially it is going to assign y to chocolate, but then right here it will automatically overwrite y as mint chocolate chip, and when we hit Shift+Enter, it's going to show mint chocolate chip. Variables are also case-sensitive. So if I come up here and I say a capital Y, this is a lowercase y, and this is a capital Y, it is going to print out the correct one instead of mint chocolate chip. And then if I go down here to the print and I type the capital Y, it will give us the mint chocolate chip.

Up till now we've only assigned one value to one variable, but we can actually assign multiple values to multiple variables. So let's do x, comma, y, comma, z is equal to, and now we can assign multiple values to all of those. So we can say chocolate, and then we'll do a comma, oops, a comma, then we can say vanilla, and then we'll do another comma, and we'll say rocky road. Now this is going to assign chocolate to x, vanilla to y, and rocky road to z. So what we can do is we'll say print, and we'll go print, print, print, and we'll say x, y, and z. So it prints out chocolate, vanilla, and rocky road, and these are our three different values. We can also assign multiple variables to one value, and we can do this by saying x is equal to y is equal to z is equal to, and we can put whatever we would like. Let's do root beer float. Then we'll come back up here; we'll copy this, and let's print off our x, our y, and z, and they are all the exact same now.

So far we've really only looked at integers and strings, but you can assign things like lists, dictionaries, tuples, and sets all to variables as well. So let's go right down here. So let's create our very first list. I'm going to say ice_cream is equal to, and that is our variable right there; the ice_cream is our variable. So now we're going to do an open bracket like this, and we're going to come up here and copy all of these values, and we're going to stick it within our list. So now within ice_cream we have three string values: chocolate, vanilla, and rocky road, all within this list. So what we can do is we can say x, comma, y, comma, z is equal to ice_cream. So so now these three values: chocolate, vanilla, and rocky road, will be assigned to these three variables: x, y, and z. And we can copy this print up here, and we'll hit Shift+Enter, and now the x, y, and z all were assigned these values of chocolate, vanilla, and rocky road.

Now, something that we just did, which is really important, or something that you really need to consider is how you name your variables. So right here we have ice_cream. Now this, to me, is exactly how I usually write my variables, but there are many different ways that you can write your variables. So let's take a look at that really quickly, and let's add just a few more because I have a feeling we're going to go a little bit longer than what we have. So there are a few best practices for naming variables. First, I'm going to show you kind of what a lot of people will do; I'll show you some good practices, and I'm going to show you some bad practices as well that you should avoid doing. The first thing that we're going to look at is something called camel case, and let's say we want to name it testVariableCase, oops, case. Now if we have testVariableCase, the camel case is going to look like this: we'll have lowercase test, and then we'll have uppercase Variable and uppercase Case is equal to. This is what this variable is going to look like, and we can assign it vanilla swirl. And this is what your camel case will look like; it's going to be lowercase, and then all the rest of those uh compound words, or however you want to say that, these letters are going to be capitalized to kind of separate where the words end and begin. Let's go right down here; we're going to copy this. The next one is called Pascal case. So Pascal case is going to look just a little bit different; instead of the lowercase at test, it's going to be a capital T in Test. So TestVariableCase, again, this is a very similar way of writing it, very similar to camel case, but just a capital at the beginning.

Now let's look at the last one, and this one is my personal favorite. This one is going to be the snake case. Now this one is quite a bit different in the fact that you don't use any capital letters, and you separate everything using underscore. So we're going to write test_variable_case. Now typically—let me have them all in there—typically these are the best practices; these are what you typically want to do, but probably the best one to to use is this snake case right here. What a lot of people say is that it improves readability. If you take a look at either the camel case or the Pascal case, which you will see people do, it's not as easy to distinguish exactly what it says, and the name of a variable is important because you can gain information from it if people name them appropriately. So when I'm naming variables, I usually write it in snake case because I just find it a lot easier to read because each word is broken up by this underscore. So now let's look at some good variable names. These are all ones that you can use or could use. Let's do something like test_var. So test_var is completely appropriate. We can also do something like test_var, oops, we could do _test_var; you'll see that often as well; well people will start it with an underscore. You can do testVar, capital T, oops, capital T, capital V in testVar, or you could even do something like test_var2. Now adding a number to your variable is not inherently a bad thing; usually it's semi-frowned upon, but there are definitely some use cases where you can use it. But one thing that you cannot do is do something like putting the two at the front. If you put the two at the front, it no longer works; it won't run properly at all. So we're going to take that out; so we can't do that. So I'm going to use this as an example of what you should not do. You also can't use a dash, so something like test-var2, that doesn't work either, and you also can't use something like a space or a comma or really any kind of symbol like a period or a backslash or equal sign; none of those things will work within your variable.

Now another thing that you can do within your variable is use the plus sign. So let's assign this; we'll say x is equal to, and we'll do a string; we'll say ice cream is my favorite, and then we'll do a plus sign, and we'll say period. Now what this will do is it will literally add these two strings together. So let's do print, and we'll do x. So now it says ice cream is my favorite. One thing that we cannot do in a variable is we cannot add a string and a number or an integer. So we can't do ice cream is my favorite 2. If we try to do that, it will give us this error right here. So in this error, it's saying you can only concatenate a string, not an integer, to a string. So only a string plus a string for this example. You can also do—and we'll say x is equal to—or we'll say y; we'll say y is equal to 3 + 2, and it should output five because you can also do an integer and an integer now. So far we've only been outputting one variable in the print statement, but you can actually add multiple variables within a print statement. So let's go right down here; we're going to say let's give it some more right there. So we'll say x is equal to ice cream, and we'll say y is equal to is, and then the last one z is equal to my favorite, and we'll do a period at the end. Now we can go to the bottom, and we can say print x + y + z, and when we enter that and when we run and when we run that, we get ice cream is my favorite. Now we can actually add a space before is, a space before my, and when we hit Shift+Enter, it says ice cream is my favorite. You can also do this exact same thing with numbers as well. So we'll say x = 1, 2, and what z is equal to 3, so this should equal 6. Now one thing that we tried to do was assign to one variable a string plus an integer, and that did not work, but what you can do is you can take something like this and you can say ice cream, and we'll get rid of this one, and

We'll get rid of the Z now, saying plus is actually not going to work. Let's try running this. So again, we can't concatenate these, but what we can do in the print statement is we can separate it by a comma. So when we add this comma, it should work properly. Let's hit enter, and it says "ice cream 2." Again, this makes no sense, but you are able to combine a string and an integer, separating by a comma.

Now, this is the meat and potatoes of variables. There are some other things as well, but some of those things are a little bit more advanced and not something I wanted to cover in this tutorial. Although we may be looking at some of those things in future tutorials, but this is definitely the basics, what you really, really need to know about variables. I hope that this video was helpful; if it was, be sure to like and subscribe below, and I will see you in the next [Music] video.

Hello everybody. Today we're going to be talking about data types in Python. Data types are the classification of the data that you are storing. These classifications tell you what operations can be performed on your data. We're going to be looking at the main data types within Python, including numeric, sequence type, set, Boolean, and dictionary. So let's get started actually writing some of this out, and first let's look at numeric.

There are three different types of numeric data types: we have integers, float, and complex numbers. Let's take a look at integers. An integer is basically just a whole number, whether it's positive or negative. So an integer could be a 12, and we can check that by saying type; we'll do an open parenthesis and a close parenthesis, and if we say the type of 12, it's going to give us an integer. Or if we say a -2, that is also an integer. We can also perform basic calculations like -2 + 100, and that'll tell us it is also an integer. So whether it's just a static value or you're performing an operation on it, it's still going to be that data type if those numbers are whole numbers, whether negative or positive.

Now let's take this exact one and let's say 12, and we'll do + 10.25. When we run this, it's no longer going to be a whole number; it'll now be a float. So let's check this, and now this is a float type because it is no longer a whole number; it's now a decimal number. And the last data type within the numeric data type is called complex. Let's copy this right down here. Now, personally, this is not one that I've used almost ever, but it is one just worth noting. So you can do 12 plus, and let's say 3j, and if we do this, it's going to give us a complex. The complex data type is used for imaginary numbers. For me, it's not often used, but if you do use it, j is used as that imaginary number. If you use something like c or any other number, it's going to give you an error; j is the only one that will work with it.

Now let's take a look at Boolean values. So we'll say Boolean. The Boolean data type only has two built-in values: either true or false. So let's go right down here and say type true, and when we run this, it'll say bool, which stands for Boolean. We can do the exact same thing with false; that is also Boolean. And this can be used with something like a comparison operator. So let's say 1 is greater than 5, and let's check this; this is giving us a Boolean because it's telling us whether one is greater than five. Let's bring that right down here; this will give us a false, so it's telling us that one is not greater than five. And just as we got a false, we can say 1 is equal to 1, and this should give us a true.

So now let's take a look at our sequence type data types, and that includes strings, lists, and tuples. Let's start off by looking at strings in Python. Strings are arrays of bytes representing Unicode characters. When you're using strings, you put them either in a single quote, a double quote, or a triple quote. I call them apostrophes; it's just what I was raised to call them, but most people who use Python call them quotes. So right here we have a single quote, and that works well. We can do a double quote, and that works also, and as you can see, they are the exact same output. And then we have a triple quote just like this, and this is called a multi-line, so we can write on multiple lines here. So let's write a nice little poem. So we'll say, "The ice cream vanquished my longing for sweets. Upon this diet I look away; it no longer exists on this day." And then if we run that, it's going to look a little bit weird; it's basically giving us the raw text, which is completely fine. But let's call this a multi-line, and we're going to call this a variable multi-line, and we're going to come down here and say print. And before I run this, I have to make sure that this is run. So now let's print out our multi-line, and now we have our nice little poem right down here.

Now, something to know about these single and double quotes is how they're actually used. So if we use a single quote and we say, "I've always wanted to eat a gallon of ice cream," and then we do an apostrophe at the end, obviously something went wrong here. What went wrong is when you use a single quote and then within your text, within your sentence, you have another apostrophe, it's going to give you an error. So what we want to do is whenever we have a quote within it, we need to use a double quote. These double quotes will negate any single quotes that you have within your statement; they won't, however, negate another double quote. So you need to make sure you aren't using double quotes within your sentence. If you want to do something like that, you need to use the triple quotes like we did above. So we can do double double, and then let's paste this within it, and anything you do within these triple quotes will be completely fine as long as you don't do triple quotes within your triple quotes. We'll say this is wrong, so even though it's between these two triple quotes, it doesn't work exactly. Again, you just have to understand how that works; you have to use the proper apostrophes or quotes within your string. And just to check this, we can always say, "Here's our multi-line," we can always say type of multi-line, and that is still a string.

One really important thing to know about strings is that they can be indexed. Indexing means that you can search within it, and that index starts at zero. So let's go ahead and create a variable, and we'll just say a is equal to, and let's do the all-popular "hello world." Let's run this, and now when we print the string, we can say a, and we're going to do a bracket, and now we can search throughout our string using the index. So all you have to do is do a colon, and we can say five. What this is going to do is it's going to say position zero all the way up to five, which should give us the whole "hello," I believe. Let's run this, and it's giving us the first five positions of this string. We can also get rid of the colon and just say something like five, and then when we run this, it's actually going to give us position five, so this is 0, 1, 2, 3, 4, and then five is the space. Let's do six so we can see the actual letter, and that is our w. We can also use a negative when we're indexing through our string, so we could say -3, and it'll give us the l because it's -1, 2, and 3. We can also specify a range if we don't want to use the default of zero. So before we did 0 to 5, and it started at zero because that was our default, but we could also do 2 to 5. Let's run this, and now we go position 0, 1, and then we start at 2: l, l. Now we can also, also multiply strings, and we have this a "hello world," so we can do a * 3, and if we run this, it'll give us "hello world" three times. And we can also do a + a, and that is "Hello World hello world."

Now let's go down here and take a look at lists. Lists are really fantastic because they store multiple values. The string was stored as one value, multiple characters, but a list can store multiple separate values. So let's create our very first list list. We'll say list really quickly, and then we'll put a bracket, and a bracket means this is going to be a list. There are other ones like a squiggly bracket and a parenthesis; these denote that they are different types of data types. The bracket is what makes a list list. So to keep it super simple, we'll say 1, 2, 3, and we'll run this, and now we have a list that has three separate values in it. The comma in our list denotes that they are separate values, and a list is indexed just like a string is indexed, so position zero is this one, position one is the two, and position two is the three. Now, when we made this list, we didn't have to use any quotes because these are numbers, but if we wanted to create a list and we wanted to add string values, we have to do it with our quotes. So we'll say "cookie dough," then we'll do a comma to separate the value, and then we'll say "strawberry," and then we'll do one more, and this will just be "chocolate," and when we run this, we have all three of these values stored in our list. Now, one of the best things about lists is you can have any data type within them; they don't just have to be numbers or strings; you can basically put anything you want in there. So let's create a new list, and let's say "vanilla," and then we'll do three, and then we'll add a list within a list and we'll say "Scoops," comma "spoon," and then we'll get out of that list, and then we'll add another value of true for Boolean, and now we can hit Shift+Enter, and we just created a list with several different data types within one list.

Now let's take this one list right here with all of our different ice cream flavors. We'll say ice_cream is equal to this list. Now, one thing that's really great about lists is that they are changeable; that means we can change the data in here; we can also add and remove items from the list after we've already created it. So let's go and take ice_cream, and we'll say ice_cream.append, and this is going to append it to the very end of the list. We do an open parenthesis, and let's say "salted caramel." Now, when we run this and we call it just like this, it's going to take this list, add "salted caramel" to the end, and we'll print it off, and as you can see, it was added to the list. And just like I said before, let me go down here; we can also change things from this list. So let's say ice_cream, and then we need to look at the indexed position, so we're going to say zero, and that's going to be this "cookie dough" right here. We can say that is equal to, so we can now change that value. So let's call that "butter pecan." And now when we call it, we can now see that the "cookie dough" was changed to "butter pecan."

Another thing that you saw just a little bit ago is something called a list within a list, basically a nested list. So we had "Scoops," "spoon," true. Let's give this, and we'll say nested_ice_cream_list is equal to. Now when we run this, we now have this nested list. So if we look at the index and we say zero, we'll get "vanilla." If we say two, we'll get "Scoops" and "spoons." Now, since we have a list within a list, we can also look at the index of that nested list. So let's now say one, and that should give us just "spoon," and you can go on and on and on with this; you can do lists within lists within lists, and all of them will have indexing that you can call.

Now let's go down here and start taking a look at tuples. So a list and a tuple are actually quite similar, but the biggest difference between a list and a tuple is that a tuple is something called immutable; it means it cannot be modified or changed after it's created. Let's go right up here; we're going to say Tuple, and let's write our very first tuple. So we'll say tuple_scoops is equal to, and then we'll do an open parenthesis. Now, these open parentheses you've seen if you do like a print statement, but that's different because that's executing a function; this is actually creating a tuple, which is going to store data for us. So we'll say 1, 2, 3, 2, and 1. Let's go ahead and create that tuple, and we can just check the data type really quickly, and it's a tuple. And just like we saw before, a tuple is also indexed, so if we go at the very first position, which is a one, we will get the output of a one. But we can't do something like append and then add a value like three. If we do that, it's going to say "Tuple object has no attribute append," it's just because you cannot change or add anything to a tuple, just like we were talking about before. Typically, people will use tuples for when data is never going to change. An example for this might be something like a city name, a country, a location, something that won't change. They definitely have their use cases, but I don't think they're as popular as just using a list.

So now let's scroll down and start taking a look at sets. But really quickly, let me add a few more cells for us, and let's say sets. Now, a set is somewhat similar to a list and a tuple, but they are a little bit different in the fact that they don't have any duplicate elements. Another big difference is that the values within a set cannot be accessed using an index because it doesn't have an index because it's actually unordered. We can still loop through the items in a set with something like a for loop, but we can't access it using the bracket and then accessing its index point. So let's go ahead and create our very first set. So we're going to say daily_ice_cream_pints, then we're going to say equal to, and to create a set, we're going to use these squiggly brackets. I don't know if there's an actual name for those, if I'm being honest; I call them squiggly brackets, and that's what we're going to go with. We're to put in a 1, a 2, and a 3. So let's go ahead and run this, and let's look at the type, and as you can see, it is a set. Now, when we print this out, it's going to show us 1, 2, and 3, and those are all the values within our set. But if we copy this and we'll say daily_pints_log, this is going to be every single day, maybe I had different values. Now, when we run this and we do the exact same thing, now when we print this, it's going to have just the unique values within that set.

Now, a use case for sets, and this is something that I've done in the past, is comparing two separate sets. Maybe you have a list or a tuple, and you convert that into a set, and that will narrow it down to its unique values. Then you can compare the unique values of one set to the unique values in another set, and then we can see what's the same and what's different. So let's go down here and let's say wife's_ice_cream_daily; just copy this right here. We'll say is equal to; let's do our squiggly lines; let's do 1, 2; let's do just random numbers. So now this is my daily log, and this is my wife's daily log, and now we can compare these values. So let's go right down here; let's say print; we'll do my_daily_logs, and then we'll do this bar right here, and this is going to show us the combined unique values; it's basically like putting them all in one second set and then trimming it down to just the unique values. So we'll take wife's_ice_cream_daily_log, and when we run this, we actually need to run this first. When we run this, we should see all the unique values between these two sets, and so as you can see, 0, 1, 2, 3, 4, 5, 6, 7, 24, 31. So these are all the unique values between these two sets. We can also do another one, and instead of this bar, we're going to do this symbol right here, which I believe is called an ampersand; don't quote me on that, but when we run this, it's going to show what matches; that means which ones show up in both sets. So the only ones that show up in both sets are 1, 2, 3, and 5. We can also do the opposite of that by doing a minus sign, and this is going to show us what doesn't match, and so we have 4, 6, and 31. Now, where is our 24? That was in our wife's_ice_cream_daily_log; it's in this one, but we're subtracting the values on this one. So let's reverse, reverse this, and we'll say daily_ice_cream_pints_log, and let's run it. Now those are our other values, so we're taking the values of this, and then we're subtracting all the ones that are the same and getting the remaining values. And then for our last one, we can get rid of this, and we'll do this symbol right here, and this is going to show if a value is either in one or the other but not in both. So let's run this. So these values are completely unique only to each of those sets.

Now, the very last one that we're going to look at in this video is dictionaries. So let's go right down here; let's add a few cells, and let's say dictionaries. Now, I saved dictionary for last because this one is probably the most different out of all the previous data types that we've looked at. Within a data type, we have something called a key-value pair; that means when we use a dictionary, it's not like a list where you just have a value, comma value, comma value; we have a key that indicates what that value is attributed to. So let's write out a dictionary to see how this looks. So we're going to say dictionary_ice_cream, and just like a set, we use a squiggly line, but the thing that differentiates it is that in a dictionary we'll have that key-value pair, whereas in a set each value is just separated by a comma. So let's write "name," and this is our key, and then we do a colon, and this is then where we input our value. So we're going to say "Alex Freeberg," and then we separate that key-value pair by a comma, and now we can do another key-value pair. So we'll say "weekly_intake," and a colon, and we'll say "five pints of ice cream," do a comma, and then we'll do "favorite_ice_creams," and now what we're going to do is we're going to put in here a list. So within this dictionary, we can also add a list. We'll do "MCC" for mint chocolate chip, and then we'll add "chocolate," another one of my favorites. So now we have our very first dictionary. Let's copy this and run it, and let's just look at the type, and as you can see, it says that this is a dictionary. Let's also print it out. Now, if we want to, we can take our dictionary_ice_cream and say .values with an open parenthesis, and when we execute this, we'll see all of the values within this dictionary. So here's our values of "Alex Freeberg," five, "mint chocolate chip," and "chocolate." We can also say keys, and when we run this, all of the keys: "name," "weekly_intake," and "favorite_ice_creams." And we can also say items, so this key-value pair is one item, and this key-value pair is another item. Now, one difference between something like a list and a dictionary is how you call the index, but you can't call it by doing something like this where you just do a bracket, oops, and say zero. So this would, in theory, take this very first one, right, our very first key-value pair; that's going to give us an error. How you call a dictionary is actually by the key, so it doesn't technically have an index, but you can specify what you want to call and take it out. So we're going to say "name," and this is going to call that key right.

Here and when we run this, we'll get the value which is Alex Freeberg. One other thing that you can do is you can also update information in a dictionary, which we can't with some other data types. So for this, for the name it was Alex Freeberg, now let's say Ste Freeberg. And when we update that, I'm also going to print the dictionary. Get rid of this, so it's going to update Christine Freeberg in that value of the name. So let's go ahead and run this, and now it changed the name from Alex Freeberg to Christine Freeberg. We can also update all of these values at one time. So let's copy this, and I'm going to put it right down here. I'm going to say dictionary.cream.update, then we're going to put a parenthesis around these. So now what we're going to do is update this entire thing. Let me take this, say print this dictionary. Now we can update this to anything we want. So instead of here, I can say I'll say weight, and because of all that ice cream, I now weigh 300 lb. So let's run this, and as you can see, it did not delete our key value pair right here; instead, it just added to it. When you're using the update, we can't actually delete; that's the delete statement, and I'll show you that in just a second. But all we did was add this new value. It also is going to check and see if you changed anything with your key value pair. So we can go in here, here and change this value, and we'll say 10. So now when we run this, the value of this key value pair was changed. But let's say we do want to delete it. We'll say del, that stands for delete, part of this dictionary cream. And now let's specify the key, which will also delete the value with it. Well, let's specify the key that we want to get rid of, and let's say weight, and then let's print that again. And as you can see, the weight was deleted from that dictionary. So that is all we're going to cover in this data types video. Thank you guys so much for watching. I really appreciate it. If you like this video, be sure to like and subscribe below, and I'll see you in the next video.

Hello everybody, today we're going to be taking a look at comparison, logical, and membership operators in Python. Operators are used to perform operations on variables and values. For example, you're often going to want to compare two separate values to see if they are the same or if they're different within Python, and that's where the comparison operator comes in. Right here you can see our operators; you can also see what they do. So this equal sign, equal sign stands for equal. We have the does not equal, the greater than, less than, greater than or equal to, and less than or equal to. And honestly, I use these almost every single time I use Python, so these are very important to know and know how to use. So let's get rid of that really quickly and actually start writing it out and see how these comparison operators work in Python. The very first one that we're going to look at is equal to. Now you can't just say 10 is equal to 10. Let's try running that really quickly by clicking shift enter. It's going to say cannot assign to literal. That's because this is like assigning a variable; we're trying to say 10 is equal to 10, and then we can call that 10 later, but that's not how this actually works. What we're trying to do is to determine whether 10 is equal to 10, so we're going to say equal sign, equal sign, and then if we run that by clicking shift enter again, it's going to say true. Now if we put something else like 50 in there and we try to run this, it's going to say false. So really what you're going to get when you use these comparison operators is either a true or a false. If we take this right down here, we can also say does not equal, and we're going to use an exclamation point, equal sign, and that says 10 is not equal to 50, and that should be true. You can also compare strings and variables. So let's go right down here, and we're going to say vanilla is not equal to chocolate, and when we run this it'll say false. Now if it was the same, just like when we did our numbers, it should say true. And we can also compare variables, so we'll say x is equal to vanilla and y is equal to chocolate. And then when we come down here, we can say x is equal to y, and it'll give us a false, and we say x is not equal to y, and it'll give us a true. The next one that we're going to take a look at is the less than. So let's copy this one right up here, let's scroll down, and let's say 10 is less than 50. Now this will come out as true. Now let's say we put a 10 in here. Before, 10 was of course less than 50, but is 10 less than 10? No, that's false because they are the same. So if we want an output that is true, all we would have to add is an equal sign right here, and this would say 10 is less than or it is equal to 10, and now it's true. Of course we can say the exact same thing by saying greater than, so 10 is equal or greater than 10, that'll be true because 10 is equal to 10. We can also say 50 is greater or equal to 10, because 50 is obviously greater than 10. Now let's look at logical operators that are often combined with comparison operators. So our operators are and, or, and not. So if you have an and, that returns true if both statements are true. If it's or, only one of the statements has to be true. And the not basically reverses the result, so if it was going to return true, it would return false. I don't use this not one a lot, but I will show you how it works. So let's actually test that out. So before we were saying 10 is greater than 50, and of course this returned false. So now let's add a parenthesis around this: 10 is greater than 50, and we're going to say and, we'll do an open parenthesis, 50 is greater than 10. Now this statement right here is true, 50 is greater than 10, so we have a true statement and a false statement, but this and is going to look at both of them, and it's going to say they both need to be true in order to return a true. So let's try running this, and we still have a false. If we want it to return true, we're going to have to change this to make it a true statement. So 70 is greater than 50 and 50 is greater than 10. When we run this, it should return true. Now let's look at the or. So let's copy this and we'll say 10 is greater than 50 or 50 is greater than 10. Now this is a false statement and this is a true statement, so if even one of them is a true statement, the output should be true. And again we can do this even with strings, so we can do vanilla and chocolate. There we go. And vanilla is actually greater than chocolate because V is a higher number in the alphabetical order, so V is like 20 something whereas chocolate is three, right? So actually looks at the spelling for this. So if we say or here, it will come out true, and if we say and here, it should also be true because V is greater than C and 50 is greater than 10, so this should also be true. Now let's copy this right here and we're going to say not. So what we had before is 50 is greater than 10, that returned true, but now all we're doing is putting not in front of it, so instead of returning true, it's going to return false. So now let's take a look at membership operators, and we use this to check if something, whether it's a value or a string or something like that, is within another value or string or sequence. Our operators are in and not in. So it's pretty simple; if it's in, it's going to return true if the sequence with a specified value is present in the object, just like we were talking about. And for not in, it's basically the exact same thing; if it's not in that object. So let's start out by taking a look at a string. We're going to say ice_cream is equal to I love chocolate ice cream, and then we're going to say love in ice cream, and that will return true. So all we're doing is searching if the word love or that string is in this larger string. We could also just do that by literally copying this and putting this where this is, so we can check is this string part of this string, and it'll say true. We can also make a list, so we'll say scoops is equal to, and then we'll do a bracket, and we'll say 1, 2, 3, 4, 5, and then we'll say two in scoops. So all we're doing is searching to see if two is within this list, and that should return true. Now if we put a six here and we said not in, it will also return true because six is not in scoops, and that is true. And just like we did, we could also say wanted_scoops and we'll say eight, so I wanted eight scoops. So we can say wanted scoops in scoops, and this should return true because there's not an eight within the scoops that we wanted. And if we said in and we said we wanted eight, is that within our list that we created? And that's going to return a false. So that is a quick breakdown of comparison, logical, and membership operators. I hope that this was helpful. Thank you guys so much for watching. If you like this video, be sure to like and subscribe, and I will see you in the next video.

Hello everybody, today we're going to be taking a look at the if statement within Python. Now it's actually the if, elif, else statement, but that's a mouthful, so I'm just going to call it the if else statement. Now we have this flowchart, and I apologize for being blurry, but this is the absolute best one that I could find. Right up top we have our if condition. Now if this if condition is true, we're going to run a body of code, but if that condition is false, we're going to go over here and go to the elif condition. The elif condition or statement is basically saying, if the first if statement doesn't work, let's try this if statement. If this elif statement is true, it goes to this body of code; if it's false, it'll come over here to the else. And the else is basically, if all these things don't work, then run this body of code. Now you can have as many elif statements as you want, but you can only have one if statement and one else statement. So let's write out some code and see how this actually looks. Let's first start off by writing if, that is our if statement, and now we have to write our condition, which is about to be either met or not met. So we'll say if 25 is greater than 10, which is true, we'll say colon, and then we're going to hit enter, and it's going to automatically indent that line of code for us, and this is our body of code. So if 25 is greater than 10, our body of code will execute. So for us, we're just going to write print and we'll say it worked. Now if we run this, it's going to check, is 25 greater than 10? If that is true, print this. So let's hit shift enter, and it worked. Now let's take this exact code, we'll paste it right down here, and we'll say is less than, and right now this if statement is not true, so it's not actually going to work. As you can see, there's no output; there's nothing that happened really, but it did check to see if 25 was less than 10, but it just wasn't true. Now we can use our else statement, so we're going to come right down here and we're going to say else and we'll do a colon, and we'll hit enter again, automatically indenting, and we're going to say print, and we're going to say it did not work... So what it's going to do is it's going to come up here and check, is 25 less than 10? No, it's not, so this body of code is not going to be executed; it's going to go right down to this else statement. Now this else statement is going to be printed; there's no condition on this, so the if statement has a condition, 25 is less than 10; this has no condition, so if this doesn't work, if this is false, it's going to come down here, and it will run this body of code. Let's run this by clicking shift enter, and as you can see, our output is it did not work. Now let's go back up here and put greater than, because this is now true, it's going to say if 25 is greater than 10, print it worked, and then it's going to stop; it's not going to go to this else statement at all. So let's run this, and our output is it worked. So what if we have a lot of different conditions that we want to try? Let's come right down here; this is where the elif comes in. So really quickly, let's change this to a not true, a false statement. We're going to go down and say elif, and we're going to say if it is, and let's say 30, we'll say elif worked. So now it's going to check, is 25 less than 10? No, it's not. Let's look at the next condition, is 25 less than 30? And if it is, we'll print elif worked. So let's try running this, and elif worked. Now we can do as many of these elif statements as we want; we can do let's just try a few of them right here. So we'll say if 25 is less than 20, is less than 21, and let's do 40, and let's do 50. So we'll say elif, elif2, elif3, and elif4. Now if you look at this, the first one that is actually going to work is this 25 to 40 right here. Once this one is checked and it comes out as true, none of the other elif or else statements will work. So let's try this one; it should be elif3, and this one ran properly. Now within our condition, so far we've only used a comparison operator; we can also use a logical operator like and or or. So we can say if 25 is less than 10, which it's not, and let's say or actually and, we'll say or 1 is less than 3, which is true. If we run this now, it will actually work. So we can use several different types of operators within our if statement to see if a condition is true or not, or several conditions are true. There's also a way to write an if/else statement in one line if you want to do that. So we can write print, we'll say it worked, and then we'll come over here and say if 10 is greater than 30, and then we'll write else print, and we'll say it did not work, just like we had before, except now it's all occurring on one line. So let's just try this and see if it works. So it's saying print it worked if 10 is greater than 30, which it wasn't, so it went to the else statement and then it printed out our body right here. Although we didn't have any indentation or multiple lines, it was all done in one line. Now there's one other thing that we haven't looked at yet, and I'm going to show it to you really quickly, and that's a nested if statement. So when we run this, it's going to say it worked. It works because it says 25 is less than 10 or 1 is less than 3. Since this is true, it's going to print out it worked. But we can also do a nested if statement, so we can do multiple if statements as well. So we're going to hit enter and we'll say if, and we'll do a true statement here, so we'll say if 10 is greater than 5, let's do a colon, hit enter, then we'll say print, and then we'll type a string saying this nested if statement oops worked. Now let's try this out and see what we get. So it went through the first if statement, it said it was true, and it prints out it worked. This is still the body of code, so it goes down to this next if statement, and it says if 10 is greater than 5, we're going to print this out. And you could do this on and on and on; it can basically go on forever, and you can create a really in-depth logic, and that actually happens a lot when you start writing more advanced code. So I hope that this was helpful; I hope that you understand the if/else statement better; I hope that you understand how nested if statements work as well. Thank you guys so much for watching. If you like this video, be sure to like and subscribe below, and I'll see you in the next video.

Hello everybody, today we're going to be learning about for loops in Python. The for loop is used to iterate over a sequence, which could be a list, a tuple, an array, a string, or even a dictionary. Here's the list that we'll be working with throughout this video, and I have this little diagram right here which kind of explains how a for loop works. The for loop is going to start by looking at the very first item in our sequence or our list, and that's going to be our one right here. It's going to ask, is this the last element in our list? And it is not, so it's going to go down to this body of the for loop. Now we can have a thousand different things that can happen in the body of the for loop, as we're about to look at in just a second. Then it's going to go up to the next element and ask, is this the last element reached? So it'll be no again because we'll be going to the two, and then the three, and then the four, and the five. Once it reaches the five, it'll go to the body, the for loop, and then when it asks if that's the last element, the answer would be yes because it's iterated through all the items within the list, and then we would exit the loop and the for loop would be over. Now that may not have made perfect sense, but let's actually start writing out the syntax of a for loop so we can understand this better. To start our for loop, we're going to say for, and then we're going to give it a temporary variable for this for loop. So it's a variable; as it iterates through these numbers, it's going to assign the variable to that number. So for this one, we're just going to say number because it's pretty appropriate because these are all numbers, and then we're going to say in integers. Now right here, you can put just about anything; this could be the list, this could be a tuple, this could be a string even, but that is what we're going to iterate through. So we're saying for the variables, each of these numbers within this list of integers, and then we're going to write a colon. This is the body of code that's going to actually be executed when we run through and iterate through our list. So for our first example, we're going to start off super simple, and all we're going to do is say print, open parenthesis, and say number. As it iterates through the 1, 2, 3, 4, and 5, number becomes our variable that is going to be printed. So during that first loop, our one will be printed because that will be assigned right here, then through the next iteration, the two will be assigned and'll be put right here in each loop until the very end. So let's hit shift enter, and as you can see, it did exactly that. Now in this body, and I'll copy and paste this down here, in this body we really can do just about anything we want; we don't even have to use this variable number right here; we can just print yep if we wanted to. And what it's going to do is for each iteration, all five of those, every time it loops through, it's going to print off yep. So let's hit shift enter, and it printed it off for us. So really we weren't even using the numbers within the list; we were really just using it as almost a counter. Now let's copy this integers once again, let's go right up here, and let's go copy

This for loop that we wrote now we do not have to call this number. This can be anything you want; any variable name that you'd like to name it. We could call it jelly, and we can do jelly plus jelly. I think you're getting the picture, right? When it loops through that one, it's doing 1 + 1. When it loops through the two, it's doing 2 + 2. That is basically how a for loop works.

Now, for a dictionary, it's going to handle it a little bit differently. So let's create a dictionary really quickly. So we'll say ice cream dictionary is equal to; we're going to do squiggly brackets. So we're going to say name, and we're going to say colon. We need to assign our value for that item, so we're going to say Alex Freeberg. We'll do our next one separated by a comma, and we'll say weekly intake, and I'll say five scoops per week. The next one we will do is favorite ice creams, and for this one we're going to do something a little bit different. For this, we're going to have a list within this dictionary. So we'll say, within our list of my favorite ice creams, we'll say mint chocolate chip, and I'll just do MCC for that, and we'll separate that out by a comma, and we'll say chocolate. So now we have this dictionary, ice cream dict, and within it we have my name, my weekly intake, and my favorite ice creams with a list in there as well. Let's hit shift enter, and now we're going to start writing our for loop.

Now, the for loop is going to look very similar, but to call a dictionary, it's just a little bit different. So we're going to say for the cream in ice cream dictionary.values, and then we're going to do parentheses and then a colon. Now we're going to print the cream. So in order to indicate what we actually want to pull, we have to specify within the dictionary what we want. Are we pulling the item? Are we pulling the value? We need to specify this, so that's why we have this .values right here. So let's run this and see what we get. So as you can see, we are pulling in the values right here; that's why we're pulling in Alex Freeberg, 5, and mint chocolate chip & chocolate.

Now we are able to call both of those, both the key and the value. So let's go right down here, and we can do both the key and the value. So we can pull two things at one time, and we're going to do this by saying .items. So we could also do .key if we just wanted to do a key, but we want to do items, so we're going to do both of them. So we're going to go right down here and say for key and value in ice cream dictionary.items: print, and let's write key, and then we'll do a comma, and then let's give it a little arrow or something like that, uh, something like this, and then we'll do a comma, and we'll say value, and let's print this off and see what we get. So it's looping through, and for each key and value, it's saying here is the key, so that's the name; then we have weekly intake; then we have favorite ice creams. It's giving us a little arrow, and then we're also printing off the value. So we have name: Alex Freeberg, weekly intake: 5, favorite ice creams: mint chocolate chip and chocolate.

So now let's talk about nested for loops. We've looked at for loops; we understand how they work and why they do what they do, but what about a nested for loop, a for loop within a for loop? For this example, let's create two separate lists. Let's create flavors, and let's make that a list by making it a bracket. We'll do vanilla, the classic chocolate, and then cookie dough; all great flavors. So that's our first list, and then we're going to say toppings, and we'll do a bracket for that as well, and we'll say hot fudge, and then we'll do Oreos, and then we'll do marshmallows. Is that how you spell marshmallows? I think it's an "e"; that looks wrong. I might be spelling it wrong, but that's okay. So let's save this by clicking shift enter, and now we have our flavors and our toppings. So now let's write our first for loop. We're going to say for 1, as in our number one for loop, we're going to say in flavors, and we'll do a colon. We'll click enter. Now we can write our second for loop. So we're going to say for 2 in toppings, and then we'll do a colon and enter, and then we're going to say print, and we'll do an open parenthesis, and then we're going to say 1, so we're printing the 1 in flavors, and then we're going to say 1, comma, I'm going to say topped with, comma, 2. So what this is essentially going to do is we're going to say, for 1, we're going to take the very first 1 in flavors, and then we're going to loop through all of 2 as well. So we're going to loop through hot fudge, Oreo, and marshmallows, and once we print that off, then we will loop all the way back to Flavors and look at the next iteration or the next sequence within the first for loop. So let's run this really quickly and see what we get. So as you can see, it goes vanilla, vanilla, vanilla, and vanilla is topped with the hot fudge, the Oreos, and the marshmallows, and then we start iterating through our second one in our first for loop. So there's that hierarchy. So we're iterating completely through this one before we actually go to the very first for loop and start iterating through that one again. Now that is essentially how a nested for loop works. These nested for loops can get very complicated; in fact, for loops in general can get very complicated, the more you add to it and the more you're wanting to do with it, but that is basically how a for loop and a nested for loop works. Thank you guys so much for watching. Be sure to like and subscribe below, and I'll see you in the next [Music] video.

[Music] Hello everybody. Today we're going to be taking a look at while loops in Python. The while loop in Python is used to iterate over a block of code as long as the test condition is true. Now, the difference between a for loop and a while loop is that a for loop is going to iterate over the entire sequence regardless of a condition, but the while loop is only going to iterate over that sequence as long as a specific condition is met. Once that condition is not met, the code is going to stop, and it's not going to iterate through the rest of the sequence. So if we take a look at this flowchart right here, we're going to enter this while loop, and we have a test condition right here. The first time that this test condition comes back false, it's going to exit the while loop. So let's start actually writing out the code and see how this while loop works. So let's create a variable; we're just going to say number is equal to one, and then we'll say while, and now we need to write our condition that needs to be met in order for our block of code beneath this to run. So we're going to say while number is less than five, and then we'll do colon, enter, and now this is our block of code. We're going to say print, and then we'll say number. Now what we need to do is basically create a counter. We're going to say number equals number + 1. If you've never done something like this, it's kind of like a counter. Most people start it at zero; in fact, let's start it at zero, and then each time it runs through this while loop, it's going to add one to this number up here, and then it's going to become a one, a two, a three each time it iterates through this while loop. Now, once this number is no longer less than five, it'll break out of the while loop, and it will no longer run. So let's run this really quick by hitting shift enter. So it starts at zero, and it's going to say while the number is less than five, print number. So the first time that it runs through it is zero, and so it prints zero, and then it adds one to number, and then it continues that while loop right here, and it keeps looping through this portion; it never goes back up here to this line of code. This is just our variable that we start with, and then once this condition is no longer met, once it is false, then it's going to break out of that code.

Now that we basically know how a while loop works, let's look at something called a break statement. So let's copy this right down here, and what we're going to say is if number is equal to three, we're going to break. Now, with the break statement, we can basically stop the loop even if the while condition is true. So while this number is less than five, it's going to continue to loop through, but now we have this break statement, so it's going to say if the number equals three, we're going to break out of this while loop, but if this is false, we're going to continue adding to that number just like normal. So let's execute this. So as you can see, it only went to three instead of four like before because each time it was running through this while loop, it was checking if the number was equal to three, and once it got to three, this became true, and then we broke out of this while loop.

The next thing that I want to look at, and we'll copy this right down here, is an else statement. Much like an if statement, but we can use the else statement with a while loop, which runs the block of code, and when that that condition is no longer true, then it activates the else statement. So we'll go right down here, and we'll say else, and we'll do a colon and enter, and then we'll say print, and we'll say no longer less than five. Now, because this if statement is still in there, it will break. So let's say six, and then we'll run this, and so it's going to iterate through this block of code, and once this statement is no longer true, once we break out of it, we're going to go to our else statement. Now, as long as this statement is true, it's going to continue to iterate through, but once this condition is not met, then it will go to our else statement, and we'll run that line of code. Now, the else statement is only going to trigger if the while loop no longer is true. If we have something like this if statement that causes it to break out of the while loop, the else statement will no longer work. So let's say if the number is three, and we run this, the else statement is no longer going to trigger, so this body of code will not be run.

Now, the next thing that I want to look at is the continue statement. If the continue statement is triggered, it basically rejects all remaining statements in the current iteration of the loop, and then we'll go to the next iteration. Now, to demonstrate this, I'm going to change this break into a continue. So before, when we had the break, if the number was equal to three, it would stop all the code completely, but when we change this to continue, which we'll do right now, what it's going to do is it's no longer going to run through any of the subsequent code in this block of code; it's just going to go straight up to the beginning and restart our while loop. So what's going to happen when we run this is it's going to come to three; it's going to become three; it's going to continue back into the while loop, but it's never going to have that number changed to be added to one to continue with the while loop. This will basically create an infinite loop. Let's try this really quickly, and as you can see, it's going to stay three forever. Eventually, this would time out, but I'm just going to stop the code really quick. So if we just change up the order of which we're doing things, we're going to say there, and we're going to put this down here. So what it's going to do now, instead of printing the number immediately and then adding the number later, we're going to add the number right away, and then we're going to say if it is three, we're going to continue, and it's going to print the number. So let's try executing this and see what happens. So as you can see, we no longer have the three in our output. What it did was when we got to the number three, it continued and didn't execute this right here, which prints off that number. So that really is the basics of the while loop. I hope that this was helpful. I hope that you learned something in this video. If you did, be sure to like and subscribe below, and I'll see you in the next [Music] video.

Hello everybody. Today we're going to be taking a look at functions in Python. A function is a block of code which is only run when you call it. So right here we're defining our function, and then this is our body of code that when we actually call it is going to be ran. So right here we have our function call, and all we're doing is putting the function with the parenthesis; that is basically us calling that function, and then we have our output. Throughout this video, I'm going to show you how to write a function as well as pass arguments to that function, and then a few other things like arbitrary arguments, keyword arguments, and arbitrary keyword arguments. All of these things are really important to know when you are using functions. So let's get started by writing our very first function together. We're going to start off by saying def; that is the keyword for defining a function. Then we can actually name our function, and for this one we're just going to do first_function, and then we do an open parenthesis and then we'll put a colon. We'll hit enter, and it'll automatically indent for us, and this is where our body of code is going to go. Now, within our body of code, we can write just about anything, and in this video I'm not going to get super advanced; we're just going to walk through the basics to make sure that you understand how to use functions. So for right now, all we're going to say is print; we'll do an open parenthesis; we'll do an apostrophe, and we'll say we did it, and now we're going to hit shift enter. And this is not going to do anything, at least you won't see any output from this. If we want to see the output, or we actually want to run that function, and some functions don't have outputs, but if we want to run that function, what we have to do is just copy this and put it right down here, and now we're going to actually call our function. So let's go ahead and click shift enter, and now we've successfully called our first function. This function is about as simple as it could possibly be, but now let's take it up a notch and start looking at arguments. So let's go right down here, and we're going to say define number_squared; we'll do a parenthesis and our colon as well. Now, really quickly, when you're naming your function, it's kind of like naming a variable; you can use something like X or Y, but I tend to like to be a little bit more descriptive. But now let's take a look at passing an argument into a function. The argument is going to be passed right here in the parentheses. So for us, I'm just going to call it a number, and then we're going to hit enter, and now we'll write our body of code, and all we're going to do for this is type print and open parenthesis, and we'll say number, and we'll do two stars, at least that's what I call it, a star and a two, and what this is going to do is it's going to take the number that we pass into our function, it's going to put it right here in our body of code, and then for what we're doing, it's going to put it to the power of two, and so when the user or you run this and call this function, this number is something that you can specify; it's an argument that you can input that will then be run in this body of code. So let's copy this right here, and then we'll put it right down here into this next cell, and we'll say five, and so this five is going to be passed through into this function and be called right here for this print statement. Let's run it, and it should come out as I believe 25. That is my fault; I forgot to actually run this block of code, so I'm going to hit shift enter. So now we've defined our function up here, and now we can actually call it. So now we'll hit shift enter, and we got our output of 25. Now, now in this function we only called one argument, but you can basically call as many arguments as you want; you just have to separate them by commas. So let's copy this, and we'll put it right down here. Now we'll say number_squared_custom, and then we'll do number and then we'll do power. So now we can specify our number as well as the power that we want to raise it to. So instead of having two, which is what you call hardcoded, we can now customize that, and we'll have power power. And now when we call this function, we can specify the number and the power, and both of those will go into this body of code and be run, and we can customize those numbers. So let's copy this, and we'll say 5 to the power of 3, and let's make sure I ran this, so let's do shift enter, and now we will call our function, and let's hit shift enter, and we got 5 to the power of 3, which is 125. And just one last thing to mention is if you have two arguments within your function and you are calling it right here, you have to pass in two arguments; you can't just have one. So if we have a five right here, it's going to error out; we have to specify both arguments for it to work.

Now let's take a look at arbitrary arguments. Now, arbitrary arguments are really interesting because if you don't know how many arguments you want to pass through, if you don't know if it's a one, a two, or a three, you can specify that later when you're calling the argument, so you don't have to do it upfront and know that information ahead of time. So let's define our function. So we're going to say define, and then we're going to say number_args, and we'll do an open parenthesis and a colon. Now, within our argument right here, typically we would just specify here's what our argument will be; it will be number, or it will be a word, right? But what we're going to do is something called an arbitrary argument, so it's unknown, so we're going to put star, and then we'll say args. Now, you will see something exactly like this typically if you're looking at tutorials that'll have *args in there, or if you're looking at just a generic piece of code, this is what it will look like, but for us we're going to actually put number. Again, we have the star and then we have our arbitrary argument right here, and then we'll hit enter, and we're going to say print, open parenthesis, and this is where it's going to get a little bit different. So we're going to say number, and then we're going to do an open bracket and let's say zero, and then we'll do that times, and then we'll say number again with a bracket of one. In a little bit, once we run this, and then we call this number_args function right here, we're going to need to specify the number zero and the number one that's going to be called. So let's go ahead and run this, and then we are going to call it, and let's say 5, comma, 6, comma, 128. So right up here we did not know how many arguments we were going to pass through; it could be five, it could be a thousand. We could also call in a tuple, and that's what this is right here; we're calling in a tuple. So what it's going to do now is when it calls this number, it's going to call the very first within that tuple, which will be that five, and then it'll also call in this number, which will be the first position, which is the six. So let's hit shift enter, and it's going to multiply these numbers together, so 5 * 6 is equal to 30.

Said, this is a tuple, so we don't actually have to write out these numbers like we just did. We can pass through a tuple when we are actually calling this function. Let's do that right up here. Let's just create um, let's call it argTuple, and we'll do open parentheses, and we'll do the same numbers. Let's just copy it, make it easier. And now we've created this tuple right here, which we can then pass in. And this is a lot more handy, a lot more specific, and this is most likely how someone would do something like this. But let's now create this. And now we can copy argTuple and pass it through. Now, really quickly, this is going to fail, and I'm doing that on purpose, but I want to show you what you need to do in order to pass through this tuple. So right now, it's going to say "Tuple index is out of range." All you have to do in order to use this is you have to specify a star before it, just like you did when you're creating your argument up here. You have to put a star in front of argTuple that we just passed through. And now let's try running this, and now it works properly.

Now, the last two things that we're going to look at are keyword arguments and arbitrary keyword arguments. There are more things that you can learn and do within functions, but again, I'm just trying to teach you the basics to make sure that you understand how they work. So let's go right up here, and a keyword argument is kind of similar to this right here. And let's actually copy this and put it right down here. Now, a keyword argument is very similar in that you're going to specify your arguments right here, but what we did up here—let me bring this down—when we actually called the function, what we did was we just put in a five and a three. And when we did that, it automatically assigned number to five and power to three, and that's totally fine, and you can do that. But if you want a little bit more control, you can use a keyword argument. So right here, we could say power = 5 and number = 3. So I just switched it around; right, number was assigned to five and power was assigned to three, but I just switched it to show you how this might work. So let's run both of these, and now it's 3 to the power of 5, which is 243. So that essentially is a keyword argument; again, it just gives you a little bit more control. You don't have to put them in specific positions like if you're just calling multiple arguments.

Now let's come right down here. We're going to create basically another custom function. Uh, so for this one, we're going to write `define number_bar`, and then we'll do an open parenthesis, a colon, and enter. And what this one is is this one is a keyword argument or an arbitrary keyword argument. Now, to specify an arbitrary argument, all we did was a star and then we input number. But if we're doing a keyword argument, we actually have to have two stars right here. So let's start taking a look. And again, if you're doing arbitrary, it means we don't really know how many keyword arguments we want to pass into our function, so we're just going to put `*number`. And then later within our body of code and when we're calling it, we'll be able to specify it. And just like the arbitrary argument before, the arbitrary keyword argument means we really just don't know how many keyword arguments we're going to need to pass into our function. So to demonstrate this, let's write `print`, do an open parenthesis, and we'll say `'my'`, oops, need to do an apostrophe, `my number is`, we'll do just like that, little space, and we'll say `+`. And this is kind of where it gets a little interesting or a little bit more tricky. So we're going to say `number`. So this is us calling our number, and then we're going to do a bracket, and then I'm actually going to go to calling the function. It's a little bit backward or a little bit different than what you might think, but when we're calling it, what I'm going to do is I'm going to say `integer =`, let's just do some random number. Now, when we're calling that keyword within our body of code, what we're going to do is we're going to actually type out `integer` just like this. And this looks a little bit different, but what this allows us to do is we can put as many keyword arguments in here as we want later, and I'll show you in just a second. But for us, we're just creating this key and this value when we are calling it within the function. So now when we create this and we run this—oh, whoops, I forgot this has to be a string—um, so let's run this again. Now we will say `'my number is'`, then we're—we're going to add—we'll say `+`, and this isn't going to look great, but we'll say `'my other number'`, because this will all be in the same line; that's okay. `'my other number'`, and then we'll say `number`, and we can specify again what we want in there. So now we can go down here to where we're calling it, we'll put a comma, and we'll say `integer2 =`, we'll do a random number, and then we'll put in `two` right here, and then we'll add `+` right here so we don't error out. We'll create this, we'll run this, and as you can see, both numbers were passed through. Again, the syntax is terrible, but now you can see that you have this arbitrary keyword argument right here, and all we have to do is put `number`, `number`, and we can pass through as many of these arbitrary keyword arguments as we want, as long as we just specify within our function when we're calling it.

So that's all we're going to look at in today's video on functions. There are, of course, other things that you can do within functions, and it can get a little bit more advanced, but I wanted to show you the basics, the meat and potatoes of things I definitely think you should know in order to get started using functions. I hope that you were able to understand functions better because of this video. If you did, be sure to like and subscribe below, and I will see you in the next video.

Hello everybody. Today we're going to be talking about converting data types in Python. In this video, I'm going to show you how to convert several different data types, including strings, numbers, sets, tuples, and even dictionaries. So let's start off by creating a variable. We'll say `num_int = 7`, and we can check that data type by saying `type`, and then inserting our variable `num_int`, and that will tell us that our data type for this variable is an integer. Let's go ahead and create another one. We're going to say `num_string =`, and for this one we'll also do a seven, but let's check the type, and we'll do an open parenthesis, and we'll say the type of `num_string`, and that one is a string. Now let's say we wanted to add those. We'll say `num_sum`, so the sum of `num_int` + `num_string`. Now, when we're adding these two values, it is not going to work; it's going to give us an error, and it's going to say "unsupported operand type(s) for +: 'int' and 'str'". So it cannot add both an integer and a string. What we need to do in order to add these two numbers is to convert that string into an integer. So let's go right up here, let's add another cell, and let's say `num_string_converted =`, and we want to convert it into an integer. So all we have to do to convert it into an integer is type `int`, and then we're going to say `num_string`, and that is as easy as it's going to get. All we have to do is say `integer` with our `num_string` inside of it, and then it's going to convert it. And we can even check it right after by saying `type num_string_converted`, and let's run this, and now we can see that it was converted into an integer. So now let's add that `num_string_converted` right here. Let's copy and replace that string with the string converted, and let's actually print out that `num_sum`, and it worked properly. Now we did not specify what type of value this `num_sum` was going to be, but because it was two integers in here, it's going to automatically apply that data type of integer to that `num_sum`.

Let's go right down here, and now let's look at how we can convert lists, sets, and tuples. So now let's say we have a `list_type`, and that's equal to `1, 2, 3`, and we can check it again by saying `type`, and that is a list. Let's say we want to convert it to a tuple; it's fairly easy. All we're going to do is write `tuple`, say `list_type`. That `list_type` is now going to be a tuple, and we can check that by saying `type`, and wrapping it around this tuple, and it shows us that it is converting that list into a tuple. Now we can also convert a list into a set, but it may change the actual values within it. Let's check that out really quickly. So let's say we have this list, and let's add a few more values to this, just like that. Now let's say we want to convert it to a set. So we're going to run this, and we'll say `set(list_type)`, and let's try running this and see what the output is. So this is something that you really need to be aware of when you are converting data types, because `set` does not act the same as a list. A set is basically going to take the unique values in the list and convert it to a set, and it fundamentally changes the data that was in that original list. And just to check the data type, we can say `type`. I'm just doing this for all of them, and as you can see, that is now a set.

Now let's go down here and take a look at dictionaries. Now let's say we have a dictionary called `dictionary_type`, and we'll do a squiggly bracket, and we'll say `name: Alex`, then we'll do `age: 28`, and then we'll do `hair:`. So really quickly, let's take that `dictionary_type` and just confirm that it is a dictionary, and it is. And now what we're going to do is take a look at all of the items within that dictionary. So we're going to do `dictionary_type.items()`, open parenthesis, and this is going to show us all the items within it. Now we can also take this and look at something like the values, and when we run that, these are our values. So within our dictionary, we have items, and that's what this is right here; this is one item, and then within that we have our values, which are right here: Alex, 28, and Na. And then we have something called a key, and this is the key; the name, age, and hair are all keys, and we can look at that by saying `.keys()`. So let's say we want to take all of the keys and put that into a list. What we're going to do is we're going to take this right here, say `list()`, we'll do an open parenthesis, we'll type that in right there, so it says a list, and we're converting these keys into a list, and let's run that, and now this is a list, and let's just check the type as well, just to confirm, and as you can see, it was converted properly into a list. And we can do the exact same thing with values, and the values can also be converted into a list. Now we can also convert longer strings that aren't just numbers like we did above in our very first example. So let's do `long_string`, and we'll say `"I like to party"`. Now we're going to take this string and we're going to say `list(long_string)`. So we're going to convert this string into a list, and let's see what happens. So it took every single character in that string and put it into a list, and we could also do a set as well; that one's a lot shorter because it's only looking at unique values. So that is how you convert data types in Python. Thank you guys so much for watching. I really appreciate it. If you like this video, be sure to like and subscribe below, and I'll see you in the next video.

Hello everybody. Today we're going to be working on building a BMI calculator in Python. Now, before we get started, I want to show you this BMI calculator that I found online, and it shows you the basic calculation that they use, and that's the one we're going to use in this video. And they also have this calculator right down here and some ranges that we can use for our calculator as well. So for reference, I weigh about 170; I'm about 5'9". Let's calculate this. So I'm about a 25.1 BMI, which falls into the overweight category; that's unfortunate, but we can see exactly how this works and how ours should work when we actually build it. So we're going to kind of reference this throughout the video. So let's go right over here to our BMI calculator. We need to calculate weight and height, and then run this calculation right here. So let's go ahead and copy this, and we're going to put it right down here. Here. And so now we have our calculation. So what we need is we need input from a user, and there is an input function within Python that we're going to be using. So let's actually give me a few more cells. So the first thing that we need to calculate is their weight. Let's type out weight right here. We'll say `weight =`, and this is where we'll use our input function. So we'll say `input()`, and when we actually run this, it's just going to give us this blank square, or a user can input something. We'll say "Alex". So this is our output; is what the actual user input, and it does save it to this variable. So if we say `print(weight)`, it will still print out "Alex". Now this is where we want the user to, just like we did before, where they'll input their weight. So we want to kind of give them a prompt for this. We'll put a string in here, so I'll do a double quote, and then I'll say `"Enter your weight in pounds: "` So now when we do this, it'll say "Enter your weight in pounds". I'll say 170, and then when we run this, it does store that. Now let's do `print(weight)`. I should have saved it weight again. Oops. Now it's only storing the value of 170; it's not actually storing this string right here. So that's really important for when we do our calculations later. Um, I'm going to—I'm going to save this right down here because I'm sure I'm going to use that later. Um, so we have that it's working. Now we need to also do our height. So let's copy this, and we'll put it right here, and we'll do `height`, and `"Enter your height in inches: "` So now for this one, if we hit enter, it's actually running. Let's stop it really quick and interrupt it. Let's try running this. So it's going to say "Enter your weight in pounds". That's the first input. Say 170, and then when I hit enter, it's going to prompt me for that second input. And so in inches, 5'9" is 69 in, and then I can hit enter again, and now we have both of our inputs. Now we need this calculation right down here, and just like that. So now we have `weight` in pounds * 703 divided by `height` in inches * `height` in inches. So we actually have `weight`, and it's already written in there, but I'm just going to do like this. We'll do `weight * 703`, so that's pounds there, our weight in pounds * 703, divided by now we have our `height` in inches * the `height` in inches. So this is our calculation right here. So let's do this exact same thing. Let's run this, and this * of course is not going to work. Whoops, we need to do our star for both of these. All right, now this is our calculation. So let's run this. So we have 170, and that's pounds, and inches was 69. Hit enter, and it says "TypeError: can't multiply sequence by non-int of type 'str'". Ah, that's because these are being stored in strings. They—right down here, I do, and we'll do `type(height)`. We run that, this is actually a string. So we want to change that because we don't need that anymore. That—so we don't want it to be a string; we need those to be integers or floats, or really anything besides a string; it just needs to be numerical, uh, so integer, float, really. So let's do `int()`, and we'll wrap that input in it, and we'll do the same thing for this one. Now we have an integer for our weight, an integer for our height. So now when we're running this calculation, it should work properly. Let's run this again. Our pounds are 170, our height is 69 in, and it's not giving us our output because we're not printing anything. Okay, so I just need to do `print(BMI)`. So let's try this again. 170, 69, and there is our BMI, 25.1. So it worked the exact same as this one. So they input—well, we input our height, we inputed our—or we inputed our weight, we inputed our height, and then it calculated our BMI.

The next thing that we need to do is we need to kind of give the user some context: Is that good? Is their BMI within a good range, a bad range? We don't know, uh, so let's go ahead, and I'm going to see if I can copy this—know if this will work or not. Let's go ahead and copy this right down here. Perfect. So what we now need to do is we need to say, okay, if the user has given us this input, we want to give them—or tell them if they are a normal weight, overweight, obese, severely obese, anything like that, and we have these ranges, so that should help us out quite a bit. So let's just write our `if` statement, and then we'll include it up here, but let's go down here, and we'll say `if`, and then we'll do `BMI`, and let's just say `BMI > 0`. So if it's greater than zero, if they had any input where the BMI was not zero, which should be every time if they do it properly and they don't, you know, put a string in there or something, or type out 40, which maybe we should make a prompt for that, if that happens, then we can say `if`. We'll do `BMI`, and now we need to give that first range, so this range right here. So if it's under 18.5, so we need to do a less than. So if it's less than 18.5, and it just says under, it doesn't say under or equal to, so I'll keep it at 18.5. So if it's under 18.5, then let's give kind of the output. We'll say `print()`, and the output or the basically the prompt is "underweight". So we'll just say `"You are underweight"`. And just like that. Um, then we're going to pass several `elif` statements through here. Well, let's just say `else`. I guess this would be like if they are—if they don't input something properly, if something messes up, maybe I—we could write something like—um, `print("Enter valid inputs")`, or something like this, or we can always change that. But let's really quickly—let's run this. Okay, so I'm not in that range. Uh, let's make the next one, so then I can be within a certain range. Oops, and we need—we should need one—one more minimum. So we'll say `elif`. `elif`. These next two are this 24.9, so it's going to check this one first. So if it's 18.5 or below 18.5, it's automatically going to print this one. So this next one, we don't have to do like a range or anything; we can just say if it's below—if it's between 18.5 and 24.9. So this one actually should be less than or equal to. Um, this one is "normal". Oh, whoops, 24.9. So this one is 24.9. This one is going to say `"You are normal weight"`. So let's run this now. Let's see. BMI was 25.1. Oh guys, I'm just messing up here. I apologize. All right, this is the one that I was part of. So now it's going to be—I'm part of the overweight crowd now. Now let's run this, and now our prompt is "You are overweight," cuz remember...

The BMI was saved right here as 25.1. Down here, if we run through this, it's saying, "No, you're not in..." Oops, get rid of that. "No, you're not in under 18.5. You're not under 24.9. If you're under 29.9, you are overweight." So that did work properly; that's really good. And I don't think I want this to be our output for person because we're going to add this up here. It's just going to give us the BMI, and then the output is going to say, "You are overweight." Uh, let's make it a little bit more customized. Um, I'm going to say `name = input`, and then we'll say, "Enter your name." So it'll be "Enter your name." We'll do Alex, 70, 69. There's our BMI. Now it's going to run through this logic, or it will run through this logic, just a second when we actually finish this. So then we have 34.9, and let's do one more. Oops. And then this one's going to be for 39.9. So this one was overweight; this one is obese, severely obese. So we'll say "severely" – that you spell it – "obese," and then anything that's over that, 40 and over, so if it's not this one, anything else should be "morbidly obese." So actually, this `else` statement right here should say, "Uh, you are severely obese." This is going to say "morbidly obese." Now I added that name up here because I wanted to add that down below actually. So we're going to say `name +`, and then we'll do like a comma, "You are underweight." So it'll be a little bit more personalized. Uh, I think it'll, I think it'll be a nice touch; I really do. We'll do it like this, and we'll say "You," and let's go back and do that to all of them. And let me see how quickly I can do this. Oh, whoops, what did I do? Get rid of that. `name + u` like that. Geez, you guys are seeing me mess up. A `name + you`, and then `name + you`. So now let's run this, and now it's a little more personalized. It says, "Alex, you are overweight." So this is all really good. Now this is an `if` statement. Um, what we had done before, I think, is actually what we should put right down here. So we'll say `else`, and then if that doesn't work, we'll say, "What do we say? Enter valid input." We'll just put that. Um, and let, let me see if I can test this out. Don't, I don't know if this will error out or if this will even work. Let me just see if I can mess with it and see if I can get it to work. Actually, let's copy this. We're going to copy this whole thing; we're going to include it right here, and now we have basically our entire calculator. So, um, let's run this. "Enter your name," we'll say Alex. "Enter your pounds," 170. "Enter your inches," 69. And then it's going to say, "25.1, Alex, you are overweight," and that's perfect. We could even go as far as adding like some feedback. We say, "You are overweight," and then it would be a period, and we could say, "Um, you need to exercise more. Stop sitting and writing so many Python tutorials." So now if we run this, we'll do Alex, 170, 69. It says, "Alex, you are overweight. You need to exercise more and stop sitting and writing so many Python tutorials." Period. And that's it. This is the entire project. Um, you can go a ton farther. You can include much more complex logic. You could even build out a UI to create your own, you know, app just like this, where it has this input and this UI. You can build that out with in Jupyter notebooks with Python. Um, but that's not really what this tutorial is for. This is just to kind of help you um think through some of the logic of creating something like this. So you know, I hope that this was helpful. I hope that this was fun. I like creating stuff like this. We have two other projects that we're going to do, and maybe I'll include more, but we have two right now that I have planned. Um, and I hope those, those are helpful. This is probably our easiest one, and they'll get a little bit more difficult in the next projects. So I hope that this was fun. I hope that this was helpful, and that you can now kind of utilize those Python skills that you've been working on. If you like this video, be sure to like and subscribe below, and I'll see you in the next [Music] video.

Hello everybody. Today we're going to be creating an automatic file sorter for your files and File Explorer. Now, out of all the projects that we've done in this series so far, I think this one might be the most difficult, but I also think this one is the most cool because it has some real-life applications. So without further ado, let's take a look at some files that we have right down here in my File Explorer. So I have this beautiful picture of Rosie, uh, right here. This is a PNG file. I have a CSV file and a text file, and I want to sort all of them into their own folders depending on what kind of file it is. So if I go right in here and I click on this one, I go to properties, I can see that this is a PNG file. Um, if I go into this one, I don't need to, but if I go into this one, it's a CSV file, and of course, this one is a text file. So I want three separate folders in here, and I want them to automatically go into those folders without me having to drag and drop and going and clicking. Now, we only have four files here, but imagine if we have thousands of files, how much time that could save us. So let's get out of here and let's start writing our code. So we're going to say `import OS, shutil`. Now `OS` obviously stands for operating system; `shutil`, uh, I don't know what it actually supposed to stand for, but what it will allow us to do is do some high-level operations on our files in File Explorer. So we're going to go ahead and import those. And now that we have those imported, uh, something that's going to be very important for us to have throughout this whole thing, and this is anytime I'm working with like directories or something like this, we want to get this path down. So I'm going to go ahead and copy this path, and we're just going to say `path =`, and we'll do this right here. So let's run this, and I need to put an `r` right here to make this a raw text. Um, so when you don't have the `r`, uh, it's going to read in these, you know, these backslashes and these colons and different stuff. If we do `r`, it's just going to read it in as the raw string, and that's what we want. So here's what we need to do. There, there's a few different things that have to happen when we are writing this out. One thing is is we need to go in here and we need to see this path, and we need to see, "Are there folders in here already?" Um, if not, we need to create a folder. So that's one of the first things that we need to do. The next thing that we need is it needs to check each of these files individually, identify what kind of file it is, and then put it into the correct folder. So we have to create the folder, then check these, and then place it into the correct folder. So let's go right out of here. So what we're going to start doing is we're going to start working with these paths and these directories, and some of these things you may never have seen before, but that's okay. I'll try to explain it as I go through. So the first thing that we're going to write is `os.listdir`, uh, and what this is actually going to do is show us all the files in there. We're going to say `path`, so it should show us all the files within `path`. And so here are our results. So we have the "data professional results," "fake text file," our image, and our other image. So this is actually showing us what files are in that path, and that's super important because we're probably going to have to loop through this in some way later. Um, I wrote this all out before, so I kind of remember, but I'm doing this all off the top of my head, so I guarantee you throughout this I'll make some mistakes. But what we now need to do is we need to create folders or check if there's a folder and create it if it isn't there. That's um the next step that we need to take. So let's go right down here, and we want to check if this path exists already. So if that folder already exists, so we're going to say `os.path.exists`. So this is going to check, "Does this path, just like this path up here, does it already exist?" And then we're going to do an open parenthesis; we'll say `path`. So that's our path. Now we need to add a folder name to this. Um, we could hardcode it, so we could do `+`, we could say "CSV files," and that could work. So it would say, "Does this path already exist?" And we can try running this, and it's going to say "False," so this doesn't already exist. But the thing is is we need to create three separate paths, so we could do this by just hardcoding it in by saying "CSV files," "image files," um, and "text files," or we can just put this all in a list and loop through it. I think it's just going to be easier to do that, or I don't know, visually it's going to be easier. So we'll do `folder_names =`, and we'll create a list. So I think I want to call it "CSV files," comma, um, "image files" or "PNG files," whatever you want to write, and then we'll do "text files." Do "text files," and then we can go right down here, um, a little `for` loop. Uh, I think what we'll do, actually, let's write `folder_names`. Then we can put something like, uh, let's write "Loop," why not. So a little trick for the `for` loop is you're going to say `for`, and we'll say `Loop`, and we'll just do a range because we want it to basically go through here. We don't want it to actually give us these file names; we just want it to count 0, 1, and 2. So if we do `range` from 0 to 2, 0, uh, 0, 1, 2, that should work. If we do um this, then when it loops through, it's going to call `folder_name` and say 0, which would be "CSV files," "image files," and "text files." Um, so let's, yeah, I need a colon. Let's run through this really quickly. Shouldn't do anything, but what we can do now is we can say, "Okay, if this does not exist, what we can do is actually create it." So we'll say `if not`, so if this does not exist, then what we're going to do is take this, and we'll say `os.makedir`, and we'll do just like that. Um, I think it's `makedirs`; I can't, I think that's correct. Um, so let's test this out really quickly. Let's see if this works. And "invalid syntax," I, I need a colon. Okay, so I just ran this. Let's see if it did actually make those folders. Let's refresh it, and it didn't. So let's just print this off. Um, so `if not`, let's just print, let's see, does this actually work? Let's do `if`. Ah, okay, so I think I know what might be happening. I think it's giving us, it actually be, let, let's check this really quick. Go to "Python tutorials." Oh, no, I think it's creating, yeah, it's creating these "Python tutorial images" right here. Whoops. Okay, so I just figured it out. Um, let's go back into "Python tutorials," don't take a look at any of those notebooks; those are secret. Um, we were creating them in the wrong place, um, and that's because of this right here. We need a backslash, so we need to actually include a backslash right here, here in this path. We didn't have that. "E y scanning string literal." Okay, so this backslash could cause an issue. Let's see if I can do forward slashes on all these. Just stick with me, guys. I might cut this out; I might not. We'll see if this is important. Just going to keep talking while we're doing it. Um, let's run this. Okay, so now that we're doing these forward slashes, we're still checking. Let's make sure we can still check those files. Good. Now when we loop through this, I'm not going to, well, yeah, I can print it off; doesn't matter. I'm going to print it, and we'll see if that name works, and then we're also going to, um, uh, I said `if`, so if it exists, then make it. No, no, no. So `if not`, I think the `not` did make sense; we just weren't sure. We had to do some um checking. So if it exists, then we're going to create it, and we'll keep the print in there because it doesn't really matter. So it's going to create the CSV and image, but didn't create the text. Let's see. Okay, let's, I don't know why this would work, but let's run it. Okay, so I think I just had the wrong range. So now we have our images all through, or we have our folders, all three folders. Now we need to write a script that will read in these and check and see what kind of file it is and place it into the correct folder. So let's come right down here and let's see what we need to do. So now I think we need to use this right here. Um, I think we need to loop through this to be able to check each one. So we need to name this, so we'll just do, um, `file_name =`. Run that. So now we have this `file_name`, um, and what we can do is loop through this. So let's say, let's say `for file in file_name`. So we're going to loop through this. Now when it goes through, it needs to check the, it's going to check the file path, and in the file path, it'll say ".txt," ".CSV." Let's say, um, if I think it should be `CSV`. Let's test it on this one, but if `CSV` is in `file_name`, or actually it's `file`, so if, if it's in `file` and not in, oh, not, not, `not in`. If it's also not in this, I believe, because we're going to check, we're going to check each of those folders. So we're going to loop through, and it's going to check and see if the `CSV`, so if that string is in the file, then what we want to do is check that it's also not in here. That's actually just the folder. We also need, also we're not doing that loop anymore. Um, um, okay, I'm sorry, I'm talking this through; I'm figuring it out as I go because I may have forgotten some of this. So we're going to say this, that's the "CSV files," so we need to check this one. Um, let's do it like this. Oops. Okay, so it's going to check to see if "CSV files," and I think it needs that in between it. So it's going to say the path, so there's our path plus slash "CSV files." Actually, no, it needs to be like this. CU, we're going to check that. Then I got it all right; I figured it out now. Then we're going to check if this file is in there. Yeah, so that's right. So it says, "If the CSV is in the file," which is right, where am I looking? Oh, `file_name`. So if it's in that list of the actual files, which is all of these, if we find "CSV" in any of these files and it's not already in here, so it's going to say `path + "CSV files"`. Did I say "files"? Yeah, "CSV files" plus `file`. Okay, that all looks correct. So if it's not in there, we're going to use `shutil.move`. Now this is how we actually move the file. It gives us the ability to move what we want. Then we'll say `move`. We need to take it from our initial path to our new path. So we're going to specify, we'll separate by comma. We need to specify its original path, which it should just be this without this. I think it should be `file`, because this is where it is now. It's in the FI, this path with that file name. Then we need to say we want to move it to here. That is what we want to do. Um, yeah, so let's check it with just this one and see if it works. Okay, it ran through it. Let's go check. Aha. Now that CSV file is gone. Perfect. That is exactly what we want it to happen. Now we can just recreate this for, um, for both our PNG files, our image files, and our text files. So we'll say `elif`, and `elif`, and let's do "PNG," then we'll do "image files," and "image files," because again we're just doing the exact same thing. I can do "text files," the next one's going to be "text files," "text files." So this one's going to check for ".txt." Now, do we need anything else? Um, we'll just say `else`, and we'll print off, `print`, "This file type is not included," or or if there's multiple files, we'll say, "There are files in this path that weren't moved." Okay, so if we run through this, it's going to catch our CSV, catch our PNG, catch our text, and if not, it'll say, "There are files in this path that weren't moved!" All right. Now let's run through this. Uh, uh, that's because `if`, `elif`, `elif`, and then it's going to this `else` statement. Uh, I don't know. Let's, let's circle back around to that in a second. All of them were moved properly; that's really good. Really quickly, I, I'll, I'll check and see. I just don't, I'm G to take that out for now. So I'm just going to run it. Um, I'm, we may or may not go back to that, but let's check and see if everything worked properly. So let's go into the "CSV file," and we have our CSV file. Let's go into our "image files," and we have our images. And let's go into our "text file," and there are our text files. Now is there anything else that we need to do? I don't believe so, but what I can do is I can take all this, I can include it in here, and I'm going to basically restart it just to see if it works properly from scratch, right? I just want to make sure that I didn't miss anything, and we'll delete these. So we have our, I'm just going to rerun everything. We, we imported, we created our path, these are our file names, and then when we run this, it should take our folder names, check through them. If they aren't already created, it's going to create it. Don't need it to print, so let's get rid of that. Then for the `file` within our `file_names`, and it check it, it checks each one. We check if there's a CSV and if it's already, already in that file, if it's already in that folder, I mean, if it's in that folder, then it doesn't do anything. But if it isn't, so and `not`, it's not in there, it is going to move it to that location. So it's going to check CSV, PNG, and text. I think everything should work properly. Let's run this, and it looks like it's working. Good, good, good, and perfect. It worked exactly how I had hoped. Um, that's great. So this is the automatic file sorter in File Explorer project. Uh, you can go even a step further. So I had to come in here and manually run this. You can go a step further and put a timer on this where it automatically does this, maybe every hour, every day, every 30 minutes. You can run this in your background, especially if you create, um, like a an execution for this. You can run this in your background. Um, if you are curious on how to do that, I think I did something, something similar to that in my web scraping project, um, my Amazon web scraping project. If you want to go check that one out, but we're not going to do it in this project. This is all I wanted to show you how to do. So I hope that this was helpful. I hope that this project was, you know, interesting and that you liked it. I hope that you learned something, and so if you did, be sure to like and subscribe below, and I will see you in the next video. What's going on, everybody? Welcome back to another video. Today we're going to be starting our Python web scraping...

Tutorial Series

Now, this is more of a continuation of the Python tutorial series series, but because we're going to be focusing on web scraping for three or four videos, I wanted to just make it its own little miniseries. In this series, I'm going to show you the basics of web scraping: how to actually look at HTML, how to inspect a web page, how to pull that data in, and then even put it into a CSV file so you can save it and use it. Now, in this series, we're just covering the basics, which is a fantastic place to start, but in future series I'll be going into some of the more advanced web scraping topics as well. So, without further ado, let's hop on my screen and get started with web scraping.

HTML

Now, the first thing that we need to learn is HTML. HTML stands for hypertext markup language, and it's used to describe all of the elements on a web page. Now, when we actually go to a website and start pulling data and information, we need to know HTML so we can specify exactly what we want to take off of that website. So that's where HTML comes in, and we're going to look at the basics, understanding just the basic structure of HTML. Then we'll go look at a real website, and you'll kind of see that's a little bit more difficult than what we just have right here, but this is the basic building blocks to get to what the HTML actually looks like on a website.

Now, this is basically what HTML looks like: we have these angled brackets with things like HTML, head, title, body, and then you'll notice that at the end we'll have a /body, and then we'll have a /body at the bottom. This forward slash /body denotes that this is the end of the body section in HTML. So, everything inside of this is within this body. So there is this hierarchy within HTML: we have HTML and /HTML at the bottom, which encapsulates all the HTML on the website; then we have things like head and /head, body and /body.

Now, within these sections, we usually have things like classes, tags, attributes, text, and all these other things—things that we'll get to in different lessons. But one of the easiest ones to notice and look at are tags, things like a P tag or a title tag. Now, within these tags—because this is a super simple example—we have these strings here: "my first web page," "page," and this is what's called a variable string, and this is actual text that we could take out of this web page.

Now that you understand the super basics of HTML, let's actually go to our website. And I'm going to have a link down below, but it's going to be this one right here. This is basically just a website that you can, you know, practice web scraping on; it's called scrapethissite.com. And what we're going to do is look at the HTML behind this web page, and you can do this on any website that you go on. So we're going to right-click; we're going to go down to inspect.

Now, right off the bat, this looks a lot more complicated and a lot more complex than the very simple illustration that we were looking at. But let's kind of roll this up just a little bit. You'll notice we have HTML and /HTML at the bottom; we have a head and there is the end of the head, and then a body and the end of the body. So, in a super simple sense, it is similar, but just the information that's within it is a lot more difficult.

Now, if we look at this title right here, this is our title tag. If we click this little arrow, this is our dropdown; you'll notice that here we have the string: "Hockey Teams, Forms, Searching, Imp, Pagination." Now, let's say we didn't know; we didn't want to click on that and go find it. There's something that's super helpful within this inspection page that you can click on right here; it says: "Select an element in the page to inspect it." So we're going to click on that, and as we go through our page and let's click on this title, it's going to take us to exactly where this is in our HTML. This is extremely helpful, extremely useful. For example, let's say the data I want is down here; I want to take in the Boston Bruins. I can click on it, and it's going to take me to where that is exactly in the HTML. This is where we can start writing our web scraping script to specify, okay, I'm looking for a TR tag; I'm looking for a TD tag; I'm looking for the class called team. This is all information and things that we can use to specify exactly what we want to pull out of our web page.

Now, there are other things that didn't really look at as well in just our simple illustration. Let's come right over here; there's things like HRs. Now, these are hyperlinks. So if we went and then clicked on this, this is just regular text, but inside of it is this hyperlink where, if we clicked on it, it would take us to another website, and typically that's denoted by this href right here. Then you'll typically see things like a P tag, which usually stands for a paragraph.

Now, the last thing that I want to show you—while we're here, and we're going to learn a lot more in the next several lessons—but if we come right down here, there is this actual entire table here. And let's try to find this table, and I'm having trouble selecting the entire thing, but let's select this team name. And if we look at this team name, you can see that this is encapsulating the table, this table tag. Now, these are super helpful because it takes in the entire table. Now, if we wrap this up and we look just at this, it says class="table", and then we have the end of this table tag. Now, when we open it, it's going to have all of this information. So, as you can see, as I'm highlighting over it, we have these TH tags and we have these TD tags, and even these TR tags, which is the individual data, and this is something that we'll look at when we're actually scraping all of the data from this table in a future lesson. So this is how we can use HTML, how we can inspect the web page and see exactly what's going on kind of under the hood. And then in future lessons, we'll see how we can use this HTML to specify exactly what data we want to pull out. Thank you guys so much for watching. If you like this video, be sure to like and subscribe below. I will see you in the next lesson.

Beautiful Soup and Requests

Hello everybody. In this lesson, we're going to be taking a look at Beautiful Soup and requests. Now, these packages in Python are really useful; these are the two main ones that I use when I was first starting out with web scraping. It can get a lot of what you want done in order to get that information out. Now, of course, there are other packages that you can use that may be a little bit more advanced, but again, this is just the beginner series. In a future series, we'll look at other packages as well that have some more advanced functionality. So what we're going to be doing is we're going to import these packages, and then we're going to get all of the HTML from our website and make sure that it's in a usable state. And then in the next lesson, we're going to kind of query around in the HTML, kind of pick and choose exactly what we want; we look at things like tags, variable strings, classes, attributes, and more. So let's get started by importing our packages. What we're going to say is: from bs4—this is the module that we're taking it from—we're going to say import, and then we'll do Beautiful Soup. Then we're going to come down, and we're going to say import requests.

Now let's go ahead and run this. I'm going to hit Shift+Enter, and it works well for me. Now, if this does not work for you, you may potentially need to actually install bs4. So you may have to go to your terminal window and say: pip install bs4. I'll just let you Google how to do that if you need to do that, because it's pretty easy. But if you're using Jupyter notebooks through Anaconda like how we set it up at the beginning of this Python series, then you should be totally fine; it should be there for you.

The next thing that we need to do is specify where we're taking this HTML from. So what we need to actually do is come right over here to our web page, and we need to get the URL. So we're going to go here; we're going to copy this URL, and I'm just going to put it right here for a second. And what we're going to do is we're going to be using this URL quite a bit, so we just want to assign it to a variable. So just say: URL = , and then we'll put it right in here. Now we can get rid of that. So now this is our URL going forward; this is where we're going to be pulling data from. Let's go ahead and run this. Now we're going to use requests, and what we're going to do is we're going to say: requests.get, and then we're going to put in URL. Now, this get function is going to use the request library; it's going to send a get request to that URL, and it's going to return a response object. Let's go ahead and run this. As you can see here, I got a response of 200. If you got something like a 204 or a 400 or 401 or 404, all these things are potentially bad. Something like a 204 would mean there was no content in the actual web page. 400 means a bad request, so it was invalid; the server couldn't process it, and you don't get any response. If you got a 404, that might be one that you're familiar with; that's an error that means the server cannot be found.

The next thing that we're going to do is take the HTML. Now, if you remember, we come right back here, and we inspect this; we have all this HTML right here. Now, on this web page specifically right now, it's completely static; it's not a bunch of moving stuff or anything like that. Usually, when you're looking at HTML, if you're looking at something like Amazon, and those web pages can update, but when you actually pull that into Python, you're basically getting a snapshot of the HTML at that time. So what we're going to do is bring in all of this HTML, which is our snapshot of our website, and then we can take a look at it. So we're going to come right down here, and now we're going to say Beautiful Soup. So now we'll use the Beautiful Soup package or library. So we need to say Beautiful Soup, and we're going to do an open parenthesis; we're going to do two things; there's two parameters that we need to put in here. First, we need to put in this get request; we actually need to name this, and we'll call this page; we'll say: page = , and let's run this. And now we're going to put that page in here, and what we're going to say is: .text. So the page is what's sending that request, and then the text is what's retrieving the actual raw HTML that we're going to be using. Then we're going to put a comma here, and what we need to specify is how we're going to parse this information. Now, this is an HTML, so what we're going to do is: 'html'. Just like this. This is a standard; this is already built into this library, so we don't need to go any further, but it's basically going to parse the information in an HTML format. Let's go ahead and run this; let's see what we get. And as you can see, we have a lot of information, and as I scroll down, I'll try to point out some things that we've already looked at in previous lessons—something like this TH tag that should be very similar; that's the title; then we have these TD tags; and then, of course, if we scroll down even further, we'll have things like a TR tag. So these are all things that we looked at in that first lesson when learning about HTML.

Now, again, we want to assign this to a variable, so we're going to say: soup = this information right here. Now, I'm not going to go into all the history behind Beautiful Soup; what I will say is the guy who created this Beautiful Soup library—what he said was is that it takes this really messy HTML or XML, which you can also use it for, and makes it into this kind of beautiful soup. So I just thought that was kind of funny, but that's why we're calling it soup right here. And we're going to go ahead and run this, and we'll come right down here, and we'll say: print(soup). And let's run it, and now we have everything in here. So we have our HTML, our head, we have some HR and some links in here. Let's scroll down a little bit more, and then we have our body right there, and of course, we have a bunch of information in here. Now, in the next lesson, what we're going to be doing is learning how to kind of query all of this to take specific information out and basically understand a lot of what's going on in this HTML to make sure we can actually get what we need.

Now, if this looks really kind of messy to you, and it just doesn't make a lot of sense, there is one more thing that I'm going to show you, and we'll come right down here. So we'll say: soup.prettify(), and if you've ever used a different type of programming languages, pry is very common in a lot of them where it'll just make it a little bit more easy to visualize and see. You'll notice that it kind of has this hierarchy built in, whereas if we scroll up, there's no hierarchy built in; it's all just down this left-hand side. So if you kind of want to view it and just kind of visually see the differences, this does help a lot, but it doesn't actually help a lot when you're, you know, querying it or using, you know, find and find_all, which is what we're going to look at in the next lesson. So that is our lesson on Beautiful Soup and requests. In the next two lessons, we're going to be looking at find and find_all, as well as really diving into things like variable strings and tags and classes and all those things. And then in the last lesson, we're going to do kind of this mini-project where we try to get all the data from this web page that we've been using from that table and put it into a Pandas DataFrame. So thank you guys so much for watching; I really appreciate it. If you like this video, be sure to like and subscribe below, and I will see you in the next lesson.

Find and Find_All

Hello everybody. In this lesson, we're going to be taking a look at find and find_all. Really, we're going to be looking at a ton of different things in this lesson; this is where we really start digging in, seeing how we can extract specific information from our web page. But in order to do that, let's set everything up where we actually bring in the HTML like we did in the last lesson, and we're just going to write all this out one more time, just for practice if nothing else, and then we'll get into actually getting that information from the HTML. So we're going to start by saying: from bs4 import BeautifulSoup; there we go. And: import requests. We'll go ahead and run this. Then we're going to come up here, grab our HTML, or sorry, our URL. So we'll say: URL = , and we'll have that right here. Now we need to say: page = , and then we'll do: requests.get, and then we'll put in our URL right here. And we're going to come over here and run this. And lastly, we need to say: soup = ; so we'll say: soup = BeautifulSoup, there we go, and then within our parentheses, we need to specify the page.text, because we need that, and our parser, which is: 'html'. And there we go. And let's go ahead and run this; let's print it out, make sure it's working. And there we go. So we have our soup right here; all this should look really similar to our last lesson. And so now we've brought in our HTML from our page; we have a lot, a lot, a lot of information in here.

Now, really quickly, let's come over and let's inspect our web page. Now, in here, we have a ton of information; right, we have a bunch of different tags and classes and all these other things, but how do we actually use these? Well, that's where the find and find_all is going to come into play, and they're pretty similar, and you'll see that in just a little bit. But let's say we want to take one of these tags, and let's come down; let's say we just want to take this div tag. Now, there's going to be a lot of different div tags in our HTML, but let's just come right here; let's go down, and let's say we're going to call soup; we're going to say: soup.find. Now, within our parentheses, we can specify a lot of different things, but we're going to keep it really simple right now; we're just going to say: 'div'. Let's go ahead and run this. What this is going to bring up is the very first div tag in our HTML, and that's going to be this information right here. Now, let's copy this, and we're going to do the exact same thing, except we're going to say: find_all. Now let's run this. Now we're going to have a ton more information. Really, all find and find_all do is that they find the information. Now, find is only going to find the first response in our HTML. Let's say that's the div class="container". Let's go back up to the top; that's our div class="container". But find_all is going to find all of them, so it'll put it in this list for you. So it's going to have this first one, and it goes down to this /div, which should be right here, and then we have a comma, which separates our next div tag. So that is how we can use it.

Now, what if we want to specify one of these div tags? We pulled in a ton of them, but we want to just look for one of them. Well, this is something where the class comes in handy because right now we have class="container", class="col-md-12". I don't know what these are off the top of my head, but usually they'll be somewhat unique, and we can use these to help us specify what we're looking for. For example, just kind of glancing at this, we could also use this a tag if we wanted to look at this. So we could say, oh, we're looking for these hrefs. So we have an href here, and this right down here, we have this href as well, which again, if you remember from the previous lesson, that stands for a hyperlink. Now, something like the class or the href or these IDs, these are all attributes, so we can specify or kind of filter down based off of these. Now let's try it. So what we can do is we can do class first, and this is kind of the default within something like find_all is you can even do class_=; we can come right back up; we have this div, and then here's our class. So again, we have to have the div and the class. If we took this a tag, this is an a tag, which would go right here, with the class of something like navlink, or something like navlink. Again, down here, we need to specify that more, but we have our div, so we'll say: 'col-md-12' right here. And let's go ahead and run this, and now it's going to pull in just that information. Now we're still getting a list because we have multiple of these, so this div class="col-md-12" doesn't just happen once. If we scroll down, we'll see it multiple times, something like right here, or actually, let me see, right here. So here's this comma, then here's our next one. So we have two of these div tags with a class of col-md-12, and in each of these, we have different information. This looks like a paragraph with this P tag right here. And let's scroll back up. So I also think we should try out doing something like this P tag. Typically, these P tags stand for...

Paragraphs or they have text information in them. Let's try to P tag really quickly, and let's just see what we get. Let's run this, and it looks like we get multiple P tags. Now, if we come back here, you can see that there's this information, and it's this information that we're pulling in. I'm just, you know, noticing that from right here. And then we have this information right here, and it looks like there's one more, which is this href, which looks like this: open source so data via, and then that uh hyperlink or that link right there. So we have three different P tags. Now, just to verify and make sure that that's correct, what we could do is come over here; we're going to click on this paragraph. It's going to take us to that P tag where the class is equal to lead. Let's come over here and look at this paragraph. Now we have another P tag right over here with the class is equal to glyphicon glyphicon education. I have no idea what that means, um, and then we'll go to our last one, which is right here where the P tag is equal to uh we have a tag HRA class uh and a bunch of other information. So let's say we just wanted to pull in this paragraph right here. Let's go here and see how we can specify this information. So it looks like P or the class is equal to lead; that looks like it's going to be unique to just that one. So if we come down here, we're going to say comma, and it was class, so you can do uh class_ is equal to, and then we're going to say lead. Let's try running this, and we're just pulling in that information.

Now let's say we actually want to pull in this paragraph. We actually want this text right here, and this is a very real use case, you know. Let's say I'm trying to pull in some information or or a paragraph of text. Well, let's copy this, and what we're going to then do is say .text, and let's run this. Now we're going to get an error right here, and this is a very common error because we're trying to use find all. Unfortunately, find all does not have a text attribute. We actually need to change this to find. Typically, when I'm working with these find and find alls, I'm using findall most of the time until I want to start extracting text. Then, when I specify it, I'll change this back to find, just like this. Now let's try this, and now we're getting in parentheses this information. Now this is all wonky; it needs to definitely be cleaned up a little bit. But if we code back up, it's no longer in a list, and we no longer have things like these P tags in here or this class attribute. So we're really just trying to pull out this information. Now, again, this does not look perfect. We could even try to do something like do strip. Look like there's some white space uh that cleans it up a little bit. This definitely looks a little better, um, and we could definitely go in here and clean this up more, but just for, you know, an example, this is how we can then extract that information.

Now let's look at one more example. This is some information, and this is what we're going to do, kind of our little mini project in the next lesson. On, let's say we wanted to take all this information. What if we wanted to pull in something like the team name that's going to be in right here in this TR tag? And each of these TR tags have th tags underneath them. So if we scroll down, you'll notice that each row is this TR tag. So let's go ahead and search for let's do th; let's just search for that first. So let's come right back up here; let's use this find all, and we'll get rid of this text for right now, and let's just say we want to look for the TR. Is that what we said we were looking for? No, th. So let's say we're looking for th. Let's go ahead and run this. So we're going to have underneath this th; we have team name, year, wins, losses, and notice these are all the titles. So these titles are the only ones with these th tags. If we go down, you'll notice that the data is actually TD tags. So now let's go back and look for TD. We'll say D, and this is going to be a lot longer; we have a lot of information, but these are all the rows of data. Let's see if we can just get one piece of this data. We're going to get back; we want just this team name; that's all we're trying to pull in for now, um, and then we'll try to get this row, and then in the next lesson we're going to try to get all of this information, make it look really nice, and then we'll put it into a panda's data frame. So let's just get this team name right now. Let's go ahead; we're going to say th. Let's run this, and we have this th. And now that we know we're getting this information in, we can do find. Let's run this. So there's our team name. We're just going to say .text, and again we can do .strip just like that, and Bam, we have our team name. So you can kind of start getting the idea of how we're pulling this information out. We're really just specifying exactly what we're seeing in this HTML, and what's really really helpful and, you know, something that I do all the time is I'm inspecting it; I'm just kind of searching like how, what do I want? What piece of information do I want? Then I go ahead and click on it, and then I'm looking, you know, where is this sitting in the hierarchy? It's within the body; it's within this table with the class of table, then it's down here where this TR tag and then this TD tag. So I'm looking kind of at the hierarchy, and I'm specifying exactly what I'm looking for. So that is what we're going to look at in today's lesson; that's how we can use find and find all. We were able to look at classes and tags and attributes and variable strings, which is this right here, getting that text uh and variable strings, and we will look at find and find all and how it's pulling that information in and how we can specify exactly what we're looking for. Now, in the next lesson, which is definitely going to be the most exciting one, we're going to try to pull in all of this information, so every single thing, because we'll be able to put all this information into a data frame, which then we can use pandas to really search and manipulate that data within that data frame. So with that being said, that is the end of this lesson. If you like this video, be sure to like and subscribe. I will see you in the next [Music] lesson.

Hello everybody. In this lesson, we are going to be scraping data from a real website and putting it into a p and's data frame and maybe even exporting it to CSV if we're feeling a bit spicy. Now, in the last several lessons, we've been looking at this page right here, and I even promised that we were going to be pulling this data. But as I was building out the project, I just, I honestly thought it was a little bit too easy, since in the last lesson we kind of already pulled out some information from this table, and I want to kind of throw you guys off. So we're going to be pulling from a different table; we're going to be going on to Wikipedia and looking at the list of the largest companies in the United States by Revenue, and we're going to be pulling all of this information. So if you thought this was going to be easy in a little mini project, uh, it's now a full project, because why not? So let's get started. Uh, what we're going to do is we're going to import beautiful soup and requests; we're going to get this information, and we're going to see how we can do this, and it's going to get a little bit more complicated and a little bit more tricky. We're going to have to, you know, format things properly to get it into our Panda data frame to make it looking good and making it more usable. So let's go ahead and get rid of the this easy table; we don't want that one, uh, and we're going to come in here, and we're just going to start off. This should look uh really familiar by now. We're going to say from bs4 import beautiful soup. I don't know if you've noticed, but I've messed up spelling beautiful soup in every single uh video I've noticed. Let's run this, and now we need to go ahead and get our URL. So let's come up here; let's get our URL. Say URL is equal to, and we'll just keep it all in the same thing really quickly because we know this by heart by now, right. Uh, we'll say request.get and then URL to make sure that we're getting that information. It gives us a response object, um, hopefully it'll be 200; that'll mean a good response. And then we'll say soup is equal to, and then we'll say beautiful soup, and we'll do our page.text. Now we're pulling in the information from this URL, and then we use our parser, which will be oops HTML. And let's go ahead and run this. Looks like everything went well. Let's print our soup. Now this is completely new to you; it's completely new to me; I don't know what I'm doing, uh, but it looks like we're pulling in the information. Am I right? So we got a lot of things going for us, uh, the uh stuff was imported properly; we got our URL; we got our soup, which is uh not beautiful in my opinion, but let's keep on rolling. Let's come right down here. Now what we need to do is we we need to specify what data we're looking for. So let's come and let's inspect this web page. Now the only information that we're going to want is right in here; we're going to want these uh titles or these headers. Whoops. So we're going to want rank, name, industry, etc., and then we are for sure going to want all of this information. Let's just scroll down; see if there's anything tricky in here. All right, that looks pretty good, and there is another table. So there's not just one table in here; there are two tables in this page, so that might change things for us, but let's come right back and let's inspect our page by using this little button right here, and let's specify in let's see if I can highlight just this page. Oh, it's not going. Oh, let's do that right there. So now we have this uh Wiki table sorter. Now I'm going to actually come right here; I'm going to copy, and I'm just going to say copy the outer HTML. Just just going to paste in here real quick, and that's a ton of information. I didn't think it was going to copy all of it, and we're just going to delete that. I just wanted to keep that class uh because I wanted to then come right down here at the bottom and just see what this table uh looks like. I don't know if it's part of it or if it's a if it's its own table, um, I can't tell. Let's look at this Rank, and let's come up. So it says uh it's under this table, and it looks like it's its own table, but it says Wiki table sort sortable jQuery table sorter wikip sortable jQuery table sorter. So it looks like there are two tables with the same class, which shouldn't be a problem if we're using find to get our text because we should be taking the first one, which will be this table, and this is the table we want, um, and if we wanted this one, we could just use find all, and since it's a list, we could use indexing to pull this table right, um, but I think we're going to be okay with just pulling in this one. So let's go ahead and let's do our find. So we'll do soup.find, and we could find all or we could just do find uh table. Let's just try this and see what we get, and if it pulls in the right one that we're looking for, that'd be great. Now this does not look correct at all, um, I don't know what table it's pulling in. Oh, maybe it's this right here; this might be a table. Yeah, it is. So we have this uh box more citations. So actually, we are going to have to do exactly like what I was talking about. Let's pull this, and we well we could do comma class uh right here, and let's do both. You know what? This is a learning opportunity; let's do both. So let me go back up to the top because I need these, um, and what we're going to do. Let's come right down here. I want to add in uh another thing. Actually, I'll just push this one up there. There we go. So we're going to say find or all. Let's run this. So now we have multiple, and again we got that weird one first, but if we scroll down, here's our comma, and then here's our wik Wiki table sortable, and then we have rank, name, industry, all the ones that we were hoping to see, and I guarantee you if you scroll all the way to the bottom, um, we're going to see potentially Well Fargo, Goldman Sachs. I'm pretty sure those are, um, let's see. Yeah, here we go: like Ford motor, Wells Fargo, Goldman Sachs. That's this table right here. So now we're looking at the third table, but again, this is a list, so we can use indexing on this, and we'll just choose not position zero because that's this one right here, which we did not like. Well, now we'll take position one. Let's run this. Let's go back up to the top, and this is our table right here: rank, name, industry; this is the information that we were actually wanting. Just to confirm: rank, name, industry, etc. So this is the information we're wanting, and we're able to specify that with our findall, and this is the information we want. So we now want to make this the only information that we're looking at. So I'm just going to copy this. We didn't need to use our class for this one; you probably could have, um, but we could. So let's actually um put this right down here. This will be our table; we'll say equal to, but then I'll come right here, and I'm going to say soup.find. This is just for demonstration purposes. We do table, comma class_ is equal to, and then we'll look at this right here. Whoops, me do this, and let's see if we get the correct output, and let's run this, and looks like we're getting a nun type object. If I remember, remember, looks like the actual class is this right here. So let's run this instead, and I got to get rid of the index. There we go. Okay, so we were able to pull it in just using the find, so the find table class, and it says Wiki table sortable; at least that's the HTML that we're pulling in right here. Let me go back because I don't don't know if that's what I was seeing earlier. Let's just get this rank. Let's go back up. Where's the rank? We go rank; there we go. So here's our Rank, and let's go up to the table, and there's our class. Yeah, and and that's just uh to me that's a little bit odd. So it says Wiki table sortable jQuery-table-sorder right here, but in our actual um in our actual python script that we're running, it was only pulling in the wiki table sortable. So it wasn't pulling in the jQuery.sorter. Why? Uh, I'm not 100% sure, but all things that we're working through, and we were able to uh we were able to figure out. So we're going to make this our table. We're going to say tables equal to uh soup.findall, and let's run this, and if we print out our table, we have this table. Now this is our only data that we are looking at. Now the first thing that I want to get is I want to get these titles or these headers right here; that's where we're going to get first. So let's go in here; we can just look in this information. You can see that these are with these th tags, and we can pull out those th tags really easily. Let's come right down here; we're just going to say th, and we can get rid of this. Let's run this. Now these are our only th tags because everything else is a TR tag for these rows of data. So these th tags are pretty unique, which makes it really easy, which is really really great because then we can just do worldcore titles is equal to. So now we have these titles, but uh they're not perfect, but what we're going to do is we're going to loop through it. So I'm going to say worldcore titles, and I'll kind of walk through what I'm talking about. Isn't a list, and each one is within these th tags, so th, and then there's our um string that we're trying to get. So we can easily take this list and use list comprehension, and we can do that right down here. So I'm going to keep this where we can see it, um, we'll do worldcore tore titles that's equal to. Now we'll do our list comprehension; should be super easy. Uh, we'll just say for title in worldcore titles, and then what do we want? We want title.text; that's it, um, because we're just taking the text from each of these; we're just looping through, and we're getting rank. Then we're looping through, getting name, looping through, getting industry; that's that's it. So let's go and print our world table titles and see if it worked, and it did. This looks like it needs to be cleaned up just a little bit. So let's go ahead and do that while we're here before we actually put it into the uh P's data frame. Oops, I just wanted uh I just wanted this actually. So what we're going to do is try to get rid of those backslash ends. If we do .strip, that may actually not work. Yeah, uh, because this is a list. What we need to do is we can actually do it .text.strip right here. Let's try to do it in there. There we go. So now we have uh this, and now this world tables is good to go. Now I'm actually noticing one thing that may be odd. Yeah, so we have rank, name, industry, goes to headquarters, but then in here we're getting rank, name, industry, and then the profits, which is from this table right here, which we don't want. Let's scroll back up; let's kind of backtrack this and see where this happened. We did find all table; we're looking at the first one right, and then we're doing [Music] headquarters, uh, so we're doing print table. Ah, okay, I think I found the issue here, and let's backtrack again. This is we're working through this together; we're going to make mistakes, uh, the table is what we actually wanted to do; we just did soup.findall th, which is going to pull in that secondary table, um, jeez, we were not thinking here, um, so now we need to do find all on the table, not the soup, because now we were looking at all of them. Oh, what a rookie mistake. Okay, uh, let's go back. Now let's look at this. Now it's just down to headquarters. Okay, okay. Let's go ahead and run this. Let's run this. Now we just have headquarters. Now let's run this. Now we are sitting pretty. Okay, excuse my mistakes. Hey, listen, you know, if it happens to me, it happens to you. I promise you this is, you know, this is a project; this a little U little project we're creating here, so we're going to run into issues, and that's okay; we're figuring out as we go. Now what I want to do before we start pulling in all the data is I want to put this into our Panda's data frame. We'll have the uh, you know, headers there for us to go, so we won't have to get that later, and it just makes it easier uh in general, trust me. So we're going to import pandas as PD. Let's go ahead and run this, and now we're going to create our data frame. So we'll say PD. Now we have these world uh table titles. So what we're going to do is pd.data frame, and then in here for our columns, we'll say that's equal to the world table titles, and let's just go ahead and say that's our data frame and call our data frame right here. Let's run it. There we go. So we were able to pull out and extract those headers and those titles of these columns; we're able to put it into our data frame, so we're

Set up, and we're ready to go. We're rocking and rolling. The next thing we need—let's go back up—the next thing we need is to start pulling in this data right here. So we have to see how we can pull this data in. Now, if you remember that we had those TH tags, those were our titles, as you can see I'm highlighting over it. But down here now we have these TD tags, and those are all encapsulated within a TR tag. So these TR represent the row; then the TD represents the data within those rows. So TR for rows, TD for data. Let's see how we can use that in order to get the information that we want.

So let's go back up here. Just going to take this because, again, we're only pulling from the table—not soup, not soup—what were we thinking? Um, and let's go ahead and let's look at TR. Let's run this. Now, when we're doing this TR, these do come in with the head, so we're going to have to—later on—we're going to have to get rid of these. We don't want to pull those in um and have that as part of our data. But if we scroll down, there's our Walmart. Um, we have the location; these are all with these TD tags, and then, of course, it's separated by a comma. Then we have our TD2. So above we had our TD1. So Row one, Row two, Row three all the way down. Now we will easily be able to use this right, because this is our column data, and we can even call it that: column_data = . We'll run that. Um, and what we're going to do is we're going to loop through that because it was all in a list. So we're going to loop through that information, but instead of looking at the TR tag, we're going to look at the TD tag. So let's come right down here. We'll say: for the row in column_row:, now we need to loop through this. We'll do something like row.find_all("td"), and then what are we looking for? We're not looking for the TR; we're looking for the TD. And just for now, let's print this off; see what this looks like. Apparently, I didn't run this column_data; that's why. And let's run this. And what we actually need to do is something almost exactly like this, and I'm going to put it right below it. Um, instead of printing this off, because again this is all in a list, we're using find_all, so we're printing off another list, which isn't actually super helpful. Um, for each of or all these data that we're pulling in, what we can do is we can call this the row_data, and then we'll put the row data in here. So we'll say: for and we'll say in row_data, so we'll just say: for the data in row_data, and we'll take the data; we'll exchange that. And now, instead of World_Table_titles, we can change this into individual_row_data. Right, and now let's print off the individual_row_data. So it's the exact same process that we were doing up here, and that's how we cleaned it up and got this. And we may not need to strip, but let's just run this and see what we get. There we go. Um, and strip, I'm sure, was helpful. Let's actually get rid of this. Yeah, strip was helpful; it's the exact same thing that happened on the last one. So let's keep that. Actually, let's run this, and now let's just kind of glance at this information; let's look through it. This looks exactly like the information that's in the table. Let's just confirm with this first one: 25, uh, two—what am I saying?—572,754, 2.4, 2300, 57275, 2.4, 2200. So this looks exactly correct. Now we have to figure out a way to get this into our table, because again these are all individual lists; it's not like we're just, you know, putting all of this in at one time. We can't just take the entire table and plop it into um into the data frame. We need a way to kind of put this in one at a time.

Now, if you're just here for web scraping and you haven't taken like my pandas series, that's totally fine; that's not what we're here for anyways. Um, but what we can do, we'll have our individual_row_data, and we're going to put it in kind of one at a time. Now, the reason we have to do that is because when we had it like this—and let's go back—when we had it like this, it's printing out all of it, but what it's really doing—and let's get rid of it—what it's really doing is it's kind of doing it like this: it's printing it off one at a time, and it's only going to save that current row of data. This last one, it's only going to save that as it's looping through. So what we actually want to do is every time it loops through, we append this information onto the data data frame. So as it goes through—and eventually it's going to end up with this one—but as it goes through, let's run this; as it goes through, it puts this one in, and then the next time it loops through, it puts this one in, and the next time it loops through, etc., all the way down. Um, so let's see how we can do this. So we have our data frame right here. Let's get rid of this; let's bring our data frame in. Now, again, like I just mentioned, if you don't know pandas and you haven't learned that, uh, you know, go take my uh series on that; it's really good. And we do something very similar to this in that series, so I'm not going to kind of walk through the entire logic, um, but there is something called loc, which stands for location when you're looking at the index on a data frame, and we're going to use that to our advantage. So we're going to say the length of the data frame, so we're looking at how many rows are in this data frame, and then we're going to say that's our length. Then we're going to take that length and use it when we're actually putting in this new information. Pretty um pretty cool. So we're going to say df.loc[length], so we're checking the length of our data frame each time it's looping through, and then we're going to put the information in the next position; that's exactly what we're doing. So let's go ahead and put in the individual_row_data.

Um, so let's just recap: We're looping through this TR; this is our column data. So these TR—that's our row of data. Then we're—as we're looping through it—we're doing find_all and looking for TD tags; that's our individual data, so that's our row_data. Then we're taking that data—each piece of data—and we're getting out the text, and we're stripping it to kind of clean it. And now it's in a list for each individual row. Then we're looking at our current data frame, which has nothing in it right now. We're looking at the length of it, and we're appending each row of this information into the next position. So let's go ahead and run this. It's working; it's thinking, and it looks like we got an issue: cannot set a row with mismatched columns. Now we're encountering an issue—not one that I got earlier—but we're going to cancel this out; we're going to figure this out together. So let's print off our individual_row_data. Let's look at this. This one is empty; this is—I'm almost certain—is probably the issue. Um, I didn't encounter this issue when I wrote these—when I wrote this lesson—um, but I'm almost certain that this is the issue right here. So let's do the column_data, but let's start at position—let's try one—and not parentheses; I need brackets because this is a list, right? So it should work. And there we go. So now that first one's gone, so now we just have the information. I didn't even think about that um just a second ago, but I'm glad we're running into it in case you ran into that uh issue. Let's go ahead and try this again, and it looked like it worked. So let's pull our data frame down. I could have just wrote DF. Let's pull our data frame down, and now this is looking fantastic now. Um, these three dots just mean there's information in there; it just doesn't want to display it, but it looks like we have our rank, we have our name, have the industry, revenue, revenue growth, employees, and headquarters for every single one. So this is perfect. Now this is exactly what I was hoping to get. Now you can go in and use pandas and manipulate this and change it and, you know, dive into all the information in there, but we can also export this into a CSV if that's what you're wanting. So we could easily do that by saying: we'll do df.to_csv(), and then within here we're just going to do r and specify our file path. So let's come down here to our file path, then we'll go to our folder for our output. So we're just going to take this path, and let me do it like that, so I have this path in my OneDrive/Documents/Python/Webscraping/being/folder/for/output. So, you know, I already made this, um, and I'm just going to put this right down here. Now I do have to specify what we're going to call this; we'll just call this companies.and then we have to say .csv; that is very important. Now, if we run this—I already know just because uh we have this Rank and this index here—we're going to keep this index in the output; not great—uh, but let's run it. Let's look at our output. There's our companies, and when we pull this up, as you can see, this is not what we want because we have this extra thing right here. Now, if we're automating this, this would get super annoying. So what we're going to do is go back and just say index=False. Let's go out of here, and now we're just going to come right down here; we're going to say , index=False, and so it's going to take this index and it's not going to import or actually export it into the CSV. Now let's go ahead and run this. Let's pull up our folder one more time and let's refresh just to make sure; should be good. And now this looks a lot better. So we're able to take all of that information and put it into a CSV, and it's all there. So this is the whole project. So if we scroll all the way back up, let's just kind of glance at what we did here. Scroll down; we brought in our libraries and packages; we specified our URL; we brought in our soup; um, and then we tried to find our table. Now that took a little bit of uh testing out, but we knew that the table was the second one, so in position one, so we took that table; we were also able to specify it using find, but then we used the class, and of course we just wanted to work with that table; that's all the data we wanted. So we specified—this is our table—and we worked with just our table going forward. Of course, uh, we encountered some small issues—user errors on my end—but we were able to get our world titles and we put those into our data frame right here using pandas. Then next we went back and we got all the row data and the individual data from those rows and we put it into our pandas data frame. Then we came below and we exported this into an actual CSV file. So that is how we can use web scraping to get data from something like a table and put it into a pandas data frame. I hope that this lesson was helpful. I know we encountered some issues; that's on my end, and I apologize, but if you run into those same issues, hopefully that helped, uh, but I hope this was helpful, and if you like this, be sure to like and subscribe below. I appreciate you; I love you, and I will see you in the next [Music] lesson.

So the first thing that we need to do is import our pandas Library. So we're going to say: import pandas. Now this will import the pandas library, but it's pretty common place to give it an alias, and as a standard when using pandas, people will say: as pd. So this is just a quick alias that you can use—that's what I always use, and I've always used it because that's how I learned it, and I want to teach it to you the right way. So that's how we're going to do it in this video. So let's hit Shift+Enter. Now that that is imported, we can start reading in our files. Now, right down here, I'm going to open up my file explorer, and we have several different types of files in here: We have CSV files, text files, JSON files, and an Excel worksheet, which is a little bit different than a CSV. So we're going to import all of those; I'm going to show you how to import it, as well as some of the different things that you need to be aware of when you're importing. So we're going to import some of those different file types, and I'll show you how to do that within pandas. So the first thing that we need to say is: pd. and let's read in a CSV because that's a pretty common one. We'll say: read_csv(). And this is literally all you have to write in order to call it in. Now it's not going to call it in as a string like it would in one of our previous videos if you're just using the regular operating system of Python. When you're using pandas, it calls it in as a data frame, and I'll talk about some of the nuances of that. So let's go down to our file explorer. We have this countries_of_the_world.csv. You just need to click on it and right-click and copy as path, and that's literally going to copy that file path for us. You don't have to type it out manually; you can if you like. And we're just going to paste it in between these parentheses. Now, if we run it right now, it will not work. I'll do that for you. It's saying we have this Unicode error. Uh, basically what's happening is is it's reading in these backslashes and this colon and all those back clashes in there and this period at the end. What we need to do is read this in as a raw text, so we're just going to say r, and now it's going to read this as a literal string or a literal value and not as, you know, with all these backslashes, which does make a big difference. When we run this, it's going to populate our very first data frame. So let's go ahead and run it, and now we have this CSV in here with our country and our region. Now, if we go and pull up this file—and let's do that really quickly—let's bring up this countries_of_the_world; it automatically populated those headers for us in the data frame, but we don't have any column for those 0, 1, 2, 3. So if we go back, as you can see right here, there's this index, and that's really important in a data frame; it really makes a data frame a data frame, and we use index a lot in pandas. We're able to filter on the index, search on the index, and a lot of other things, which I'll show you in future videos, but this is basically how you read in a file. Now, if we go right up here in between these parentheses and we hit Shift+Tab, this is going to come up for us. Let's hit this plus button, and what this is is these are all the arguments or all the things that we can specify when we're reading in a file, and there are a lot of different options. So let's go ahead and take a look really quickly. Really quickly, I wanted to give a huge shout out to the sponsor of this entire pandas series, and that is Udemy. Udemy has some of the best courses at the best prices, and it is no exception when it comes to pandas courses. If you want to master pandas, this is the course that I would recommend; it's going to teach you just about everything you need to know about pandas. So huge shout out to Udemy for sponsoring this pandas series, and let's get back to the video. The first thing is obviously the file path; we can specify a separator, which there is no default. So when we're pulling in this CSV—when we're reading in the CSV—it's automatically going to assume it's a comma—CU—it's a comma-separated uh file. You can choose delimiters, headers, names, index_col, and a lot of other things, as you can see right here. Now I will say that I don't use almost any of these; the few that I'm going to show you really quickly in just a second are up the very top, but you can do a ton of different things, and I'm just going to slowly go through them. So that's what those are. You can also go down here; this is our docstring, and you can see exactly how these parameters work; it'll show you and give you a text and walk you through how to do this. Again, most of these you'll probably never use, but things like a separator could actually be useful, and things like a header could be useful because it is possible that you want to either rename your headers or you don't have a header in your CSV and you don't want it to auto-populate that header. So that is something that you can specify. So, for example, this header: I'll show you how to do this. The default behavior is to infer that there are column names if no names are passed. This behavior is identical to header=0. So it's saying that first row or that first index, which is like right here—that zero—is going to be read in as a header, but we can come right over here and we'll do: , header=, and we can say: None, and as you can see, there are no headers. Now, instead, it's another index, so we have index indexes on both the x-axis and the y-axis. And so right now we have this zero and one index indicating the first column and the second column. If we want to specify those names, we can say: header=None, then we can say: names=, and we'll give it a list. And so the first one was country, and what's that second one? Oh, region. So right here, that's the first—the first row—but we'll rename it, and we'll just say: ['country', 'region'], and when we run that, we've now populated the country and the region. Uh, we're just pretending that our CSV does not have these values in it, and we have to name it ourselves. That's how you do it, but let's get rid of all that because we actually do want those in there. So we're just going to get rid of those and read it in as normal, and there we go. Now, typically when you're reading in a file, what you need to do is you want to assign that to a variable; almost always when you see any tutorial or anybody online or even when you're actually working, people will say: df=, df stands for data frame. Again, this is a data frame. In the next video in this series, I'm going to walk through what a series is as well as what a data frame is because that's pretty important to know when you're working with these data frames. But we'll assign it to this value, and then we'll say we'll call it by saying: df, and we'll run it, and that's typically how you'll do things because you want to save this data frame, so later on you can do things like: data_frame., and you can uh, you know, pass in different modules, but you can't really do it; it's not as easy to do it if you're calling this entire CSV and importing it every time. So let's copy this because now we're going to import a different type of file. So now we've been doing read_csv, but we can also import text files. Now you can do that with the read_csv; we can import text files. Let's look at this one; we have the same one; it's countries_of_the_world, except now it's a text file because I just converted it for this video. I'll copy that as a path, and so now when we do this—oops, let me get those quotes in there—it'll say: world.txt, it will still work. As you can see, this did not import properly. Um, we have…

This country, back SLT region, and then all of our values are the exact same with this back SLT. That's because we need to use a separator, and I'll show you in just a little bit how we can do this in a different way. But with that read CSV, this is how we can do it. We'll just say sep is equal to; we need to do back SLT. Now let's try running this, and as you can see, it now has it broken out into country and region.

We could also do it the more proper way, and this is the way you should do it. And I'll get rid of these really quickly, but just want to keep them there in case you want to see that. But you can also do read_table, and let's get rid of this separator. And now we have no separators, just reading it in as a table. Let's run this, and it reads it in proper the first time. This read_table can be used for tons of different data types, but typically I've been using it for like text files. Um, we can also read in that CSV, so let's change this right here to CSV. We can read it in as a CSV, but just like we did in the last one when we read in the text file using read_csv, this read_table, you're going to need to specify the separator, so I'll just copy this and we'll say comma. And now it reads it in properly again. You can use that for a ton of different file types, but you just need to specify a few more things if you don't want to use the more specific read_uncore function when you're using pandas.

Now let's copy this again. We're going to go right down here, and now let's do JSON files. JSON files usually hold semi-structured data, um, which is definitely different than very structured data like a CSV, where it has columns and rows. So let's go to our file explorer; we have this JSON sample. We will copy this in as the path. Let's paste it right here, and we'll do read_json. Again, these different functions were built out specifically for these file types; that's why, you know, each one has a different name. So now we're reading this in as the JSON. Let's read it in, and it read it in properly.

Now let's go ahead and copy this and take a look at Excel files, because Excel files are a little bit different than other ones that we've looked at. Um, so let's just do read_uncore_excel, and let's go down to our file explorer, and let's actually open up this workbook. As you can see, we have sheet one right here, but we also have this world population, which has a lot more data. Let's say we just wanted to read in sheet one; we can do that, or by default it's going to read in this world population because it's the first sheet in the Excel file. Well, let's go ahead and take a look at that. Let's get out of here, and and let's say, oops, I forgot to copy the file path. Let's go ahead and copy as path, and we'll put it right here, and let's just read it in with no arguments or anything in there, or no parameters. When we read it in, it's reading in that very first sheet, so this is the one that has all of the data.

Now let's say we wanted to read in that extra sheet name, or the second sheet name. We'll just go comma, sheet_undor_name, say is equal to, and then we can specify sheet, was it sheet one like this? Yes, it was. So we just had to specify the sheet name right here, and then it brought in that sheet instead of the default, which is the very first sheet in that Excel. Now that definitely covers a lot of how you read in those files. Again, you can come in here and hit Shift+Tab and this plus sign and take a look at all the documentation, and you can specify a lot of different things—things that I didn't think were very important for you guys to know, especially if you're just starting out. The ones that we looked at today are what I would say are like the ones that I use almost all the time, so I wanted to show you those. But if you're interested in any of these other ones, or you have very unique data and you need to do that, um, you know, it's worth really getting in here and figuring things out.

A few other things that I wanted to show you just in this kind of first video, or this intro video on how to read in files: one thing that you may have noticed, especially in this file right here, is we're only looking at the first five and then the last five. So if we wanted to see all the data, all the data is in these like little three dots right here, right? We want to be able to see that data, but right now we can't, and that's because of some settings that are already within pandas, and all we need to do is change that. So this one has 234 rows and four columns, so obviously we can see all the columns. Well, let's just change the rows. All we'll say is pd.set_uncore_option. Now what we need to do is we're going to change the rows; we're not going to change the columns, at least not on this one, so we'll say 'display.max_rows'. Now if we just run this for whatever data we bring in, it's going to be able to show the max rows, and then we'll say 235, although there's 234 rows, I'm just going to be safe. Let's run this, and now it has changed it. So let's read in this file again, and you'll see how it's changed. Now we have all the numbers, and we have this little bar on the right that allows us to go down all the way to the bottom and all the way to the top, so now we can actually look and kind of skim and see our values. I like that better than just having that, you know, shorter version. Um, we can do the exact same thing on columns as well. So if we look at this one, this is our JSON file; it has the same thing right here. We have what was it? 38 columns, but we can only see, I think it's maybe—it's 20 or something like that; I can't remember—um, but we have 38; we can only see like, let's say, 15 of them or 20 of them. We'll do the exact same thing, and we'll just say pd.set_options.max_columns, and we'll set that to 40 for that one. When we run this—oops, let's get over here—when we run this one again, we can now scroll over and see every single one of our columns. Now that one is, in my opinion, a lot more useful. I like being able to see every single column, so definitely something that you should be using, especially when you have these really large files; you want to be able to see a lot of the data and a lot of the columns. So when you're slicing and dicing and doing all the things that we're about to learn in this Panda series, you know, you know what you're looking at.

I also want to show you just how to kind of look at your data in these data frames as well; that's also pretty important. So let's go right down here, and the very last one that we imported was this one right here, this read_excel. So this data frame is the only one that's going going to read in. Let's run it. Um, this is the last one to be run, so this variable right here, DF, uh, it won't be applied to all these other ones, which we can always go back and change those. Typically you'll do something like data frame two; you want to do something like that. Um, so let's keep data_frame_2. Oops. So what we're going to do is we're going to bring data_frame_2 right down here, and we want to take a look at some of this data; we want to know a little bit more about it. Something that you can do is data_frame_2.info, and we'll do an open parenthesis, and when we run this, it's going to give us a really quick breakdown of a little bit of our data. So we have our columns right here: rank, CCA_3, country, and capital. It's saying we have 234 values in those columns because there's 234—scroll up here—because there's 234 uh, rows; that tells me that there's no missing data in here, at least not, you know, completely missing like null values. There is something something in each of those rows; the count tells me it's non-null, so there's no null values, and it tells me the data type, so it's ringing in as an integer, an object, an object, and an object, and it also tells us how much memory it's using, which is also pretty neat because when you get really really large data types, memory usage and and knowing how to work around that stuff does become more important than when you're working at these really small, you know, sample sizes that we're looking at. We can also do—oops, let me get rid of that—can also do data_frame_2, and we'll do .shape, and for this one we do not need the parentheses, and all this is going to tell us is we have 234 rows and four columns. We're also able to look at uh, the first few values or rows in each of these data frames, so we can just say data_frame_2.head, and if we do that, it's going to give us the first five values, but we can specify how many we want; we can say .head(10); it'll give us the first 10 rows right here. We can do the exact same thing, and let's go right down here, and we'll say .tail, so they'll give us the last 10 rows within our data frame.

Now let's copy this, and let's say we don't want to actually look at all of these values or all these columns; we can specify that by saying df2 and—oops, let's get rid of all of this—and we'll say, with a quote, we'll say Rank, and now we can take just a look at the rank data. Now we can't do that by doing the index, or at least not like this. If we want to use this index that is right here, we can, but there's a very special function called loc and iloc for that, and I'm going to have an entire video on this because it does get a little bit more complex, but there's df2, and there's loc and iloc stands for location and integer location. That's only for the indexes, whether it's the x axis or the y axis; those are the indexes, and for location it's looking for the actual text, the actual string of the index. So if we come up here, that data_frame_2, we can specify 224, and it'll give us this information right here in a little different format. So let's go bracket, and we'll say 224, and when we run this, it gives us our rank, CCA, country, capital, with our values over here, kind of like a dictionary almost. Now let's copy this, and we'll say df2.iloc, and right now these look the exact same, but we haven't really talked a lot about changing the index, and you can change the index to a string or a different column or something like that, and we'll look at that in future videos. The iloc looks at the integer location, so even if these—let's go right up here—even if this index had changed to, let's say, this rank or this CCA_3 or country or whatever you make this index, the iloc will still look at the integer location, so that 224 would still be 224 even if it was Uzbekistan. So then when we look at this, it's going to be the exact same, but if we had changed that index, this loc is the one that we could search on, and we could search Uzbekistan—is that how you spell Uzbekistan? Hey, I nailed it! So that is how you use loc and iloc. Again, I just wanted to show you a little bit about how you can look at your data frame or search within your data frame. Now in future videos, I'm going to dive a lot deeper into a lot of the concepts that we just looked at because I just kind of touched on them. I wanted you to have a brief introduction to them so that in future videos I'm not just dropping everything on you all at once. So hopefully this was a good quick introduction to those topics. Uh, you should be able to read in a file now, see your data frame, and kind of look at it in a few different ways that we just looked at, and I hope that that was helpful. And if it was, be sure to check out all my other videos on Python and pandas, and if you like this video, be sure to like and subscribe below, and I will see you in the next [Music] video. [Music]

Hello everybody. Today we're going to be looking at filtering and ordering data frames in pandas. There are a lot of different ways you can filter and order your data in pandas, and I'm going to try to show you all of the main ways that you can do that. So let's kick it off by importing our data set. So we're going to say data_frame is equal to, and we'll say pandas, and I need to import my pandas, so we'll say import pandas as pd. That's pretty important, I think. Um, so pd.read_csv, and we'll do R, and then we'll say the world_population.csv. So let's run this. All our data frame right here, and this is the data frame that we're going to be filtering through and ordering in pandas. So let's kick it off. The first thing that we can do is filter based off of the columns, so the data within our columns, so Asia, Europe, Africa, or whatever data we may have in that column. Let's go right down here. We're going to say DF, and then within it we're going to specify what column we're going to be filtering on, so we're going to say DF with another bracket, and we'll say rank. So we're going to be looking at this rank column right here, and we'll say in that rank column we want to do greater than 10, and that's actually going to be a lot of them. Let's do less than. So when we run this, it's only going to return these values that are less than 10. We can also do less than or equal to, you know, all of these um, comparison operators, so less than or equal to. So now we have all of the ranks 1 through 10. Now if we look at these countries, we can specify by specific values almost exactly like we did here, but instead of doing a comparison operator like we did right here and including those names, let's say Bangladesh and Brazil, we can use the isin function, almost like an in function in SQL, if you know SQL. So let's go right down here, and we're going to say specific_countries. So right now we're just going to make a list of the countries that we want, and then we'll say Bangladesh and Brazil. So let's go right down here, and we'll say, okay, for these specific countries from the data frame, let's do our bracket; we'll say in this country column, so we'll do data_frame and then another bracket for country. So in this country column we can do .isin and then an open parenthesis, and then look for our specific countries. So we're looking at just this column, and we're saying isin, so we're looking at are these values within this column, and we're getting this error, and this looks very very odd. Let me—this doesn't look right. There we go. I just had some syntax errors; I apologize. Made it way more complicated than it needs to be, but here's how you use this isin function. So we're looking at Bangladesh and Brazil, and we return those rows with Bangladesh and Brazil.

Really quickly, I wanted to give a huge shout out to the sponsor of this entire Panda series, and that is Udemy. Udemy has some of the best courses at the best prices, and it is no exception when it comes to pandas courses. If you want to master pandas, this is the course that I would recommend; it's going to teach you just about everything you need to know about pandas. So huge shout out to Udemy for sponsoring this Panda series, and let's get back to the video. We can also do a contains function, kind of similar to isin, except it's more like the like in SQL as well. I'm comparing a lot of this to SQL cuz when you're filtering things, I always—my brain always goes to SQL—but in pandas it's called the contains. So let's do—let's actually copy this because I don't want to make the same mistake again. Let's do that, and we'll do the bracket, but instead of .isin, we're going to do .str.contains and then an open parenthesis. So we're going going to be looking for a string if it contain—if it contains—let's do United, almost like United States or or any other United. So let's run this, and as you can see, we have United Arab Emirates, United Kingdom, United States, United States Virgin Islands. So we can kind of search for a specific string or a number or a value within our data or within that column of country now.

So far we've only been looking at how you can filter on these columns; we can also filter based off of the index as well, and there's two different ways you can do it, or two of the main ways: there's filter, and then there's loc and iloc. Loc stands for location, and iloc stands for integer location, and if you've seen other previous videos, I've kind of mentioned those. So we can take a quick look at all of those. So really quickly, we need to set an index because the index right now is uh, not the best. We'll set our index to Country. So let's say df2 is equal to DF.set_index, and we'll say country. I'm just doing df2 because later on I want to use that data frame again, so I'm just going to assign it to another data frame so that we can just easily switch back and forth. So now we have this index as the country, and what we can do is use the filter function. So let's go down here; we'll say df2.filter, and we'll do an open parenthesis, and now we can specify our items. So these are actually going to be specifying which columns we want to keep. So we're going to say items is equal to, then we'll make a list; we'll say continent—hope that's how we spell continent; I'm always messing up with my uh, my stuff here, my spelling—then we'll do CCA_3, because why not? You can specify whichever ones you want. When we run this, it's going to only bring in those two columns. Now by default it's choosing the axis for us, but we can also specify which axis we want to search on. So if we say axis is equal to 0, it's actually going to search this axis; this is the 0 axis; this is the 1 axis. So where our columns are is 1. So if we go back and do 1, we're searching on that 1 axis, or those header axes again, and this is the default, but you can specify that. So if you just want to search on uh, you know, filtering right here, you can do that. And let's actually copy this and do that right down here just you can see what it looks like, but let's search for Zimbabwe, and we'll do Zimbabwe, and we'll be looking at the 0 axis, which is the up and down on the left-hand side, and when we filter on that, we can filter by Zimbabwe by looking just at the country index. We can also use the like just like we did before, and I'll show you the exact same demonstration that we did, which you can say like is equal to, and instead of having to put in a concrete um, text text, you can just say United, just like we did before, and we're searching where the axis is equal to 0, which again is this left-handed access. So now we're looking for United, and it's going to give us all of the countries or all the indexed values that have United in it. Like we were talking about before, we also have loc and iloc. So we can say data_frame_2.loc. Now this is a specific value, so we'll do United States. So location is just looking at the actual name or the value of it, not its position. So if we search for United States, it's going to give us this right here, where it gives us all of the columns for United States and then all of the uh, values for United States. Or we can do the iloc, which is the integer location, which is not the exact same.

Because we're looking at the string for the L, we're looking at this string, but underneath it, there still is a position that's that integer location. Let's do a completely random one; let's just say three. If we look at the third position, it's going to give us ASM, which I'm not exactly sure what it is, but it still gives us basically the same kind of output, which is the columns and the values. So that's another way that you can search within your index when you're actually trying to filter down that data.

Now let's go look at the order by, and let's start with the very first one that we looked at. Let's do data frame; that's why I kept it because I wanted to use it later. Now we can sort and order these values instead of it just being kind of a jumbled mess in here. We can sort these columns however we would like: ascending, descending, multiple columns, single columns. Let's look at how to do that. So we'll say data frame, and then we'll do data frame. Look at rank again, just like we were doing above, and let's do data frame where it's less than 10. I should have just gone and copied this; I apologize. So now we have this data frame that is greater than 10. Now we can do .sort_values, and this is the function that's going to allow us to sort everything that we want to sort. So we can do by= and we'll just order it by the exact same thing that we were doing or calling it on; we'll do rank. So now what this is going to do, it's going to order our rank column, and as you can see, it did that: 1, 2, 3, 4, 5. We can also do it with ascending or descending. So if you want to, you can look here and see what you can do. So we'll do ascending; we'll say that's equal to true, and so that's the automatic default, so that didn't change anything. But if we say false, it's going to be descending from highest to lowest. So now we have it in the opposite direction.

Now we don't have to just order or sort this on one single column; we can do multiple columns, and we can do that by making a list right here. Whoops, make a list just like that, and we'll input different ones as well. So now let's input our country, and when we run this, it will give us rank of 9, 8, 7, 6, as well as the country of Russia, Bangladesh, Brazil. Now if you noticed, the country really didn't change because the rank stayed the exact same. That's because there's an order of importance here, and it starts with the very first one. If we change this around and we look at this one and put a comma right here, now the country is going to be descended, and the rank would come second. So it's not going—the rank isn't going to really have any effect here. So now we have the country: United States, Russia, Pakistan, and the rank really didn't get ordered at all.

Now if we want to see how that can actually work, let's do continent right here and actually put it right here and do country here. So if we run this, it's first going to come, and it's going to organize or sort the continent, then it's going to come back and go to the country, and then it's going to sort the country. So keep—so keep your eye right here in this Asia area because we're going to sort this differently than ascending. So we have ascending=false, and that applies to both of these; it's false and false, but we can specify which one we want to do. We can do a false here and a true here. So we'll do false, comma true, and what this is going to do is it's going to say false for the continent, so the continent right here is going to stay the exact same, and so that is a lot of how you can filter and order your data within pandas. I hope that this was helpful. I hope that you enjoyed this video. If you liked it, be sure to like and subscribe below. Check out all my other videos on Python and pandas, and I will see you in the next [Music] video.

Hello everybody. Today we're going to be looking at indexing and pandas. If you remember from previous videos, the index is an object that stores the access labels for all Panda objects. The index in a data frame is extremely useful because it's customizable, and you can also search and filter based off of that index. In this video, we're going to talk all about indexing, how you can change the index and customize that, as well as how you can search and filter on that index, and then we're also going to be looking at something a little bit more advanced called multi-indexing. You won't always use it, but it's really good to know in case you come across a data frame that has that. So let's get started by importing pandas: import pandas as pd.

Now we'll get our first data frame: we say DF = pd.read_csv, and I've already copied this, but we're going to do R, and we're going to put this file path. So I have this world population CSV; I will have that in the description, just like I do in all of my other videos. Let's run DF, and let's take a look at this data frame. So we have a lot of information here: we have rank, country, continent, population, as well as the default index from zero all the way up to 233. Now if you haven't watched any of my previous videos on pandas, the index is pretty important, and it's basically just a number or a label for each row. It doesn't even necessarily have to be a unique number; um, you can create or add an index yourself if you want to, and it doesn't have to be unique, but it—it really should be unique, uh, especially if you want to use it appropriately for what we're doing. The country is actually going to be a pretty great index because the country, you know, is going to be all unique because we're looking at every single row as a different um country, as well as the population. So let's go ahead and create this country or add this country as our index.

Now we can do this in a lot of different ways, but the first way that you can do this if you already know what you are going to create that index on is we can just go right in here when we're reading in this file, and we'll say comma index_oops, I—I spelled that completely wrong—index_column, and we'll say that is equal to, and then we're going to say quote country. So we're taking this country, and we're going to assign it as the index. Now let's read this in, and as you can see, this is our index now. It looks a little bit different; we didn't have this country header right here, which is specifying that this is still the country, but you can tell that this is the index based off the um bold letters, as well as it being on the far left, and all the regular columns for the data is over here while the country header is right here, and it's lower than all the others. Just a quick way that you can see that that is the index. Now before we move on, I want to show you some other ways that you can do this as well, but I'm going to show you how to reverse this index before we move on, and we'll say data frame. So we had our data frame right here, so we have data frame dot we'll say reset_index, and then we'll say in_place=True, which means we don't have to assign this to another variable and all that stuff; it'll just be true. So now when we run that data frame again, the index was reset to the default numbers.

So now let's go down here; I'll show you how to do this in a different way. You can do DF dot we'll say set_index, and then we'll just say country. So very similar to when we were reading in that file, and we said set the index or that index column; we said index_column=country. If we do this and we run it in, it works, but if we say data frame right down here, it's not going to save that. If we want to save it just like we did above, we're going to say in_place=true. That is going to save it to where we don't have to assign it another variable. So now when we run this, the data frame right here, which is going to populate this—the data frame is going to say in_place=true, so that country will now be our index again. Let's run this, and there we go. Really quickly, I wanted to give a huge shout-out to the sponsor of this entire panda series, and that is Udemy. Udemy has some of the best courses at the best prices, and it is no exception when it comes to pandas courses. If you want to master pandas, this is the course that I would recommend; it's going to teach you just about everything you need to know about pandas. So huge shout-out to Udemy for sponsoring this Panda series, and let's get back to the video.

Now what's really great about this index is we're able to search based off just this index, and so we can filter on it and basically look through our data with it. And there are two different ways that you can do that—at least this is a very common way that people who use pandas will do to kind of search through that index. The first one is called loc, and there's loc and iloc; that stands for location or integer location. Let's look at loc first. Let's say df.loc, and then we'll do a bracket. Now we're able to specify the actual string, the label. So let's go right up here, and let's say Albania. So we'll say Albania. So again, this is just looking at the location. Let's run this. Now it's going to bring up all the Albania data, just like here where it's kind of looks like a column in a column, and we can get this exact same data but using iloc right here. And when we ran loc, we were searching based off Albania, which is in the 0, 1 position. So if we actually pull the one position for that integer, the iloc, we can look at the one position, and this should give us the exact same data.

Now let's take a look at multi-indexing, and we'll come back to a little bit of this in a second. So multi-indexing is creating multiple indexes; we're not just going to create the country as the index now; we're going to add an additional index on top of that. So let's pull up our data frame. Right now we have the country, but let's do .reset_index, and we'll say in_place=true. Oops, let's run it. So now we have our data frame. Now let's set our index, but this time when we set our index, we're going to add the country as the index as well as the continent as an index. So we'll say data frame.set_index, then we'll do a parenthesis, and instead of just doing country like we did before, we're going to create a list, oops, and we'll do it like that, and then we'll say oops continent and separate it by a comma. So we have continents and Country. Let's just say in_place=true. Now when we run this, we're going to have two indexes, and let's see what this looks like, and let's run this. So now we have country as well as continent as our index. Now you may notice that these indexes are repeating themselves on this continent index; we have Europe right here and Europe right here, as well as Asia and Asia, and it looks a little bit funky, but we are able to sort these values and make them look a lot better. So let's go ahead and try this; we'll do DF.sort_index, and when we run this, it should sort our index alphabetically. And we can also look in here and see what kind of things we can, you know, specify. We can specify the axis, but it's automatically going to be looking at the zero; this is zero, and this is one. So we have two axes within our data frame; you can choose the level, whether it's ascending or not ascending, in_place, kind, string, sort_remaining—all of these different things. The only one that I really, you know, think is worth looking at is the ascending; we already know some of these other ones, but if we look at ascending, let's run it. Now it's sorted these, and so now it's kind of grouped together, so we have Africa and all the African ones, as well as South America and all the South American ones. Let's really quickly say pd.set_option, and we'll say display.max_columns, and just like this, let's run it, and I need to specify—whoops—specify right here. Let's see how many rows we have: 235. So let's do 235. Let's run this, and now when we run this, you can see that Africa is all grouped together, and all the countries are in alphabetical order under it, and then we go all the way down to Asia, and again, just all in alphabetical order. If we wanted to, we could say ascending=true, and then when we run this—oh, I meant to say false—and then when we run this, it's the exact opposite, so it starts with South America, the last one, and then goes in reverse alphabetical order. We could also say false, make it a list, and do comma true, and just like this, and then it would sort this first column as false and this next column as true. So you can really customize it, but, you know, for what we're doing, we don't need any of that; we just need to be able to see this right here. So now when we try to search by our index like we did before, we did data frame.loc. Now when we did that and we said, you know, let's say Angola, when we specified Angola, it's not going to work properly because it's searching in this first index for the first string that we have. We can search Africa; let's search for Africa, and now we have all of the African countries. And if we want to specify to Angola, we can also go down another level, oops, by doing Ang Angola, and now we have what we were looking at before where we're calling all the data within those, but we couldn't do it just based off Africa because we had an additional index right here. So once we called both indexes, now we get this view. But let's look at that iloc really quick. When we run this, let's just say one because right up here—oh, we have Angola zero and then one. So you think it may pull up Angola. Let's go ahead and run this, and it's still pulling up Albania. Let's go right up here. If you remember when we didn't have the multiple indexes, it was pulling up Albania. The difference when you're doing these multi-indexes is that the—the loc is able to specify this, whereas this one does not go based off that multi-indexing; it's going to go based off the initial index or the integer-based index. So that's a lot about indexing in pandas. We'll cover even a few more things in future videos as we get more and more into pandas, but this is a lot of what indexing looks like within pandas, and again, super important to learn how to do and know how to do because it's a pretty important building block as we go through this Panda series. So I hope you enjoyed this video on indexing. If you did, be sure to like and subscribe below, and I will see you in the next [Music] video.

Hello everybody. Today we're going to be taking a look at the groupby function and aggregating within pandas. Groupby is going to group together the values in a column and display them all on the same row, and this allows you to perform aggregate functions on those groupings. So let's start reading in our data and take a look. So we're going to do import pandas as pd, and then we're going to say our data frame is equal to, and we'll say pd.read_csv, we'll do an open parenthesis, R, and our file path, and we're going to be looking at the flavors CSV right here. So right here we have our flavor of ice cream, we have our base flavor, flavor, whether it was vanilla or chocolate, whether I liked it or not, the flavor rating, texture rating, and its overall or its total rating. Now these are all my own personal scores, so you know, I've spent years researching this, so these are all very accurate, but this should be a low-stress environment to learn groupby and the aggregate functions. So the first thing that we can do is look at our groupby. Now you can't group by—well, you can—you can group by flavor, but as you can see, these are all unique values. What we need is something that has duplicate values or—or similar values on different rows that'll group together. So this base flavor is actually a perfect one to group it on, and we'll do that by saying DF.groupby, do an open parenthesis, and we'll just specify base flavor, and this will then group together those values, and I need to make sure I can spell properly. This will group those flavors together. So let's run this, and as you can see, it actually is its own object, so it has a groupby data frame GroupBy object. So now that we've grouped them, let's give it a variable, so we'll say group_by_frame; let's say that's equal to. Let's copy this; we'll run it, and now what we need to do is run our aggregations in order to get an output. So we're going to say mean, and that's all we're going to put just for now, just to get an output that we can take a look off, and then we'll build from there. So let's go ahead and run this, and right here we have our base flavor, which is now saying is the index of chocolate or vanilla, and then it's taking the mean or the average of all the columns that have integers. Notice that it did not take the liked column, and it did not take the flavor column because those are strings, and they cannot aggregate those, and we'll take a look at that later, but it took all the values that have integers, and then it gave us the average of those ratings. Really quickly, I wanted to give a huge shout-out to the sponsor of this entire Panda series, and that is Udemy. Udemy has some of the best courses at the best prices, and it is no exception when it comes to pandas courses. If you want to master pandas, this is the course that I would recommend; it's going to teach you just about everything you need to know about pandas. So huge shout-out to Udemy for sponsoring this Panda series, and let's get back to the video.

So right off the bat, as averages with chocolate, I have a much higher rating overall than the ones with vanilla bases. Now we can actually combine all of this together into one line, and we can do something like this. So we'll say DF.groupby, and we'll say mean just like this, and this will actually run it. Before we didn't have any aggregating function on there, so it didn't run, but now that we combine it all into one, it will run properly. Now there are a lot of different aggregate functions, but I'm going to show you some of the most popular ones or the most common ones that you will see. So let's copy this right here, so we can do .count, and when we run this, we can look at the count, and this will show us the actual count of the rows that were aggregated. So for chocolate, we have three, so there're going to be three all the way across, and for vanilla, we had six, so we're looking at a higher count of vanilla, which, if you're comparing it to this mean up here, that could be a big skew towards the chocolate because if you have one or two good chocolates, it could really pull the numbers up, whereas if you had two good vanillas but all the other ones were bad, it pulls that average down. So knowing the count of something—something is really good. Let's take a look at the next one, and we can do min and max, and I'll just run these really quickly. We can do min, and when we run this, the first thing that you should notice is that it now has a flavor and a liked column, and that's because min and max will actually look at the first letter in the string or the first set of letters if there are—you know, chocolate something—it'll look at the first, and then

It'll actually populate it so chocolate with the CH chocolate is the very first, or the minimum value for that string. And for a cake batter, that is the minimum value in vanilla as well. Now with the liked, it's interesting because apparently I liked all the chocolate ones. I'm going to go take a look. So chocolate, I liked chocolate, I liked chocolate, I lik-- so there is no, no option in this liked column. So yes was the only option. And now let's look at Max, whoops, and it should do the exact opposite, which is going to take the highest value, even if it's a string. So Rocky Road, the letter r comes later in the alphabet, so that's what it's looking at. And so does vanilla, and then we have yes as well. And then, of course, right here it's taking the max value. So before when we were looking at Min, I just focused on those, but it still does the exact same thing to these integer, um, columns as well. So for the max value for vanilla, it was mint chocolate chip that was our base. So I had a rating of 10 for this vanilla row or grouping. And then we can also look at the sum, and there are all the sums for these. And again, it only does integer because we can't add the strings. Here are the sum or the total values for all of them. And for the total values, since we had, you know, six rows that were grouping into this vanilla, we now have a lot of, a much higher score for vanilla.

Now that's a really simple way to do your aggregations, but there is actually an aggregation function. And let's take a look at this CU. This is, um, a little bit more complex, although when I write it out or show you, I hope it makes a lot of sense. We can do a-- so this is our aggregate function, and what we need to pass into our aggregate function is actually a dictionary. So let's do an open parenthesis, and we're going to do a squiggly bracket, and then we need to specify what we're going to be aggregating on, or what column. So let's do this flavor rating; let's copy this. We'll do flavor rating, and I need to put that as a string, and then we'll do a colon. And now we can specify what, what aggregate functions we want. So we've done sum, count, mean, Min, and Max, all of those, and we can actually put all of those into here and perform all of those aggregations on just one column. So let's make a list, and then let's say mean, Max, count, and uh, what's another one? Sum. So let's do all four of those only on this flavor rating column. And when we run this, we have our base flavor right here, chocolate and vanilla, but now we don't have multiple columns; we have one column with multiple columns of our aggregations. And it is possible to pass in multiple columns like that. So we'll do texture rating, and we'll just come right here and do a comma, then we'll say uh, uh, texture rating, and then a colon. I don't know why I spelled it out when I copied it, but I did, and then we'll do the exact same ones. And now when we run it, we're getting the exact same columns, mean, Max, count, and sum for flavor rating, then mean, Max, count, and sum for our texture rating.

Now, so far we've only grouped on one column, but we can actually group on multiple columns. Let's go back up here to our data, and I should have just copied this down here. Let's go back down and just look at this. So really, we only grouped it on this base flavor, but you can do multiple groupings or group by multiple columns. So let's do our base flavor, which we did already, as well as the liked column. So we're going to say DF.dog.GroupBy, then we'll do an open parenthesis, and then instead of just passing through one string, we're going to do a list, and we'll say base flavor, oops, comma, and then we'll do liked. So now when it groups this, it should put, put two groupings. And let's run this and just see. Oops, I got to say, let's just do mean. So now we have our chocolate and vanilla, and remember chocolate only had yes, so that's the only one that it's going to group on. But vanilla had a no and a yes. So if we look at the vanilla, we have our base flavor vanilla, and then within liked we have no and a yes, which can show us that within our vanilla when we group on these, our NOs were really low, but our yeses were really high. We actually had a pretty similar rating, or very close to the same rating, as the ones we really liked in chocolate. And just like we did above, we can take this doag, and I'm going to copy this, and it'll perform it on each of those rows. Let me close that, and what did I do wrong? Oh, I need the squiggly bracket, and it'll show us each of those. So the mean, Max, count, and sum for all of the chocolate and vanilla, as well as the groupings of liked yes and no.

Now, after we've looked at all that, and that's how I usually do it, there is one, uh, shortcut function that can give you some of these things just really quickly. And so let's go back up here and take this. It's just called describe, um, and if you've ever done it, it's just going to give you some high-level overview of some of those different aggregations. So let's run this, and it's going to give us our chocolate and vanilla, and within each column it's going to give us our count, our mean, our standard deviation, I believe is what that is, our minimum, 25%, 50, 75, and 100, which is our Max, then our count and our means. So a lot of those aggregate functions, but the describe is, you know, a very generalized, um, function. We can't get as specific as we were with the previous ones that we were looking at, but I just wanted to throw this out there in case this is something that you'd be interested in, because it, you know, technically is showing a lot of those aggregate functions, just, you know, all at one time. So that is our GroupBy and aggregate functions within pandas. I hope that that was helpful. I hope that you understood, you know, everything that we were working on. If you like this video, be sure to like and subscribe, and check out all my other videos on Python, as well as pandas, and I will see you in the next [Music] video.

Hello everybody. Today we're going to be talking about merging, joining, and concatenating data frames in p-- do this. This whole video is basically around being able to combine two separate data frames together into one data frame. These are really important to understand when we're actually using the merge and the join. Right here we have what's called an inner join, and the shaded part is what's going to be returned; it's only the things that are in both the left and the right data frames. Then we have an outer join, or a full outer join, and this will take all the data from the left data frame and the right data frame, and everything that is similar. So basically, just takes everything. We also have a left join, which is going to take everything from the left, and then if there's anything that's similar, it'll also include that. And then the exact opposite of that is the right join, which is going to give us everything from the right data frame, and it's going to give us everything that is similar, but it's not going to give us anything that is just unique to the left data frame. So this is just for reference because in a little bit, when we start merging these, these become very important. So I just wanted to kind of show you how that works visually.

So let's get started by pulling in our files. So first we're going to say import pandas as pd. We'll run this, and then we'll say data frame one, and we'll also have a data frame two. And these are the different data frames, the left and the right data frame that we'll be using to join, merge, and concatenate. So we'll say data frame 1 is equal to pd.CSV.read, and we'll do R, and here is our file path. So we have this lr.CSV, that's our Lord of the Rings CSV, and let's call that really quickly so we can see what's in there. And I'm having a dyslexic moment, uh, because it's supposed to be reor.CSV, uh, I apologize for that, but this is our data frame; this is our data frame one. We have three columns: it's their Fellowship ID, 10001, 2, 3, and 4; their first name, Froto, Sam, Wise, Gelf, and Pippen; and their skills, hide and gardening, spells and fireworks. So this is our very first data frame that we're going to be working with. Let's go down a little bit; let's pull this down here, and we're just going to say data Frame 2, Data Frame 2, and this is the Lord of the Rings 2. So let's pull this one in now. As you can see, it's very similar. We have Fellowship ID 1, 2, 6, 7, 8. So we have three different IDs here; we don't have 6, 7, and 8 in this upper, this first data frame. We also have the first name, so Froto and Sam, or Samwise, are in the very first and the second data frame, but now we have three new people, Barir, Eland, and Legalis, and now we have this age column, which again is unique to just this second data frame.

Really quickly, I want to give a huge shout out to the sponsor of this video, and that is Zendesk. I've been using Zendesk for my company's customer analytics, and it has been absolutely phenomenal. They're going to be hosting a conference called Zendesk Relate on May 10th, and they're going to talk all about customer analytics, chatbots, and AI in this space. You can attend in person in San Francisco, or you can attend virtually, but space is limited, so be sure to apply if you want to attend. So if you are a business leader and you want to make most out of your customer data, or you want to learn customer data analytics, I will leave links in the description. Again, huge shout out to Zendesk for sponsoring this video.

Now the first one that I want to look at is merge, and I want to look at merge first because I think this one is the most important; I use this one more than any of the ones that we're going to talk about today. The merge is just like the joins that we were just looking at, the outer, the inner, the left, and the right, and there's also one called cross, and I'll show you that one, although if I'm being honest, I don't really use that one that much, but it's worth showing just in case you come into a scenario where you do want to do that. So let's go right down here, and I want to be able to see these while we do it. So we're going to say data frame one, and when we specify data frame one as the very first data frame, we say data frame.merge. This is automatically going to be our left data frame. Then if we do our parentheses right here and we say data Frame 2, this is our right data frame, and let's see what happens when we do this. So what it's going to do, and this we didn't specify this, it's just a default, it's going to do an inner join. So it's only going to give us an output where specific values or the keys are the same. Now you can't see this, but what is happening is is it's taking this Fellowship ID and saying I have 101 here, a 102 here; this is the exact same as up here with this Fellowship ID and fellowship ID of 101 and 2. But when we look at 3 and 4, those aren't in this right, right data frame, and 6, 7, 8 is not in this left data frame. So the only ones that match are this 101 and 2, and that's why they get pulled in down here. But because we didn't explicitly say here's what I want to join or merge between these two data frames, it actually is looking at the Fellowship ID and the first name. So it's taking in these unique values of Froto and Samwise, which are the same in both, which is why I pulled it over. But really quickly, let's just check and make sure that we did it on the inner join because, again, we didn't specify anything; that was just the default. So we're going to say how is equal to, and then we'll say inner, and if we run this, it's going to be the exact same because, again, the inner is the default. But now just to show you how it's kind of joining these two, uh, data frames together, I'm going to say on is equal to, and then I'm only going to put Fellowship ID. So let's run this. Now the first thing that you may have noticed is this first name_x and this first name_y. What the merge does as kind of a default is when you were only joining on a Fellowship ID, we have this right data frame with Fellowship ID, the left data frame with the Fellowship ID. If you're just joining on these and you're not joining on the first name and the first name, then it's going to separate those into an _x and an _y. And even though they have the exact same values, since we are not merging on that column, it automatically separates that into two separate columns, so we can see the values within each of those columns. If we went into this on and we make a list and let's do it like that and we say comma and then we write first name, oops, first name, and then we run this, it's going to look exactly like it did before. Again, it automatically pulled in both of these columns when it was merging at the first time, even though we didn't write anything. But if we actually write this, this, it's doing exactly what it was doing when we just had df2; we're just now writing it out.

Now there are other arguments that we can pass into this merge function. Let's hit Shift+Tab, and let's scroll down here. So within this merge function, we have a lot of different arguments that you can pass into it. First, we have this right, which is the right data frame, which is this data frame two. Then we have the how and the on, which we've already shown how to do. There's a left_on, right_on, left_index, right_index; not something you'll probably use that much, but you definitely can if you want to look into that, and there's all these doc strings which show you exactly how to use all of these. So if you're interested in looking at the left and the right and the left index, it's all in here. The one that is really good is the sort, and you can sort it saying either it's false or true. Then we have these suffixes. Now if you remember when we took these out, what it automatically did was it put in these _x and _y. You can customize that, and you can put in whatever you'd like instead of the _x and _y; you can put in some custom, um, string for that. We also have an indicator and a validates. Again, all things you can go in here and look at. I'm just going to show you the stuff that I use the most. So these things right here are things that I definitely use the most. So now that we've looked at the inner join, let's copy this right down here, and let's look at the outer join, and these get a little bit more tricky. I think the inner join is probably the easiest one to understand. Well look at the outer; it's spelled o-u-t-e-r. I don't know why I always want to say o-t-t-r, but let's run this and see what we get. So now this looks quite different. The inner join only gave us the values that are the exact same; this one is going to give us all of the values regardless of if they are the same. So we have 1, 2, 3, 4, 6, 7, and 8. So let's scroll back up here. So we have 1, 2, 3, 4, 1, 2, and 6, 7, 8. So we don't have a 5, and then if you notice in this data frame right here, if the value doesn't have-- so if we can't join on the Fellowship ID or the first name, like Legalis wasn't one that we joined on or that has a similar value in the left data frame, it just gives us an NaN, which is not a number, and it's going to do that for any value where it couldn't find that join or it couldn't match, uh, something within that either ID or first name. So in age, we also have that for the ones that weren't in the right data frame; we only had 101 and 102, so we'll have the age for both Froto and Sam, but for Gandalf and Pippen, we don't have their corresponding IDs, and so it's just going to be blank for Gandalf and Pippen, and you can see that right here. So again, outer joins are kind of the opposite of inner joins; they're going to return everything from both; if there is overlapping data, it won't be duplicated.

Now let's go on to the left join, and I'm going to pull this down right here, and now we're just going to say how is equal to left, and let's run this. So what this is going to do is it's going to take everything from the left table or the left data frame right here, so everything from data frame one. Then if there is any overlap, it'll also pull the overlapped, or the, you know, whatever we're able to merge on from data Frame 2. So let's go back up to our data frame 1 and 2. So it's going to pull everything from this left data frame because we're specifying we're doing a left join, so everything from the left data frame will be in there. We're also going to try to bring in everything from the right, but only if it matches or, or is able to merge. So just this information right here will come over; we weren't able to join on 6, 7, or 8, so really none of that information is going to come over. So let's go down and check on this. So again, we have 1, 2, 3, 4, all of the data with this first name and skills; everything is in here, but then we are trying to bring over the age, but we only have matches with 1 and 2, so only these two values will come in. Let's look at the right join, because it's basically the exact opposite. Let's look at the right, and this is basically the exact opposite of the left in the fact that now we're only looking at the right hand, and then if there's something that matches in data frame one, then we will pull that in. So this, this is basically just looking like data Frame 2, except we're pulling in that skills column, and since only 1 and 2 are the same, that's why the skills values are here.

Now those are the main types of merges that I will use when I'm using a data frame or when I'm trying to merge a data frame, but there also is one called a cross or a cross join, uh, and let's look at this one, and this one is quite a bit different. Here we go. Let's run this. So this one is different in that it takes each value from the left data frame and compares it to each value in the right data frame. So for Froto in this left data frame, it looks at the Froto in the right data frame, Samwise in the right data frame, Legalis, Elon, and Baromir, all on the right data frame. Then it goes to the next value, Samwise, and does the exact same thing: Froto, Samwise, Legalis, Elon, Baromir, and it does that for every single value. So let's go right back up here. So it's taking this, this, this 1, it's comparing it to 1, 2, 3, 4, 5. Then it's taking Samwise, it's comparing it to 1, 2, 3, 4, 5. Gandalf, 1, 2, 3, 4, 5. Pippen, and then you kind of see that pattern, and that's what a cross join is, um, there are very few, in my opinion, reasons for a cross join, although you'll, if you ever do like an interview where you're being interviewed on Python, you will sometimes be asked on cross joins, but there aren't a lot of instances in actual work where you really use, need a cross join.

Now let's take a look at joins, and joins are pretty similar to the merge function, and it can do a lot of the same thing, except in my opinion, the join function isn't as easily understood as the merge function; it's a little bit more complicated, um, but let's take a look.

See how we can join together these data frames using the join function. So let's go right up here; we're going to say data frame one.do join, and then we'll do data frame two. Very similar to how we did it before. Let's try running this, and it's not going to work. Um, when we did the merge function, it had a lot of defaults for us. Let's go down and see what this error is. It says the columns overlap, but no suffix was specified. So it's telling us that it's trying to use the Fellowship ID and the first name, just like the join did, except it's not able to distinguish which is which. And so we need to go in there and kind of help it out a little bit. Again, a little bit more hands-on than the merge, but let's see what we can do to make this work. Let's do a comma and we'll say on. Let's really quickly let's open this up and kind of see what we have. So this one has less options than the merge does. We have other, and that's our other data frame. We can do on, and we're going to specify, you know, what column do we want to join on? And then we can look at how do we want it to be: a left, an inner, an outer—the same kind of types of joins as the merge. Then we have that left suffix, right suffix, and that's right here is kind of part of the issue that we were just facing—is that those columns are the same. But if we say left suffix, it'll give us an underscore whatever we want to specify; any string for columns that are both in the left and the right, we can give it a unique name, so we'll no longer have that issue. And then we can also sort it like we did on the other one. But anyways, let's go back to our on. We'll say on is equal to, and then we'll say Fellowship ID. Let's try running this, and we're still getting an error. It's just not as simple as the merge, so let's keep going. So now let's specify the type, so we'll say how is equal to, and we'll do an outer. If we run this, it still doesn't work; we're still getting the exact same issue as the left suffix and the right suffix. So now let's finally resolve it. I just wanted to show you how a little bit more frustrating it was. But now let's say, uh, lsuffix is equal to, and now it automatically, when we did the merge, did an underscore X, but we can do let's do underscore left, and then we can do a comma; we'll do right suffix, and we'll say is equal to, and we'll do underscore right. Now when we run this, it should work properly. Let's run this. So this is our output, and obviously looks quite a bit different. Over here, we have this Fellowship ID; then we also have Fellowship ID left, first name left, Fellowship ID right, and first name right. So it just doesn't doesn't look right. Now, something I didn't specify when I first started this, cuz I kind of wanted to show you, is that the join usually is better for when you're working with indexes. Before, when we were using the merge, we were using the column names, and that worked really well, and it was pretty easy to do. But as you can see right here, when we're trying to use these column names, it's not working exceptionally well. Let's go ahead and create our index, and then I can show you how this actually works and how it works a little bit better when we're working with just the index. Although you can get it to work just the same as the merge, it's just a lot more work. So let's go right down here, and let's go and say df4. So we'll create a new data frame; we'll say df1.set_index, and we'll do an open parenthesis, and we'll say we want to do this index on the Fellowship ID, and then we're going to do the join. So now we're going to say join. So we're setting an index; so we're setting that index on the Fellowship ID. Now we're we're going to join it on df2.set_index, and then we're also going to do that on the Fellowship ID. I'll just copy this. Oh geez, I hate it when I do that. Okay. Now we also want to do and specify the left and the right index, so I'll just copy this, as we do need to specify this. Now let's try running the data frame 4. So really quick, just to recap, we were setting the indexes; we were doing the same thing above, right? We have this join; we were joining data frame one with data frame two. Now we're joining data frame one with data frame two, except in both instances we're setting the index as Fellowship ID, so we're joining now on that index. So now let's run this, and this should look a lot more similar to the merge than the join that we did above, except now the Fellowship ID right here is actually an index, so it's just a little bit different, but we can still go in here and do how is equal to Outer. Oops, let's say outer. So we can still specify our different types of joins, or the different way that we can merge or join these data frames together. We can still specify that. Again, it's just a little bit different, and that's why for most instances I'm using that merge function, because it's just a little bit more seamless, a little bit more intuitive. The join function can still get the job done, but as you can see, it takes a little bit more work.

Now let's look at concatenate. Concatenating data frames can be really useful, and the distinction between a merge and join versus the concatenate is that the concatenate is kind of like putting one data frame on top of the other, rather than putting one data frame next to one another, which is like the merge and the join. So concatenating them is just a little bit different in how it'll operate, but let's actually write this out and see how this looks. Let's go up here, and we'll say pd.concat; we'll do an open parenthesis, and then we're going to concatenate data frame one, comma data frame two. That's all we have to write, and let's run this. And so just like I said, it literally took the first data frame 1, 2, 3, 4 and put it on top of the right data frame 1, 2, 6, 7, 8. So that is our left data frame; this is our right data frame, and they're literally just sitting one on top of the other. But just like when we merge, either with a left or a right, when you have these skills and there aren't any values that populate for them, it is going to say not a number. And since we're not actually joining, we're not joining on one and two, even though this one and this one is the same rows, it's not populating that value because, again, we're not joining these together; we're just concatenating and putting one on top of the other. Now, if we go into this concat, we say shift tab, there are a lot of different things that we can do, which if you remember the zero axis is the left-hand index, and the axis of one is the top index, which is the columns. So you can specify that, and we can also do joins, and this is the one that I'm going to take a look at, but there are other ones that you can um look into as well. Let's look at join. Let's do a comma, and we'll say join is equal to, and let's do an inner join. So let's see what happens with this. As you can see, it is only taking the columns that are the same; that's what this inner is doing. It's joining these columns together, and the ones that were different, they didn't take, because again, we weren't able to combine them; they aren't similar between both frames. Let's do an outer, and now it's going to take all of them. And like I said, that's doing this on these columns right here, but we can also do it on this axis as well. So let's go ahead and say axis is equal to one, and when we run this, now it's joining us on this index right here of 0, 1, 2, 3, 4. So now these ones are being joined together, and it's putting it side by side, much like a merge would. So that's how concatenate works, and I'm going to show you one more thing, and again, it's not up here in this, you know, title because it's not one that I recommend, but is one called append. The append function is used to append rows from one data frame to the end of another data frame, and then we can return that new data frame. And so let's do data frame one.append; we'll do an open parenthesis, and we'll say data frame two. Very similar to how we've been doing other things, and let's run this. And as you can see, this is almost exactly like how the concatenate did when we first did it. But if we read kind of this warning, it's saying the frame append method is deprecated and will be removed from pandas in the future version; use pandas.concat instead. So it's literally warning us, you know, append is on its way out. If you want to do exactly what you're doing right here, go and try concat or concatenate, because that'll do the exact same thing. So I'm not really going to show you any other variations of append, because there's no reason; it's going to be on its way out in the next version. So that is our video on merge, join, and concatenate, and append as well, uh, in pandas, and I hope that that was helpful. I hope that you learned something. I mean, this stuff is really important because often times you're not just working with one CSV or one JSON or one text file; you're working with multiple of them, and you need to combine them all into one data frame. And so this is a really, really important concept and thing to understand. With that being said, be sure to like and subscribe; check out all my other videos on Python and pandas, and I will see you in the next [Music] video. [Music]

Hello everybody. Today we're going to be building visualizations in pandas. In this video, we'll look at how we can build visualizations like line plots, scatter plots, bar charts, histograms, and more. I'll also show you some of the ways that you can customize these visualizations to make them just a little bit better. With that being said, let's go right over here, start importing our libraries, and we'll start with importing pandas as pd. And this one is really all you need to actually create the visualizations in pandas, but we may get a little bit crazy, uh, and so we're going to do a few different ones as well, like import numpy as np, and then we're going to do import matplotlib.pyplot as plt. Now I may or may not use this; I just, you know, when I get into visualizations, I may want to change some different things, so we're going to at least have them here in case we do want to use them. Let's go ahead and run this. So now let's get our data set that we're going to be using. So let's say data frame is equal to pd.read_csv, and let's get this in right here. Now we're going to be doing these ice cream ratings. Let's take a look at this really quickly. Now these values are completely randomly generated; they are not real in any way, um, but that's what we're going to be using, cuz I just wanted something kind of generic, something that wouldn't be too crazy, confusing, just something that we could use and you guys can understand that they're just numerical values. But let's also set that index really quick, so we'll say data frame.set_index, and then we'll say date, and then we'll say that's equal to the data frame. And we have this date column right here as our index. So we have uh January 1st, 2nd, 3rd, 4th, and then we have our ratings right here, and again, these are all just integers, and they're pretty easy or are really easy to demonstrate how you can visualize these, so that's why we're using it today. So the way that we visualize something in pandas is we use something called plot. So let's just take our data frame; we'll do data frame.plot, and we'll do our parentheses. Now let's go in here really quickly; let's hit shift Tab, and this is going to come up, and this is pretty important because this kind of is going to tell us what we can do within this plot. And unfortunately, there isn't like a quick overview; we just have this doc string, but we have our parameters right here; these are what we can pass in to kind of customize our visualization. So the data is going to be our data frame; then we have our X and Y labels; we can specify the kind, and this one's important because you can specify what kind of visualization do we want. We can do a line plot, horizontal, a vertical bar plot, histogram, box plot, and then a few others, including area, Pi, density—all these other things. We can also specify if we want it to be a subplot, and a lot of these things that I'm specifying, you know, I'm going to show you how to do; you can use a different indexes; you can add titles, add grids, Legends, Styles—all these different things. I mean, you can go through here; CU there are a lot, but you can specify and and, you know, customize all of these things. We won't be going into all of them, but I will show you some of the ones that I probably use the most and that I think are the most useful to know right away. So let's get out of here, and we're just going to do df.plot, and when we run this, we'll get this right here, and that was super, super easy; created a line plot by literally doing just about nothing—nothing—um, but by default it's going to give us a line plot. So if we come up here, we say kind, and let me get that out of the way, is equal to line, and we run this. So by default, without us actually having to input anything, it's giving us that line plot as a default. So uh we can specify it's a line plot. As you can see, we already have all of our data right here; we didn't have to specify anything; it kind of automatically took it in; it is visualizing all three of these columns, and it has this little um Legend right here, and we can specify where we want that—there is an argument to be able to do that. It also gave us these tick marks of 2, 4, 6, 8, 10. Again, it read in and said it's only going from 0.0 to 1.0; that is kind of the peak, and so it kind of automatically gave us these ticks for us. Again, that's another thing that you can specify; we make it go up to 2, 5, 10, 1,000, whatever you want it to be. And then we're doing this based on off of this date value right here. Really quickly, I wanted to give a huge shout out to the sponsor of this entire Panda series, and that is Udemy. Udemy has some of the best courses at the best prices, and it is no exception when it comes to pandas courses. If you want to master pandas, this is the course that I would recommend; it's going to teach you just about everything you need to know about pandas. So huge shout out to Udemy for sponsoring this Panda series, and let's get back to the video. If we wanted to break these out by the actual column, we could go in here and say subplot is equal to true, and it's actually subplots, whoops, and now we can run that, and then we can see each of those columns being broken out by themselves, instead of them all being in one visualization; it's now uh three separate visualizations. Now let's go right over here; we're going to get rid of the subplots. I want to show you just some of the different arguments that you can use to make this look nice, uh, because I don't want to do this on every single visualization; I just want to show you what you can do. So we have this one right here; we can add a title. Notice there's no title or anything really telling us what that is, so we can say comma title, and we'll say ice cream ratings. If we run this, we now have this nice title right here. Now we can also customize the labels or the titles for the X and Y axes. It automatically took this date, which is right here; this is our date index; it automatically took that for us, but we can customize that if we'd like to. All we have to do is comma, and then we'll say xlabel is equal to, and so our X is this date one right here, and we can say daily rating, and then we can do the Y label; we'll say ylabel is equal to, and for this one we can say scores. Hope you cannot hear my dog in the background, cuz they're being insane, uh, but let's go ahead and run this, and now we have these daily ratings on the x-axis, and on the y-axis we have scores. Now let's go right down here and start taking a look at our next kind of visualization, which is going to be a bar plot. So we'll do df.plot; we'll do kind is equal to, and for this one we're going to say bar. Now this is what your typical bar plot will look like, and a lot of the arguments that we just did on the line plot you can also apply to this bar plot. Something that's unique to the bar plot is that you can also make it a stacked bar plot. All we have to do is go in here; we'll say comma, and we'll say stacked is equal to true. So now this is going to make it a stacked bar chart instead of just, you know, your regular bar chart. Let's go ahead and run this, and as you can see, this is now stacked on top of one another, with each of these columns all representing the values that they have. Now we don't always have to do every single column; we can also specify the column that we want. So let's take the flavor rating, for example; we could do flavor, oops, flavor rating. Good night, flavor rating, and then it's only going to take in that flavor rating column. And if you notice, we don't have a legend; that's only when you have multiple values, which we are only looking at this one column, so all the values are right here. Now, in this bar chart, it automatically defaults to a vertical bar chart, but you can change it to a horizontal bar chart. Let's go ahead and take a look at how to do that. Bring back all of them; we'll do df.plot.dot, and then we'll say barh. And I don't know if I can keep that kind equals bar. Let me run this. Yeah, I need to get rid of that because the bar.h is its own um this is its own function. So now I'm going to run this; it should just have a stacked bar chart, except now it should be horizontal. So now you can see this worked properly; it's basically the exact same thing as a vertical bar chart, just now horizontal, which may look better, especially depending on if you have values like this or, you know, something else that just looks better being horizontal. Now the next one that we're going to take a look at is the scatter plot, so we're going to say df.plot.scatter. Scatter. And if we run this, we're going to get an error. What we need in order to run this properly is we need to specify the X and the Y axes in order for this scatter plot to work. So let's go here, and we'll say x is equal to, and we can take any of our columns that we have up here, so we'll say x is equal to texture rating, and then oops, y is equal to; we'll do overall rating. Now when we run this, it should work properly. Let's go ahead and take a look. Now if we go in here and we do shift tab, we can also see some other things that we can specify. So let's go right down here. So we have our X, and we have our Y, and those are the ones that we just did. We can also pass through an S, which is going to tell us or or change the size of the actual dots right here in our scatter plot. Then we can also do a c, which is the color of each point. Let's start with the S; let's say s is equal to; let's just do 100; let's see what that looks like. So we have a much larger number; let's do 500 and see what

That looks like so we can make these much larger on our visualization, depending on what you're looking for. We can also look at the color. Let's put comma C, so for color we can say color is equal to, and let's do uh yellow. Let's see if this works. So now we've changed it to yellow. That looks absolutely terrible, but it does work. Now let's move on to the histogram.

Histogram is always a good one; it's very similar to something like a bar chart, but what's great about a histogram is you can specify the bins. Um, so let's go ahead and say DF.plot.hist, then we'll do an open parenthesis, and let's go ahead and hit shift tab in here. Take a look at this one as well. So some of our parameters are the actual columns of the data frames that we want to pull in. We get you can choose the bins, and they have a default of 10 in here. And so let's take a look at how this works. So we'll just run this as it is. So this is by default what this histogram is going to look like. Let's go ahead and specify our bins. We'll just say it was 10 by default; let's just do 20, see what that looks like. So there are smaller columns right off the bat, and remember histograms are really good for showing distribution of variables. You know, that's really what a histogram is for, but of course, since these are completely random numbers, this histogram isn't going to make any sense at all, but you can at least kind of see visually how it works. And if I didn't mention it before, which I should have, the bins represent how many kind of tick marks are down here. So if we just do one, only going to be one very large uh, you know, histogram. We could even go further down from 10 and do five. So now there's only one, two, three, four, five. So the distribution gets smaller, and and things get more compact as you spread it out again. Like we did 100, it's going to spread it out a lot, um, and this is what it shows. You know, it's showing the distribution of those bins across however many you want. So the 10 by default, you know, it usually is pretty good for a lot of different things.

Now let's go down here and look at the box plot, and the box plot is a pretty interesting one. Let's go ahead and visualize it really quickly, and then I'll kind of explain how this one works. Let's do DF.boxplot. Let's run this, and really what we're looking at is some different markers within our data. This line right here is the minimum value within that column. We also have the bottom of the box, which is the 25th percentile of all the values within just this column. This is 50%, then we have 75%, and then up here we have our maximum value. So I can take a glance at this and see that we have a low minimum, a high maximum, and it definitely skews towards the lower range, whereas if I look over here, we have a lower minimum and a higher maximum, and you can see that this medium point is at 0.6 versus 0.4 over here. So the skew is a lot higher.

Now let's go down here and take a look at an area plot. We'll do DF.plot.area, and let's just run this. This is what we're going to get by default. Now something I wanted to show you earlier, I just haven't gotten around to, I want to show you something called Figure size or figsize. Um, so for this, it's, you know, it's just looks small; small looks a little bit cramped. Let's say we want to increase the size of this, and we'll say figsize, oops, figsize is equal to, and let's just do a parenthesis and say 10, comma 5. That should be pretty large. This is going to make it a lot larger, just something I wanted to throw in there. I look at these area charts as pretty similar to like a line chart; if we went and compared those, be pretty similar, um, but they're different visually, and you know, you absolutely can use these for different types of visualizations, but I don't use this one a lot if I'm being honest. That's why it's kind of towards the end of the video, but you definitely can do it. Let's go on to our very last one of the video; that's going to be the beautiful pie chart. Let's say DF.plot.pie, do an open parenthesis, and let's run it. We're going to get this error; that's because we need to specify what column we're working with here. So let's just say the Y, and that's what we need. Let me open this up for us right here. We have our Y, and this is our our label or a column that we're going to plot. That's really all we need, so we can just say Y is equal to flavor rating, oops, flavor rating. Let's run this, and now we get this visualization right here. Let's make this one a little bit bigger. Big size is equal to 10, comma 6. Now it's a little bit bigger. It definitely depends. So this legend is going to auto-populate; you know, you can make this as big as you want, and obviously it's going to look a little bit better if you do it larger, and these colors auto-populate. Now you can customize these colors, although I found these ones to be just when you have a lot of them, it's harder to customize them as easily, but you know, definitely look into it. These are things that everything in here is almost something that you can customize in some way, although it does get a little bit tricky. You definitely have to do some research and some Googling around just to kind of figure out how to do those things.

Now one last thing that I wanted to show, and something, you know, I could have probably done at the beginning, um, is you can actually change what visual this is, and we can do that pretty easily within matplotlib. There are different styles, um, and so let's go right here. Let's add a new row, a new cell, and we'll say print, and we'll do PLT, so that's that matplotlib right here. We'll do PLT.style.available, and what this is going to do, whoops, what this is going to do is show us all these different, different types of stylings that you can do to kind of change up this visualization. Then once we find the one that we like, we'll just do PLT.style.use, and then in the parenthesis we'll just specify which one we want. Now there's all these Seaborn ones, and Seaborn is a really great, really great library. Let's try Seaborn deep. I haven't tried this one at all. Let's go ahead and try this, and just changes some of the colors, some of the visuals. We can try something like 538. Let's try this. That looks quite a bit different, and let's try something like um classic. I don't know what this one looks like. Let's just try it. So you can try out all these different styles, find one that you like, find one that you think looks really nice, and you can run with it through all your visualizations. So this has been our video on visualizing data in pandas. I think it's is a really good introduction on how you can visualize data within Python, and in future videos we'll look at matplotlib and Seaborn, which are some really great libraries for visualizing data which I use a lot. So I hope that you enjoyed this video. If you did, be sure to check out all my other videos on Python and pandas, and I will see you in the next [Music] video.

Hello everybody. Today we're going to be cleaning data using pandas. Now there are literally hundreds of ways that you can clean data within pandas, but I'm going to show you some of the ones that I use a lot and ones that I think are really good to know when you are cleaning your data sets. So we're going to start by saying import pandas as pd, and we're going to run that. And now we're going to import our file, so we're going to say data frame is equal to pd, that's pandas, do read_excel, and we actually have this in an Excel file, so we'll say read, oops, say read_excel, do an open parenthesis, esses, and we'll do R, and then we'll paste the path right here. And now we're just going to call that variable, so we'll call data frame, and we'll actually read it in and look at the data. So let's scroll down here and let's take a look at this data frame or this Excel file that we're reading in. So right off the bat we have this customer ID that goes from 101 all the way down to 1020. We have this first name, and everything looks pretty good here except in this last name column; uh, looks like we have some errors. We have some forward slashes, some dots, some null values, um, so definitely going to have to clean that up because we don't want that in the data. We have a phone number, and it looks like we have a lot of different formats, um, as well as NAs, not a number, um, just lots of different stuff. So we're going to need to standardize that, so clean it up and then standardize it to where it all looks the same. Um, we also have address, and it looks like on some of these we just have a street address, but on some of the other ones we have like a street address and another location as well as a zip code in some of them. So we'll probably want to split those out. We have a paying customer, uh, which is yes and Nos, and some of those are not the same, so I have to standardize that. We have a do not contact, kind of the same thing as the paying customer, and we have this not useful column, which we'll probably just want to get rid of. Okay, so the scenario is is that we got handed this list of names and we need to clean it up and hand it off to the people who are actually going to make these calls to this customer list. So they want all the data in here standardized and cleaned so that the people who are making those calls can just make those calls as quickly as possible, but they also don't want columns and rows that aren't useful to them. So things like this not useful column we're probably going to get rid of, and then ones that say do not contact, if it says yes, we should not contact them; we probably will want to get rid of those somehow. So that's a lot of what we're going to be doing to clean this data set.

Normally the very first thing that I do when I'm working with a data set, most of the time except very rare cases when you're actually supposed to have duplicates, is I actually go and drop the duplicates from the data set completely. All you have to do for that is say DF.drop_duplicates. So they make it super easy for you. Let's just run it, and up here is our original data set. We have this 19 and 20, and those are obviously duplicates; they have the exact same data; it's just a duplicate row that we need to get rid of. If we look right down here, we no longer have that 20; we now just have one row of Anakin Skywalker. And of course we want to save that, so we're just going to say DF is equal to, and DF. So now it's going to save that to the data frame variable again, and now when we run this, our data frame now does not have any duplicates. That's definitely one of the easier steps that we're going to look at; uh, things are going to get quite a bit more complicated as we go, but I'm starting out, you know, kind of simple so that we can kind of get a feel for it, and then we'll start getting into the really tough stuff. So the next thing that I want to do is remove any columns that we don't need. I don't want to clean data that we're not going to use. So if we're just looking through here, you know, they may need, you know, first name, last name, phone number for sure; address might give them some information of where they're calling to or time zone, so we want that. This not useful column looks like a pretty good candidate to delete, and it's very easy to do that. We're going to go right down here, and we're going to say DF.drop, and we'll do an open parenthesis. Drop just means we are dropping that column, and we can specify that by saying columns is equal to, and then we'll paste in that column that we want to delete. So let's run this and see what it looks like, and it literally just drops that column exactly like we were talking about; it no longer has that column. Again we want to save that; we can always do in in_place equals true, um, if you follow this tutorial series, you can always do in_place equals true, and that'll save it as well, but just for our workflow, most of the time I'm going to assign it back to that variable.

Really quickly, I wanted to give a huge shout out to the sponsor of this entire Pandas series, and that is Udemy. Udemy has some of the best courses at the best prices, and it is no exception when it comes to pandas courses. If you want to master pandas, this is the course that I would recommend; it's going to teach you just about everything you need to know about pandas. So huge shout out to Udemy for sponsoring this Pandas series, and let's get back to the video. Now let's kind of go column by column and see what we need to fix, and we'll start on this left-hand side. This customer ID to me looks perfectly fine; I'm not going to mess with it at all. The first name at a glance also looks perfectly fine; I don't see anything wrong with it visually, which is a good thing, um, although sometimes that can be deceiving and that can cause errors down the line, but we're not going to uh assume that there are errors in here. Now let's look at this last name. Now the last name obviously I'm I'm seeing some obvious things, things that we talked about when we were first looking at this data set. We have this forward slash, which we definitely need to get rid of. We have null values, so not a number right here. We have some periods as well as an underscore right here. So all those things I think we should clean up and get rid of it so that when the person is making these calls, you know, it's all cleaned up for them. So how are we going to do that? We can actually do this in several different ways, but let's just copy this last name. The first one I'm going to show you is strip, and we'll write it kind of like this: we'll say data frame, and then we'll specify the column that we're working with because we don't want to make these changes or strip all of these values from everywhere; we only want to do it on just this column. If we do this and we don't specify the column name, it will apply to everywhere. So if we're trying to do these, yeah, let's say, bum, these underscores, maybe that would mess with something else in another column, and we don't want that. So we just want to specify just this last name. So let's go last_name.str.strip. Now what strip does, and let's see if we can open this up really quickly; no, we can't, um, but what strip does, I was just I was hitting shift tab in here to see if it could bring up, um, you know, some of the notes on it, but what strip does is it takes either the left side or the right side; lstrip takes from the left side, rstrip takes from the right side, and strip takes from both, but you can strip values off the left and the right-hand side, and we can specify those values. Now for what we're doing in this column, we can just use strip because, as you can see, this forward slash, these dots as well as this um underscore are all on the far sides. If there was a value like swancore Son, the strip wouldn't work at all because it's not on the outside of the value or the word. So we can use strip. I'll also show you how to use replace, and replace is another really good option for things like this, but let's start with strip and just see what it looks like and see if we can get what we need done. So let's just run this for now, see what happens. So it looks like nothing has changed because, again, we're not specifying any specific value; just by default it's only taking out white space, so like spaces that shouldn't be there; that's what it does by default. Now we can specify within this exactly what values we want to take out. So let's go ahead and do that. Let's say lstrip, and let's try to take out these dots real quick. So we're just going to do a parenthesis dot dot dot. Now let's run this and see what it looks like for this one. Potter, it is now gone. So those three dots were there before; let's just show it. So they were there, and then when I ran it like this, now they're gone. That's what the lstrip does; it takes it only off the left-hand side. Now we can also do a forward slash, so we'll do something like this, and it'll get rid of the white, but as you can see now we aren't taking out these three dots, so they're still there. Now is it possible to do something like this where we put these values inside of a list? Um, let's try it. So we'll say just like this one, two, three. Let's run it, and no, it doesn't. Um, this lstrip actually sits within the the realm of regular expression, so if you've ever worked with regular expression, you know it gets very complicated, very complex, so you want to keep it kind of simple, especially with these values where we're just taking a few out. So what we're going to do is we're going to do dot dot dot, and we're take it out one by one. Now in order to save this because we want to save this, we want to take out that value; we don't just want to say data frame equals because that would be uh very bad. What this would say is now this data frame is only equal to these values that we're seeing right here. We want to only apply it to this column, so we're going to go like this. So now when we do it and then we call the entire data frame, it's only applying this to this one column, the last name column. So let's run it, and now when we go down to Potter right here, it's cleaned up. So we're going to do the same thing but for those other values, and we'll do it just like this: we'll do a forward slash, and it's a left strip, and then we'll do I'll do the left strip on this underscore just to show you that it won't work, and then we will go on from there. So it's not pulling it because we're looking at the left-hand side only; we need to use rstrip. So now let's use rstrip, and now that looks perfect; has no underscore. So that's how you can use strip for either the left side, the right side, or just strip by itself, which covers both sides. Now I showed you all of that because I am going to show you a different way to do it, um, and I apologize because I somewhat lied to you earlier. Um, let's run this right here. Actually, we're just going to pull it in like this. We're going to remove the duplicates again. Bear with me. We're going to drop that column, and then now we're sitting with that data frame again with those exact same mistakes. I just wanted to reset it for a second. There is a way uh that you can do this, and I just wanted to, you know, kind of show you how you can do it. You can do this right here, and we'll say so we're now again we're just looking at this column, just this column, and we're using strip, and let's get rid of RCU. We want to do apply it to everywhere; you can input all of those values in visually, and it will clean it up. So let's say we want to get rid of numbers; we'll do one, two, three. Then we can do the dot, so that's going to be for a period or for a dot dot dot Potter. We could also do the underscore, and we can do the forward slash. So we put it all in one string right here. Now let's take a look at this. We'll get rid of this.

Really quickly now, let's take a look. And all of them were removed. I showed you how to do it before, because that's at least how my mind would think about it. I'd think, "Oh, I can put it in a list and run it through this L strip or this right strip," and it would work. Um, but that's not how strip works. You have to kind of combine it all into one value. So, uh, yes, I deceived you. I apologize.

But now, when we call data frame and we assign it to that column—so the last name column—or assigning what we just did to this last name column, everything should look perfect, and it does. So our customer ID, first name, last name are all cleaned up. Now we're going to come to a much more difficult one. This is probably, if I'm being honest, the hardest one. I said we were going to work up, but this is probably the hardest one of the whole video: working with phone numbers. And look at all these different types of formats. I mean, it is—um—it's not going to be fun. And imagine you—you know—there's 20,000 of these. You can't just go and manually clean those up. You need something to kind of automate that. So that is what we're going to do.

So let's go right down here. We'll copy the data frame, and I'm going to pull it right here. So now we need to clean up this phone number. What we want is it all to look exactly the same, unless it's blank, and we'll keep it blank. We don't want to populate that data, but we want all of them to look exactly like this one. And what we're going to do is, right off the bat, we're going to take all of the non-numeric values and just completely get rid of them—strip it down to just the numbers. So this 123-643 or forward slash will just be the numbers. Same with these bars and these slashes and everything—all of these will just be numeric. Then we'll go back and reformat it how we want to format it, which will look exactly like this one. Um, but we just want to do it for the entire column.

So let's go right up here, and we're going to try replace for the first time. So let's do phone number—just—oops, that's not what I wanted. So we're going to do a bracket, say phone number.string.replace, just like we did before. Now we're going to use some regular expression in here, and I'll kind of do a really high overview, although I'm not going to dive super deep into the regular expression. Then we're going to do a parenthesis, and within there we're going to do a bracket. Um, I can't remember what this is called. Is it called a carrot? I think it's called a carrot. Uh, I'm just going to call it that. It may not be correct, but I think it's an upper arrow. So it's an upper arrow, a dash—oops—A-Z, A-Z, and then 0-9.

Now, at a super high level, what that character—that first thing—is doing: it's saying we're going to return any character except, and then we specify anything A to Z, A to Z, upper or lowercase, and then—actually, I think this should be like this—A to Z, and then 0 to 9. So any value like a, b, c, 1, 2, 3, those are not going to be matched. It's going to match all of them except these values. And then we're going to replace them by saying comma, and we're going to replace them with nothing. So this is just an empty string. So literally, we're taking everything that is not an A, B, C, a, 1, 2, 3—so a letter or a number—we're replacing all of that, and then we're replacing it with nothing. So let's run this and see what it looks like, and it looks like that worked properly.

Now we do have this NA, cuz we had an N-A for—I don't remember—maybe that was Creed Bratton. Um, but it worked for basically everything else. We're going to go through the entire process, and then at the end we'll remove any values. We want them to just be completely null. We—we don't want them to even see N, A, N, and wonder what that is. We just want it to be blank. And we'll do that at the very end. So now that we know that that worked, let's assign it. We'll do DF phone num is equal to, and then we'll say data frame. And this looks a lot more standardized than it did before already. But now what we want to do is try to format this. Um, and I've done this many, many times. I always use a Lambda. You can definitely use a for loop. I just—I don't do it that way myself. So I'm going to show you how to do it using a Lambda.

Let's get rid of this, and we're going to say DF phone number—we've already done that—I'm just going to get rid of it. Now we're going to say DF phone number, then we're going to say .apply. We'll do an open parenthesis, and then this is where we're going to build out our Lambda. So we'll say Lambda X:, now this is where we're going to kind of format it. So what I want to do is I want to take the first three strings, 1, 2, 3, then I want to add a slash, and then the next three strings, add a slash or a dash, uh, and then that be the value that's returned. So it's not super difficult. We're just going to do X, then a bracket—let me get rid of that—an X, and then a bracket, and then we want the 0 to 3. So goes 0, 1, 2, so 0, 1, 2; it doesn't include the three, it goes up to three. So 0, 1, 2, that's our first three values. Then we'll do plus and do a quote and do a dash. So this is our first kind of sequence, and I'm just going to copy this. We'll do plus, and instead of three, or we are going to start at three, because now it's inclusive, so we're going to go from three and we're going to go all the way up to six. So it should be 3, 4, 5—our next three values. Then we have a dash, and we'll copy this and we'll say plus, and now we go from six all the way to 10.

Now let's try running this, and as you can see we get an error. Now I already know what the error is: float object is not subscriptable, which means we're trying to—um—basically look at it like a string. Right now it's not a string; it's actually a number. So let me get rid of this for just a second. I'm going to show you what it's talking about. So right now we have values that are floats and values that are strings, or not even a number. So we have values that are strings or not a number. So if we want to actually look through it like kind of like indexing, if we want to do that, they all have to be strings. So we need to change this entire column into Strings before we can apply this formatting.

Now, when I was creating this, if I'm being honest, my first thought when I was doing this was to do it like this: string DF phone number. Um, let's just run that. This is what the values look like. Um, and I don't remember why or why it was doing this. I can't—I can't remember, but I looked into it quite a bit, and I was like, "Oh, I need to apply this string—converting it to a string—on each value, not the entire row or not the entire column." So how we can do that is actually fairly easy, because we've already done a lot of the heavy lifting. We're just going to copy this, and we're going to say X—so string of X—and again, Lambda is like a little anonymous function, so you could do this by saying for—um—X in this—uh—column, we could do a for loop, and then say for every X it equals the string of X, and then it changes it to a string, but a Lambda just does it a lot quicker. Um, so we're going to say—so let's do that really quickly, and all of our values look exactly the same, and that's how we want it. So we're just going to copy this, apply it, good. And now we're going to take this and we're going to run this again. Just ignore all my commented-out stuff; pretend I don't have that. Um, so now when we run this, it should work. There we go. Now if we look at these numbers: 123-545, 5421, and it does that for every single one where there's values, even when there's NaN or NA, it's still adding those values, but we expected that. So let's apply it, say is equal to, and then we'll look at the data frame. And this looks almost exactly what we're hoping for. We just need to get rid of these—so this N-dash and this NA-dash—we need to get rid of those. And that is super easy to do. Um, we're just going to say—so now that we've done it, and we'll comment that out—we'll say DF, and let's copy this. Ignore the messiness; I do apologize for that. It's very messy. Um, but if you're following along with me, you get what we're doing. So DF phone number—so only on the phone number—say .string.replace, no open parenthesis. Now we can specify this value. So we want to take this exact value and replace it with nothing. And let's just see if that does work. It does. Now we have these NAs, and so let's actually—I'll paste that right down here—we're going to do—this is equal to—and then we're just going to take this entire string, put it right here, and put this value as our what we're looking for, and then replacing. And then when we call that data frame, it should work properly, and it is perfectly cleaned. So we have every single value, all the exact same; they don't have different characters or different—you know—formatting, and we got rid of all the ones that we don't have or don't need—all the ones that were just random values. So this column is now completely cleaned up. Again, definitely one of the more difficult ones—one that I've done a thousand times. I've had to work with a lot of phone numbers and stuff like—like that. This one does get very tricky, especially if you have like a plus one, which is like an area code—that can get tricky as well. But this is on a kind of a high level; this is how you can do that, and it's pretty neat how you can actually—you know—clean up and standardize those phone numbers.

So let's go right down here. Uh, let's run it. The next thing that we're going to look at is this address. Now let's just pretend that the people who are on the call center want all these separated into three different columns. They can read it easier, see what the ZIP code is, where they live, uh, you know, whatever they want it for. Let's just say we want to do that, and this is—you know—again, for this use case it may not make sense, but you have to do this. I do this all the time. Um, you need to split those columns. Now luckily all of these things are separated by a comma, so we can specify that we're going to split on this column, and then we'll be able to create three separate columns based off of this one column, which is exactly what we want. Then we can name it as well, and we can do that very easily by using this split. So we're going to say DF, and we want to specify—oh, jeez, not again—so we want to specify that we're looking at the address, then we're going to say .string.split. We'll do an open parenthesis. Now the very first value that we need to specify is what we're splitting on. So we want to split on the comma, so we want to specify that. And then we need to specify how many values from left to right it should look for. Now we'll just start with one, and then we'll go from there. Let's just see what this looks like. So it doesn't really look like it did anything. Let's do two. Well, let's go back to one, and then let's say expand equals true. When we expand it, it's actually going to—uh—separate it, I believe. Okay, so we're expanding. We now—we're only doing this with one comma, so we're only looking at the very first comma and splitting it. But in some of these—well, just in one—there is an additional comma, so we should do it up to two. Let's do this. Okay, so now we have three columns. If we just save it like this, it's going to give us these 0, 1, 2—these basically these indexed values for these columns—and we don't want that. We want to specify what these actually are, and we can do that by saying DF, and let me just do is equal to. We'll do bracket, and then within there we're going to specify our list. So we have three—three of them that we have. So I'm going to do—um—the first one, this is the street address, so we'll say street address. The next one is—and it's sh—is not a state—but these all are states, so I'm just going to say State. And then for the very last one, that looks like a zip code, so we'll say zip, and we'll do code. In fact, I also want to do street address. Um, so what this is is now going to do is these three columns are going to be applied to these three names, and they'll basically be appended. It doesn't replace the address. We're not saying DF address equals the DF address; we're not replacing it. We're now creating different columns. So let's run it, and then let's also call it. So they're right over here on this right-hand side. I couldn't see them at first, but it did exactly what we needed it to do. So now if we wanted to, at the very end, if we want to—we're not going to—we could just delete this address and keep the street address, the state, and the zip code. Another really common thing that you can do—this happens often—again with like first name, last name—well, you'll have Alex Freeberg, but it's Alex, Freeberg or Alex space Freeberg, and you can separate those out into different columns.

Now the next one that we want to look at is this paying customer. And the paying customer and do not contact are very similar—um—in the fact that it's yes, no, Y, N, yes, no, Y, N—and so let's go right on down here, and we're going to say DF dot, and we want to just replace these values as all yeses or all nos, but just with the same formatting—um—just to keep it consistent. So let's make anything that's an N into a no, anything that's a Y into a yes. I like it spelled out, so let's change anything that's a yes into a Y, anything that's a—a—no into an N. That's usually how I do it; just saves on data because it's less strings, although it's can be often very minimal. Um, but let's specify the P customer. We'll say DF[Pay customer], then we'll do .string.replace. So now we're just going to look for those specific values. So if it's a Y—oops—a capital Y, then we'll say yes. Now let's run it, and now we have no more Ys; we now just have yeses, although now these are yes yeses. Okay, we don't want to do that. Let's do—if we're looking—because it's taking—it's literally looking up here and saying, okay, there's—here's a Y—let's change the—let's change that Y into a Y. So now it's doing Y—we don't want that. So let's look for the yes and change it into a Y. Now when we run this, that looks a lot better. Um, so we'll do DF paying customers is equal to, and then we'll copy this. We'll do the exact same thing—no and N—then let's call it. And now that entire column looks really good, except for that value right there, but I'm going to leave that because I'm just going to apply it to the entire thing all at once to get rid of those at the end, instead of just going column by column. And then it's—it's literally going to be the exact same thing, so I'm not even going to scroll down. Whoops, I'm just going to put it right up here, because this is the exact same thing. I'm going to save us all some time. And when we run this, this looks exactly like what we're looking for. Again, some not a number values, but we can get rid of that in just a second by doing a place over the entire data frame. And that is basically the end of cleaning up individual columns.

Now let's go right down here. We're going to say DF.string.replace, and then we'll first do these values—oops—so we'll do—oops—let me do that. There we go, and replace that with nothing. And let's just see what it looks like. Oops, data frame object has no value string. Well, that's cuz we were looking at columns before. Yeah, I think I just need to get rid of this string. We're not looking—we're just really doing it across the entire data frame. Now let's try that. Okay, that worked appropriately. And we'll just say data frame is equal to, and then we'll copy this and we'll do the NN as well, and we'll—[Music]—do. And now when we do this, it is not going to replace these because these aren't actually a value, because we're looking for that string. We actually need to use—and I—I completely forgot this—I'm not going to lie to you—let's get rid of this—to get rid of those values, because it's literally not a number. There it is; technically empty. Um, I forgot we can do—or we could not even specify it—we'll do DF.fillna. So we're going to fill these values; if there's nothing in them, we're going to fill it, and we're going to say blank. And when we run that, every value that doesn't have something in it is going to show up blank, even over here where we only had a few—all of them throughout the data frame, if—if it doesn't have a value, it is now blank. So let's apply that, and we'll run this. And now all of our cleaning—we actually cleaning up the individual columns—is completely done. We've removed columns; we've split columns; we've formatted and cleaned up phone numbers; we've also taken values off of first name or—or—this last name column, and then we formatted it in just kind of standardized paying customer and do not contact.

Now they also asked us to only give them a list of phone numbers that they can call. So if we take a look, some of these do not contacts are Y, which means we cannot contact them, and then there are some that don't even have phone numbers. So we don't want to give the people the call center numbers that—or—or people who don't have numbers. So we want to remove those. Now there's a few different ways that we can do this, but let's start with—and we'll just go by—do this do not contact; it seems like the most obvious one. Now if it's blank, we want to give them a call. We only want to not call them if they've specifically said we cannot call them. So if it's Y, we're not going to call them. So what we need to do—it's not anything like this—we probably need to loop through this column and then look at each row that has a value of this and drop that entire row. Uh, and we probably will—will need to do that based off this index instead of doing it based off just this column. Uh, that may not make sense, but let's actually—let's actually start writing it. So we'll do for X in—and we need to look at our index, so we're just going to do—let's do DF.index, and we'll do a colon, enter. And then we want to look at these indexes. How do we look at these indexes? We use loc. That's going to be DF.loc, and then we need to look at the value, which is this X right here. So each time it looks at the index, it's looking at the value, but we want to look at the value of this column, do not contact. I don't know if I copied this before; let me copy it. We only want to look at the value in this one column; if we didn't, it would look at—um—a different value, so we don't want that. So we're looking at just that value; if it's equal to Y—so if this value

Hello everybody, today we're going to be looking at exploratory data analysis using pandas. Exploratory data analysis, or EDA for short, is basically just the first look at your data. During this process, we'll look at identifying patterns within the data, understanding the relationships between the features, and looking at outliers that may exist within your data set. During this process, you are looking for patterns and all these things, but you're also looking for mistakes and missing values that you need to clean up during your cleaning process in the future.

Now, there are hundreds of ways to perform EDA on your data set, but we can't possibly look at every single thing. So I'm just going to show you what I think are some of the most popular and the best things that you can do when you're first looking at a data set. The first thing that we're going to do is import our libraries. So we'll do import pandas as pd. We're also going to import Seaborn and matplotlib. Now, during this exploratory data analysis process, I often like to visualize things as I go because sometimes you just can't fully comprehend it unless you just visualize it, and it gives you a larger, broader glimpse of everything. So we're going to import and let's do seaborn as sns, and then we'll import matplotlib.pyplot as plt. Let's run this; this should work. Okay, perfect.

Now we need to bring in our data set. So we've worked with that world population data set; that is the exact one that we're going to use now. So we'll say dataframe equals pd.read_csv(), and we'll paste in our CSV, and this is what it should look like, although your path may be different. Be sure to make sure that you have the correct file path. Then we'll read it in. Now, this data set should look extremely familiar if you've done some of my previous pandas tutorials, but I did make some alterations to this one; took out a little bit of data, put in a little bit of data here and there to change things up. Because if it was just exactly how I pulled it—which I got this data set from Kaggle—if it was exactly how we pulled it like we've looked at in the previous videos, it's too simple; you know, we wouldn't actually be able to do some of the things that I would like to show you. So be sure to actually download this exact data set for this video because it is a little bit different. But what we're going to do now is just try to get some high-level information from this.

Now, if yours looks just a little bit different, like your values are in scientific notation—I have applied this so many times, I think it's, you know, still applied to this—you can do something, and we'll write it right down here. We're going to do pd.set_option(), and we'll do an open parenthesis, and we'll say display.float_format, and so we're going to change that float format by just saying lambda x:, and then we're going to change basically how many decimal points we're looking at. So let's just do here, so we'll do a quote percent sign 2f, so we're formatting it, whoops, 0.2f, so we're going to format it, and we'll do %x. This is going to format it appropriately. I'm, I can run it, and actually it will change it; this is at 0.1, I believe, last time I did it. So let's run this, and then let's run this again; it'll change it to 0.2, so that's two. I like it at 0.1; we don't really need it any—well, let's keep it at 0.2, why not? We're going to keep it at 0.2. That's how you change that, and I like looking at it like this a lot better than scientific notation. So just something to point out. Let's go down here and let's just pull up dataframe, so we have this data.

One of the first things that I like to do when I get a data set is to just look at the info. So we're going to do .info(), and this gives us just some really high-level information. This is how many columns we have; here are the column names; here are how many values we have; and if you notice, this is where it kind of gets—so we have 234 in each of these, so in each of these columns we have 234 until we get to this 2022 population. Once we get there, we start losing some values, and then at the world population percentage, we have all of our values, all 234 of them. The count tells us that it's non-null, so it does have values in it, and then we also have the data types, and these come in handy later, and these are really great to know, and we'll be able to kind of use those in a few different ways later on in this tutorial.

Really quickly, I wanted to give a huge shout-out to the sponsor of this entire Panda series, and that is Udemy. Udemy has some of the best courses at the best prices, and it is no exception when it comes to Panda courses. If you want to master pandas, this is the course that I would recommend; it's going to teach you just about everything you need to know about pandas. So huge shout-out to Udemy for sponsoring this Panda series, and let's get back to the video. The next thing that I really like to do, and this one is df.describe(), this allows you to get really a high-level overview of all of your columns very quickly. You can get the count, the mean, the standard deviation, the minimum value, and the maximum value, as well as your 25th, 50th, and 75th percentiles of your values. So just at a super quick glance, there is a row somewhere in here and there; this country, their population is 510 for 2022, and in fact, if you go back to 1970, it was higher; it was at 752. That's just interesting. Then if we look at the max population, one has 1.42 billion; I believe that's China. And then over here in 1970, we have 822 million; again, I still believe that's China. But this gives you just a really nice high level of all of these values or all these different calculations that you can run on it, and we can run all these individually on even specific columns, but you know, it's just a nice high-level overview.

One thing that we just talked about was the null values that we're seeing in here. I'd like to see how many values we're actually missing because that is a problem; we don't want to have too many missing values or could really obscure or change the data set entirely, and so we don't want that. So we'll say df.isnull(), and then we'll do a parenthesis, and we'll say .sum(), and when we do this, whoops, .sum(), there we go; when we do this, it's going to give us all the columns and how many values we're actually missing. Now, we have 234 rows of data, so we have 41, 47, 7, 55, 424. So we have, we definitely have data missing. What we choose to do with it in the data cleaning process, maybe we want to populate it with a median value; maybe we just want to delete those countries entirely if the data is missing. You know, I don't think you're going to do that, but these are things that you need to think about when you're actually finding these missing values. This is what the EDA process is all about; we want to find different outliers, missing values, things that are wrong with the data, or we can find insights into it while we're doing this as well. So, so this is definitely something that I would consider when I'm actually going through that data cleaning process; really, really important information to know.

Now let's go right down here, go to our next cell, say df.nunique(), and this is going to show us how many unique values—and it's actually nunique—this is going to show us how many unique values are actually in each of these columns. And this one makes the most sense for continents because I think there's only seven continents, right? Right. But we have six right here, and for all of these, each of these ranks, countries, capitals should all be unique; that makes perfect sense, as well as these, you know, these populations are such specific numbers and such large numbers; I would be shocked if any of these were similar. And then for these world population percentages, it's much lower, and again, that makes a lot of sense because when we're looking at—and we'll pull it up right here—when we're looking at these world population percentages, a lot of them are really low: 0.00, 0.01, like this one, 0.2; there are a lot of really low values for those small countries, and so those are all unique values.

Now let's say we just have this data right here, and we want to take a look at some of the largest countries, and we can easily do that. We could even, we could say max and take a look at the largest country, but I want to be a little bit more strategic; I want to be able to look at some of the top range of countries, and we can do that based off this 2022 population. So we'll say df.sort_values(); this is how we sort and not filter but order our data. So we'll do sort_values(), and then we'll do by equals, and then we'll specify that we want this 2022 population, and then we're going to say comma, and we'll say, actually, let's just run this as is, but we'll do head because we just want to look at the top values. So now we're just looking at the very top values. So what we're looking at is actually these 2022 population; that's what we're filtering on or sorting on basically, and we're looking at the very bottom values because it's sorting ascending, so from lowest to highest. So this Vatican City in Europe is 510; that's the value that we were looking at earlier. Now we can do comma, ascending equals false, because it was by default true; we can do false, whoops, we can do false, and then it'll give us the very largest ones. So if we just take a look at the top five largest by population, we're looking at China, India, United States, Indonesia, and Pakistan. And we can even specify that we want the top 10; in this head, we can bring in the top 10; we also have Nigeria, Brazil, Bangladesh, Russia, and Mexico. And you can do this for literally any of these columns, whether you want to look at continent, capital, country; you can sort on these and look at them, and you can even look at, you know, things like growth rate, world percentage. This one seems really interesting; let's just look at this one really quickly before we move on to the next thing. If we look at this world percentage, just China alone, I believe, yeah, just China alone is 17.88% of the world, so 17.88% world population percentage. Again, just getting in here, looking around; that's all we're really doing.

Now I want to look at something, and I have always liked doing this, which is looking at correlations, so correlation between usually only numeric values. We can do that by saying df.corr(), and a parenthesis, and we'll run this, and what this is is it is comparing every column to every other column and looking at how closely correlated they are. So this 2022 population, if we look across the board, it's very highly—I mean, this is a one-to-one; this is highly correlated to each other, and that almost for all of these populations, they're very, very closely tied to each other, which makes perfect sense because for most countries they're going to be steadily increasing, and so they're probably almost exactly correlated. But we can look at these populations, and if you look at the area, it's only somewhat correlated, and that's because in some countries, you know, they have a very high population but a small area, or vice versa, a small area and a very high population. So there isn't a one-to-one correlation there, but it's hard to really just glance at this and understand everything that's there. We could just visualize it, and it would be a lot easier. So let's go ahead and do that. Let's go down here; we're just going to visualize this using a heatmap basically. So we're going to say sns.heatmap(), and an open parenthesis, and the data that we're going to be looking at is df.corr(), and then we also want to say annot equals true. I'll kind of show you what that looks like in just a little bit, but let's do plt.show(), and this will be our first look, and I need to say show, not shot. We can get a little glimpse of what it looks like, but this looks absolutely terrible. Let's change the figure size really quick. So I want to make this much larger than it already is. We'll do plt.rcParams['figure.figsize'] = [20, 7]; and see if this looks any better. Okay, that looks a lot better, and, you know, this is just a quick way because it gives you basically a color-coded system; highly correlated is this tan all the way down to basically no correlation or negative correlation even, which is black. So when we're looking at these 2022 populations, and these are populations right down here on this axis, we can see that all of these are extremely highly correlated, very, very quickly, whereas the rank really has nothing to do; it's negatively correlated; doesn't really have anything to do with it. Then for the population and the world population percentage, it again is quite correlated, except for the area density and growth rate. So I find that really interesting that, you know, the density, the growth rate, in the area aren't really all that associated or correlated with the population numbers; that is, I kind of would assume that on some level they went hand in hand, and the area does—would, you know, again make sense, you know, larger area, larger population, that kind of thing.

is equal to Y, then we want to drop it. So we actually need to say, if so, if this value X in this column is equal to Y, then we want to do df.drop(), and then we'll say x, and we, I think we have to say inplace equals true here, otherwise it won't take effect. Um, otherwise you have to say like df equals df; yeah, I don't, I don't want to start messing with that. Let's just do inplace equals true, um, and let's see if that works. I, I can't remember if this is going to work or not. Invalid syntax. Okay, neon. And now let's try to run this. Okay. Okay, yeah. If we look at our index, we can already tell that there are ones missing. The one, the one is missing; the three is missing. Um, let's see, and the 18 is missing. So we already got rid of those values, and you can, you can see that there's no Y's in here anymore, which is really good. We can, if we want to, and we probably should; we should probably populate that, um, really quickly. Um, let me just go up here really quick; I'll copy this. We probably should populate that, and I didn't plan on doing this, so, um, if it's blank, oops, it's blank, give it an N, and we want to attribute it to do not contact. Do not contact. Whoops. Let's see if that works, and we probably need to do do string. Let's just see if it works. So if it's blank, dude. Okay, I don't know why it's giving us a triple N; maybe there's, maybe I need to strip this or something. Uh, okay, never mind; let's not do that. But now we basically need to do the exact same thing for this phone number, um, because if it's blank, we don't want them calling it. Um, so we can copy this entire thing, go right down here, and but now we're looking at phone number, so now we're looking just at the values within phone number, and we only want to look at if it's blank. So if it literally has no value, we want to get rid of it. Let's run this and see if it works. Again, it should. Good. And now our list is getting much smaller, so you can see in our index a lot of those rows were removed, and okay, good. Actually, this worked itself out because these all have Ns. Um, so right now we're sitting really good; everything looks really standardized, cleaned; everything looks great. I might drop this address if you want to; you can drop this address, but besides that, this is all looking really good. This Paint customer doesn't—the yes and nos aren't really anything. Um, now we could, and we probably should, before we hand this off to the client or the customer call list, we probably should reset this index because they might be confused as to why there's numbers missing or, you know, they might use this index to show how many people they've called, or I don't know, something like that. So let's go right down here; we're going to say df., and then we'll do reset_index(), and let's just see what this looks like. Um, it does work, but as you can tell, it didn't get rid of that index completely; it actually took the index and saved that original one. We do not need to save that. Whoops. Let's put it right in here. Now we're just going to do drop equals true, and when we do that, it just completely resets it; drops the original index and gives us a new index, and that is what we want. Let's do df equals, and this is our final product.

Now, one thing that I, you definitely could have done here, um, and I made this a little probably more complicated than it needed to be; um, that was just how my brain was working at the time when I'm, you know, typing this out. We could have done df.dropna(), um, which is literally going to look at these null values. Um, before we couldn't do that with this one because these aren't—we're not looking at NA; we're looking at Ys, so we couldn't do that. But because we're looking at null values, we could have also done dropna(), um, and done subset equals, and then done it just on this phone number, and then done like this, and done inplace equals true. So we could have also done this and then said df equals. I can't, I mean, I can run it; it's just not going to do anything. I can run it on the different column, but that'll mess everything up. But this is another way you can do it, and I'll just save it in case you want to. I'll say another way to drop null values. There you go, and that'll just be a note for us in the future. Um, but this is our final product. It looks a lot different than when we first started. I mean, we had mistakes here; completely different formatting in the phone number, different address, everything that we just talked about, um, and this looks just a lot, lot better, and you can tell why it's really important to do this process because, again, we're working on a very small data set. I, I purposely, you know, created this data set with these mistakes because, you know, when you're looking at data that has tens of thousands, hundreds of thousands, a million rows, these are all things that are going to be applied to a much larger scale, and you won't be able to as easily see them. Um, you'll have to do some exploratory data analysis to find these mistakes, and then you're going to need to clean the data or do it at the same time when you're exploring the data, uh, so you'll clean it up as you go. But these are a lot of the ways that I clean data; a lot of the things that you can do to make your data just a lot more standardized is a lot more visually better, and then it really helps later on with visualizations and your, you know, actual data analysis. So I hope that that was helpful. I know that this was a long video; I'm sure it was, uh, but I hope that you got something out of this; you learned some of the techniques on how to actually clean data in pandas. If you like this video, be sure to like and subscribe; check out all my other videos on pandas as well as Python, and I will see you in the next [Music] video. [Music]

But even density, um, I guess I guess density and growth rate, um, growth rate, I can see because that's a percentile thing that could be definitely not correlated. I thought the density would be more correlated than it is. All that to say is this is one way that you can kind of look at your data, see how correlated it is to one another. That can definitely, um, help you know what to analyze and look at later when you're actually doing your data analysis.

Let's go right down here, um, something that I do almost all the time when I'm doing any type of uh exploratory data analysis like this: I'm going to group together columns, start looking at the data a little bit closer. Um, so let's go ahead and group on the continent. So let's look at it right here; let's group on this continent because sometimes when you're doing this EDA, you already know kind of what the end goal of this data set is. You know kind of what you're looking for, what you're going to visualize at the end; that really comes in handy when doing this. But sometimes you don't; sometimes just going in blind. And so far we've really just been going in blind; we're just throwing things at the wind, kind of seeing some overviews, um, looking at correlation; that's all we've done. Now I kind of want to get more specific; I want to have like a use case, something that I'm kind of looking for—not doing full data analysis, not diving into the depths—but something we can kind of aim for.

So the use case or the question for us is: Are there certain continents that have grown faster than others, and in which ways? So we want to focus on these continents; we know that that's the most important column for this use case, this very fake use case. Um, so we can group on this continent and we can look at these populations right here because we can't really see growth. You can see a growth rate, but the density per uh kilometer, we don't have multiple values for that; it's just a static one single value. Same for growth rate, same for world population percentage, but we have this over a long span, many many years, um, you know, 50 years of data here. So this, we can see which countries have really done well, or which continents have really done well.

So without, you know, talking about it even more, let's do DF.groupby, and then we'll say continent. Oops, let me just copy this; I'm I'm not could—it's spelling. We're going to say DF.groupby, and then we'll do .mean, and we can just do it just like this. And now we have Africa, Asia, Europe, North America, Oceana, and South America. Okay, so if I'm being completely honest, I knew most of these. All right, I'm no geography expert, but I I knew most of these. I don't know what this Oceana is; this that I don't—I genuinely don't know what that is. Um, so let's just search for that value and see; we'll come back up here in just a second. But I want to I want to kind of understand, um, what this is. So we're going to DF, um, and we'll say continent; let me sound that out for you guys, um, then we'll do .str.contains, oops, contains. Good night. And then I want to look for Oceana, uh, and let's let's run this. Oh, I need to do it like this. Now let's run this. So now we're looking at our data frame; we're seeing when the values have this continent as Oceana. Um, okay, so these look like Islands, I'm guessing. So we have Fiji, Guam, um, New Zealand, Papa New Guinea. Yeah, these look like all—I'm I'm guessing based off the continent Oceana, Oceania, o Ocea Oceania. Guys, this is tough for me. Okay, I'm doing my best; I, you know, this is part of the EDA process. I don't know what that means; I don't know what ocean ocean ocean Oceania. Geez, I'm just going to call it Oceana; that's so wrong, but I'm just gonna—it's so easy for me to say. You know, I I now am seeing this, and it looks like Islands, um, which would make sense because for their average, they have the highest average rank, um, and I'm guessing that's because they're just mostly small continents. So let's let's order this really quickly. We're going to do .sort_values, do an open parenthesis, and I want to sort on the population; we're just doing the average population, um, we'll do by, um, equal, so on the average population, and we'll do ascending equals false. So we're looking at this average or the mean population. Asia has the highest population on average, and we have South America, Africa, Europe, North America, and then Oceana at the very bottom, which makes perfect sense—again, small Islands.

World population percentage: so each of the countries, each of those countries in Asia makes up about 1% on average—really interesting, um, to know and just kind of look at this and and the density in Asia is far higher than double, almost double, every single other continent, um, really really interesting actually now that I'm looking at this. But you know, that's something that I would actually look into, and I would be like, what is this Oceana or Oceania? What does that mean? And, you know, let me look into that; let me explore that more because I want to know this data set; I'm trying to really understand this data set well. But what I want to do now is I want to visualize this, um, because I just feel like looking at it, I don't—it's hard to visualize. And again, the use case that we're saying is: Is which continent has grown the fastest? Like it could be percentage-wise; it could be, um, you know, as just a whole on average. Let's take a look. So we're going to take this and let's copy it like this; let's bring this right down here. So let's look at this. So if I try to visualize this, and let's do that; let's do df2 is equal to, because I'm I already know it's not going to look good just based off how the data is sitting, um, we do df2. Oops, what am I doing? I don't need to do that, but I will. Okay, df2, and we'll do df2.plot; we'll run it just like this. Um, as you can see, Asia, South America, Africa, Europe, North America, Oceana; we can kind of understand what's happening, but these are the actual, um, values that are being visualized, not the continents, which is what I wanted.

In order to switch it, and it's actually pretty easy, and this is something that, um, you know, is good to know, we can actually transpose it to where these these continents become the columns and the columns become the index. And all we have to do is say df2.transpose, and we'll do this parenthesis right here, and let's just look at it, and then we'll save it. So now all these columns are right here, and all of the indexes are the columns. So let's say df3 is equal to, and I'm just doing that so I don't, you know, write over the DF or my earlier data frames. So now we have this data frame three. So now let's do data frame 3.plot, and it should look quite a bit different. Uh, whoops, I didn't run this; let's run this and run this. And as you can see, this does not look right at all. And the reason is is because we're not only looking at, uh, the correct columns; we have this density in here, world population percentage, rank; we don't need any of those. The only ones that we want to keep are these ones right here, this population. Now we can do that, and we can just go right up here; this is where we created that data frame two that we transposed; we can go right up here and we can specify within this we actually only want specific specific values. Now we can go through and hand-write all of these, and by all means go for it, but I am going to go down here; I'm going to say DF.columns, and I'm going to run this; it's going to give us this list of all of our columns, and I'm just going to—you can just copy this, and you can put it right in here. Think I need a list with—I think it needs to be like this. If I'm—let me try running this. Okay, so this worked properly. You can do it just like this, or a little shortcut if you want to do it like that. If you want to do a shortcut like, um, I I would hope you would you would just do DF.columns, just like how we looked at down here, except since this is our an index, we can search through it. So we can just say 0 1 2. Okay, so we can do 5 up to 13 because I think it's 7, and we'll just—let's see if this works; it may not; I may actually need to go like this. Let's see. There we go. So you can just use, you know, the indexing to save you some visual space; gives you the exact same output. So now we have this; this is our df2. Now let's go down and transpose it. So now we just have these populations, and we have our continents right here. And then now we're going to plot it, and this looks good, although it's backward.

Okay, it's backward. So what I actually want to do is not this; that is a quick way to do it, although not the best way to do it. Um, so I'm actually going to copy all of these, and although I said it would save us time, it did not at all. So I'm going to put a bracket right here; I'm going to paste this in here, and I'm literally going to change these up. I might speed this up, or I might just have you sit through this because, you know, this is an interesting part of the proc process, and I want, you know, you to get the full experience. You know what? Now that I'm talking about it, that is what we're going to do. You guys can hang out with me; this is a good time. We have 2010, 2015, 2020, and 2022. Now let's run it. What did I do? Oh, too many brackets. There we go. So now it's ordered appropriately; we have 1970 all the way up to 2022. This is how we want it. Let's transpose it appropriately; let's run it. And now we basically have the inverted, uh, image of this. Now, just at a glance, and we haven't done anything to this except for literally what we are looking at; at a glance, we can see that from 1970, China here, you know, Asia and China are already in the lead by quite a bit, and it continues to drastically go up, especially in the 2000s, like right here; it explodes, like just straight up, then kind of starts going up and just leveling off. Every other continent, especially Oce Oceana, is just really low; it it never has done a bunch. Let's see; look at green; green has gone up, um, from, you know, point, let's say 0.1 up to about point 2. So they've almost doubled, um, in the last 50 years. And again, you can just get an overview, a high-level overview of each of these, you know, continents over the span of this time. So this is kind of one way that we can, you know, look at that use case. We're not going to harp on that too long; I just want to give you an example, like, you know, when you're looking at this, sometimes you'll have something in mind of what you're looking for, and you go exploring and just kind of find what's out there and find what you see.

The next thing I want to look at is a box plot. Now, personally, I love box plots; you know, they're really good for finding outliers, and there's a lot of outliers; I already know this because because the average, the 25th, 50th percentile are very low, and then there's some really just big outliers. But for your data set, it may not be that way, and those outliers may be something that you really need to look into. And box plots have been something that I've used a lot where I found those outliers that way and started to dig into the data to find those outliers and, you know, came across some stuff that I'm like, oh, I have to clean this up; I have to go back to the source, really, really, really powerful and useful to be able to find these. So all you have to do is DF.boxplot, and let's take a look at it, and this already looks good as is. Maybe I'll make it a little bit wider. Um, let's do figsize, oops, sorry, figsize is equal to—let's try 20 by 10. Um, okay, that didn't help at all; I apologize; thought I would, but let's keep going. What this is showing us is that these little boxes down here, which are actually usually much much larger because you have a more equal distribution of of, um, numbers or values in the small value, this is where our averages lie; this number right here is the upper range, and then all these values, all these open circles, those actually stand for outliers. So we're looking at the 2022 population; there's a lot of outliers. Now, for our data set, knowing our data set is really important; outliers are to be expected, especially when most countries are continents are small. So we're looking at, you know, all of these little dots are outlier countries, um, or outlier values, which each value corresponds to a country. So if this was a different data set, I would be, you know, searching on these and trying to find these so that I can see what's wrong with them, if anything, or if they are real, um, numbers. Like if this was revenue, everyone's revenue is way down here, and then there's one company that's making like 10 trillion dollars; that'd be an outlier up here, and it would definitely be something that you want to look into. For our data set, knowing that, you know, we're looking at population, this is more than acceptable, you know, oddly enough, but that's what box plots are really good for—showing you some of those quartiles, the upper and the lower, um, as well as denoting these points that fall outside of those normal ranges for you to look into. So really really useful.

So now let's go down here, pull up our data frame again, and we've kind of just zoomed into the whole EDA process. There was one last thing that I wanted to show you, and this is the very last thing that we're going to look at; we're ending on really a low point if I'm being honest because the last kind of stuff was more much more exciting. But there is something: DF.dtypes. Oops, let's do DF.dtypes, and we'll run this. Now, just like .info, it gave us these values, but we're actually able to search on these values now. So these, um, object, float, and integer, we can search on those, which is really great because we can do include equal, and we can do something like number, and none of these are numbers right, or none of them explicitly say number. But when we run it, I'm getting an error: series object not—oh, that's because I'm doing, um, dtypes is for a series; we need to do select_dtypes. Now let's run this. Now it's only returning, um, the columns in this data frame where the data types are included in this number. So you won't see any, you know, country or any of those text or the strings. If we want to do that, we go in here and say object and run that. And this is another really quick way where we can just filter those columns to look for specific, whether it's numeric, um, we could even do float in here, and so now it's not including that rank, which was an integer. So we can specify the type of data type, and it'll filter all of the columns based off of that, which, you know, when you're doing stuff like this, you it is good to know what kind of data types you're working with and look at just those types of data types because there might be some type of analysis you want to perform on just that, whether it's numeric or just the string or integer columns within your data set. So again, ending on a low note, I apologize, um, you know, everything else that we looked at, all those other things that we looked at are all things that I typically do in some way or another when I'm looking at a data set. Exploratory data analysis is really just the first look; you're looking at it; you're going to be cleaning it up, doing the data cleaning process, and then you're going to be doing your actual data analysis, actually finding those trends and patterns and then visualizing it, um, in some way to find some kind of meaning or insight or value from that data. And again, there's a thousand different ways you can go about this; it it does typically, um, you know, depend on the data set, but these are a lot of the ways that you'll clean a lot of different data sets, and so, you know, that's why I went into the things that we looked at in this video video. So I hope that you guys liked it; I hope that you enjoyed something in this tutorial. If you like this video, be sure to like and subscribe, as well as check out all my other videos on pandas and Python, and I will see you in the next [Music] video.

What's going on, everybody? Welcome back to another video. Today we are back with another data analyst portfolio project where we will be scraping data from Amazon using [Music] Python. Now you may be asking, do I need to know web scraping to become a data analyst? And the answer is no; you absolutely don't need to know it, but it is a very cool skill to learn, and in fact, I have used it in my job in the past, and so it is useful, but you really don't need to know it. Something that it is used for is kind of creating your own data sets, um, and we're going to be looking at one where you can create your own data set today, but there are a lot of other uses for web scraping, and I'm sure I'll talk a little bit more about that while we're actually walking through the project. One last thing I want to say before we get started is that this is most likely an intermediate project, so if you are just now learning the basics of Python, this might be a little bit challenging for you, but I still recommend going through it because I will do my best to walk through everything, every single step of the way, and and kind of explain all the concepts, and so you can still learn something even if you aren't super good at Python right now. With that being said, let's jump over to my screen and get started on the project.

All right, so we are going to get started, and if you didn't watch the last project, I had people download Anaconda; uh, we use Jupyter notebooks, um, and I'll show you how to get to that in just a second, but I'll I'll leave this link in the description if you haven't done that already and you are just doing this project, um, but you'll go you'll download Anaconda. You know, download super easy, um, and you're going to open up Jupyter notebooks. I'll launch it right now; I already have it open, uh, but I'll open up another one just for, you know, the purposes of demonstration. What we are going to do today and what we, um, what people voted on—I mean, there's like there was like 8,000 people that voted, um, in the poll that I made of what data you wanted me to scrape; there was like Amazon, cryptocurrency, weather, um, something else I don't remember—overwhelmingly, I mean, like 70% of people, maybe even 80%, I you don't don't fact-check me on that, voted for Amazon, um, and so I'm going to do it now. There are many things that you can scrape, um, off of Amazon, just a ton of stuff, um, and I'm going to show you how to do it; I'm going to show you how to make it useful, how to make a data set, um, and it's going to be really interesting. But there are lots of other ways to do this, and so I think, um, and I have already kind of created it; I'm going to show you how to do it off of this page, um, when you're actually in an item, and you can scrape, you know, basically anything in here, um, and I'll show you how to do that. Another thing that is a little bit more advanced, and that's why this first video is starting off, I think, on the more easy side—it's not easy, but it's easier—the next thing, the next video that I'm going to make is how to actually do, um, basically do multiple items right, so this item, this item.

This item, this item, and then traverse through the different pages. So there are 20 pages. Um, you want all of that data. How do you get all of that? That'll be the next project. Um, I don't know when I plan on doing that. I, it's like 90% of the way done. Um, but I had this one completed, and so I wanted to get that out to you guys now. But that will probably be the next project. I think that is much more difficult. Um, and so if you can understand this one and you get it, and and you understand it, then the next project you should be able to understand too; it's just a little bit more complicated.

So with that being said, um, we are going to actually get into the project. I'm going to delete one of these. Um, all we're going to do is go to new, do Python 3. It'll open up a new one. We'll call this um Amazon web scraper um project. That's what we'll call it. I spell it right? Perfect. Um, the first thing that we need to do, uh, or that we should do, is upload um or or or import our libraries. So I'm going to say um import. Oops, what am I doing? It's off to a terrible start. There we go. Import libraries. Now I'm not going to write out all the libraries. Um, I have some things that I'm going to be copying and pasting throughout this. I won't—there's only a few things that I'm copying and pasting. You can take a quick glance. Um, some of the things that I just don't want to waste time on, um, because this could be a long video. I don't know. I don't want to waste time on stuff like this. Um, and so, you know, I'm just going to copy and paste it. You guys are going to—I'm—there will be a link below if you haven't clicked it already that will go to the GitHub page where you can literally have all of this code already written. I do recommend writing it all yourself because you will learn it much better. I promise. You then you'll make mistakes and you'll figure it out and all that, all that good stuff. But you will have that code available, so just go copy and paste it. Um, that's what I would do. But what we are, we are going to be using today is uh something called Beautiful Soup, requests, um, then we're going to be using time and datetime, and a potential one if you want to get—and I'm going to show you this at the end. This is not really part of the project; it goes above and beyond—but this library here is for sending emails to yourself. Um, and I'll show you how uh you can use it if you want to. I already have the whole code written out. Um, you can just steal it and try it out yourself and see if you can get it to work. But this one is not um as important. I'll put it down here. So um let's move on.

Now one thing I want to say before we get too into it is that—well, give me a second—is that right here in front of me is a different laptop. Now it took me a solid, I would say, you know, 10 hours or so to write all of this. It took over the course of like two weeks in my free time. I'd pick it up. It took me a solid, you know, two weeks on and off, an hour here, an hour there, to finish this project. Um, and I made a ton of mistakes and messed a bunch of things up, and I finally got it to work. Um, you know, after a bunch of revisions. That's typically how things go when I do projects. And so, uh, I'm about to give you a streamlined version of this because I have all the code right down here, and so I'm going to be glancing at this a lot, um, just so I don't make this video 20 hours of trying to remember all the code off the top of my head. I have it written out already. I already did the project. It works; it's beautiful; it's a good project. So, um, I don't want to waste your time, and I just want you to know that, you know, you, you nobody should be able to do this off the top of their head in an hour. Most people won't. Um, it takes time; you make mistakes. Um, but uh let's get started on the project now.

In this, uh, in this what we're going to have to do is we're going to have to tell Beautiful Soup and requests where we are actually getting this data from, what website, um, what is our computer, you know, some information from our computer. I'm going to—again, there's going to be a little copying and pasting in here because you don't ever, you will never ever ever need to know this. Um, but right here we're going to to basically connect to the website. So I'm just going to say connect to website, and we're going to say URL is equal to, and let's go get our URL. So we have this right here. So literally just go up here, do you know, uh, control A, copy that. Oops, that's the actual project; get rid of that, uh, paste it in here, and that is our URL. We will use that in just a second. Uh, what am I doing? Me, just get some room here. And then we, what we're going to need is something called headers. Now again, you will never ever ever need to know this, so I'm just going to say headers. Um, what I'm going to do is I'm going to copy this. I'm going to show you how to get this really quick, um, but is something called headers. So, uh, let me show you how to use, how to get this, and why you don't need to know any of this. So what this headers is is this something called a user agent. You need to do this for your computer, um, and you can do that by going to this link right here. So I'm going to put this link in the description so that you can go and get that, and there's something right here called the user agent. So all you have to do is copy this, just like this, do copy. I'm going to go back here, and I'll show you that it's—I'm going to copy it in. Um, it'll be the exact same. So there you go; it's the exact same. Um, all of this extra stuff except encoding, except um this HTML stuff, Connection close, all the—you don't need to know any of it. I promise; you'll never come in handy ever in life. Actually, there will be one person who that becomes handy for, and then they'll message me. Um, but we are now connecting, um, using our computer, using this URL, and then what we want to write is we want to write page. We're going to say equals, and this is where we start using uh these libraries. So we're going to use requests.get, and we are going to pull in that URL, and we're just going to say headers is equal to our headers right here. So uh we have this, and this is where we're going to actually start getting the data, bringing in the data, um, and it's not going to look like that at first, but I'll try to print some stuff out, out as we go along the way so that you can kind of see what it looks like and how we're going to kind of make it more useful because it comes in very dirty uh when we first get it, and some of the things I'm going to show you will just help clean that up. Um, and before we actually go any, any further, I don't want my head to be here for the entire time. I'm going to get rid of myself so you can just see the page. Uh, I just—it's less distracting. Uh, I hate when I feel like people are always watching me, so I want people to just focus on the code. Uh, so I will see you in a little bit. Let's get back into it.

All right, so what we are going to do is we are actually going to start using the Beautiful Soup library. All right, so we are going to say soup1 is equal to, and this is where we actually start bringing Beautiful Soup, and you guessed it, you're going to say Beautiful Soup, and then in parenthesis we're going to do page.content. Um, and again, these aren't really things that you need to remember or need to memorize. We're just pulling in the content from the page; that's really all we're doing right now, and and it comes in as HTML, so we're going to do html.parser. Uh, and let's see if I can print out, uh, actually let me just do soup1. I don't like, I don't like doing upper caps on stuff. Let's see if anything prints out real quick. So we are literally pulling in all of the HTML. Um, and let me go show you really quick because we're going to get to this in a second anyways. Um, if you come here, this is, this is a static page basically written in HTML. Um, if you have never seen HTML before, um, you know, actually a lot of this is, you know, just stuff that most people will never use. Uh, it's just good to know. Some of the stuff is good to know. So as you see, I'm scrolling on this right side, by the way. I did right-click and inspect, or control-shift I, whichever one works better for you, but as I'm scrolling over this, you should see it kind of highlighting different areas. Um, it's hard to kind of get what you want. Let's say we want this title. Um, what I can do is I can click, select element, go right here, um, and then we can select like a TI, the, the, the header or the title of the, the page. Now I just want to show you though of what we're pulling in. So we're pulling in this doc type HTML. All of this is coming in; so that's what this is right here, this doc type HTML, and we're pulling every single thing in. That is what we're doing right now. Uh, so let's get, or let's go down a little bit. Let's do soup2. We're just going to do a very, uh, you know, an upgrade to soup1 basically. We'll do Beautiful Soup again, and then we're going to do uh soup1. So we're pulling in that content again, so that soup1, and we're going to do .prettify. If you don't know what that is, it is common in a lot of different languages and a lot of different stuff. Um, it just makes things look better; that's really all it is. Uh, I don't know why I'm using double quotes. I don't know why I—you can do single ones if you want. Um, and now let's do Beautiful Soup 2, and it should just be a, it should be better formatted. Um, and let's see if that's true, and it is. So before, if you did, if you could tell it was didn't have basically any formatting, it has a little bit of formatting now. Um, it'll help in a second, um, and you'll see that. But now what we want to do is go back and we want to actually get the data that we want. Now you can get any data you want. I'm going to show you simple things, really, really easy, um, in my, in, in my opinion, it gets more difficult the more complicated stuff you start pulling, um, and and you'll understand that as we go into it. So what I'm going to do is I'm going to select this and I'm going to select this, the title; I want that. And so if you do span ID, it's equal to product uh title, so we need to remember that. Um, class, we don't need to know class, I believe. Uh, we're going to be using that ID, this, um, ID equals product title. So that's what we're going to be using. Um, class will come in in the next video when we start looking at these, uh, but not in this one. So let's remember ID equals product title. So let's go back over here. So we have this soup2; it's basically all of that HTML in it, right down here, that, that is what we're pulling in. So we need to kind of specify what we actually want. So let's say title; that's what we're going to be getting. Um, and we're going to do soup2. So using, taking all that content, um, we're going to do find, and we're going to do open parenthesis, and we're going to say we want to find that ID where it's equal to product title, and then we're going to do .get_text, and then we're going to do open parenthesis. So now let's, let's print the title and see what we get. All right, so that is exactly what we're looking for. It's funny. Got data Mis um T-shirt. That, that is what we're trying to pull in, so that's perfect. That's exactly what we want. We don't—let me, let me just do this, save me some time later on. We don't only want the title; we are also going to be pulling in the price. So if you can guess, uh, we'll be doing some uh a data set on the actual pricing. Um, and so let's go back here. We're going to again use this right here, and we're going to go to this price, and it says again, we're going to look at this ID, the ID equals price_block_our_price. So fairly easy. You can copy this. I'm just going to write it out. Um, we're going to say price is equal to soup2.find, and then it's going to be again, ID is equal to, and it's going to be price_block_our_price. Did I say that right? Oops, excuse me. There we go, and the exact same thing. .get_text(parenthesis). Uh, and there's a get_text, there's a get_all, or get_all_text, um, so you know that get_text is a specific thing that we are using. We might use a different one later on, um, but that, that is what we have. So now let's, let's print the title and print—when, why do I have all this, too much, too much space? So let's print the title and print the price. Let's see what we get. Okay, so we have our title and we have our price. I mean, you know, I don't know what all this white space is over here, um, but it looks like there's a lot of white space over here. We'll have to get rid of that uh in a little bit as we clean it up a little bit. You can, if you want, do things like, um, you can get, and this is up to you; I'm not going to do this right now, but I'm just going to show you how to do it. You can get this where you're pulling in the ratings, um, which is, you know, if you want to look at like how the ratings over time or or what ratings are for specific products, that could be really useful. Um, you can pull basically anything. You can go down the product details and look at dimensions, uh, anything you want on this page; it is static, so you can go in here and pull anything. It's, you just have to pull it from the HTML; know where you're looking, pull it in. Um, and now when we go back here, excuse me, I'm going to show you now kind of how to use this right, because we have this, but how are we going to use it? Um, that's kind of the important part, I think. First thing we need to do is clean this up a little bit because it just is, you know, if we try to use this, it wouldn't be super useful because it'd be just a little bit dirty; it's not super clean. Um, so what we want to do is let's start with the price, why not? Uh, we're going to say price.strip, um, and that's just going to take uh basically the, the junk off of either side. And so let's run that real quick. So this is what we have, but what we can also do is I don't want that dollar sign; I just want the numeric value. Um, later on we are going to be putting this, and we're going to be um creating a process to put this into an Excel file. Again, we're trying to create a data set. I don't want you to have to copy and paste stuff; it's all going to be automated basically to input this data into an Excel file for you or a CSV file for you. So, um, you know, think about making it useful in a CSV or in an Excel later on. So what we can do is do a bracket, and we're going to do one, and then everything after that. So basically it's just going to take everything from the first position onward. Uh, so let's run that, and there we go. So let's just say price is equal to price.strip, um, and pull, just do everything after that first, that first not value, what am I saying? What's the word for that? I can't remember the word, the first space, that's not the right word, but all right. Let's do the title. Um, this is basically going to be the exact same thing, super easy. So we're just going to do title.strip and open parenthesis. Um, and we can, you know, if you want to do this exact same thing. So now we have it; it's a little bit cleaner. So this is what it originally looked like, and now this is what it looks like. So, you know, nothing super crazy, but you know, something interesting to know. Now we are about to, in the very next part, what we are going to do, and let me just add a few of these because it makes me feel better, um, what we are about to do is we're going to create our CSV to insert this data into the CSV, and then later on what I'm going to do is show you kind of how to um automate this process to pull this data, um to create a data set, right? Just pulling this one time and putting into a CSV really doesn't do anything; you can just copy and paste that and save yourself a lot of time. Um, what I'm going to show you is is um basically doing it over, over time and just having it automated in the background. That is what I'm going to show you. I guess a spoiler, but what we need to do is we need to create, uh, create the CSV, insert it into the CSV, and then create a process to append more data into that CSV. I'm doing a lot of talking; let's do some writing. So what we need to do is we're going to use—I should have done this at the top, maybe I'll go back and add that later on—we're going to do import csv. Now in a CSV, what you want is you want headers and then you want the data, right? So for our headers, and we're going to call it header, we're going to do um we're going to do a bracket, and let's make the first one a title because that's going to be, we can call it title, you can call it product, whatever you want. I'm just going to call it because I've been using title, I'm going to call it title, um, and then we'll also have price. Now we need our data. So I'm going to say data is equal to. Now this is important. Um, right now how our data is, and I can do this right here, we're going to type, um, title, or no, let's do type(price). So these are strings, and that's important to know. Um, again, I don't want to get too much into, you know, dictionaries and arrays and lists and and strings and all these things, but this is a string, and you can't put that. Right now it's not super usable. What we're going to do is make this a list, um, and so I'm doing an open bracket, and I'm going to say our data is title, comma, price. Oops, price. Now oops. If I do type(oops) of data, I'll just run that. It's a list now. Um, and this is important because you can run into a lot of issues with the stuff. It's really important to remember what type, how do I say this, how your data is—is it a list? Is it an array? Is it a dictionary? Um, you know, what is it? These things are important; they do play a big impact, especially with this type of stuff. So just wanted to show you that really quick. But what we are now going to do is create a CSV. You're going to create an Excel—I call an Excel, CSV, you know, whatever you want to call it. So what we are going to do is we are going to say with, and we're going to say open, and now we're going to name our file. You can name this whatever you want. I'm

Going to call it uh um Amazon web scraper data set that's real long uh. CSV. And then we're going to do underscore W, and that means right um oh whoops, that's not right, just like I was wondering why that was uh in Black uh so we're going to do W, which means right um and then we're going to do new line. If you don't know what new line is uh all that does is when we insert the data, it doesn't have a a space in between each CSV.

And then we are going to do encode coding is equal to oops, is equal to utf8, and that is it. And we'll just say as uh let's do F. So some of that stuff you don't need to know, some of it's useful. This W definitely need to know, this new line is is good to know, and um I'll take it, I might take it out just to show you what it actually does because it's annoying if you don't have it, I promise um but you know that that new Line's important. This encoding, you know, good to know. I think that's by default is is it's like that uh anyways, what we're going to do now is we're going to uh it's something within the CSV within the CSV um Library, so we're going to do something called CSV writer and oops, CSV.writer. And we're going to do open parenthesis, and that is that. And we'll just call that writer, and then we'll we'll do this is where we need to actually create the header so uh we're going to do writer.writerow uh and this is just for the initial um the initial import or or or um not import, the initial insertion of the data into the CSV. This is what's important. The next one that we're going to write is for when we're actually appending the data, which is going to be a little bit different, but anyways we're going to do writerow open parenthesis, and this is where that header is going to go, so we're going to that these headers are going to be the title and the price.

And then for our last one, we're going to actually write the data, which is this data right here, and we're going to say writer.writerow, and we're going to do data. So this one we are creating the CSV, and then we are inserting the header and inserting the data, so super easy um yeah, I think that's fairly straightforward. Right now, let's do this and let's see what happens. So I just ran it um let's go over here in here somewhere, Amazon web scraper data set. Let's open that up, and there we go. Oh jeez, this isn't good. Can't verify my uh my subscription uh why does it say $699? I'm going to go back and look, but I think I know the issue um but this is exactly what we want. Now, of course, we want more data and maybe a little bit more useful data um and I'll show you how to get that in just a second, but we just created that out of thin air uh that was not I didn't have that saved before, so we have this data set. And the issue was is that I ran this multiple times, so now it's $6.99. If I do it again, it's 99 uh and if I did it again, it's it gets rid of everything, so I'm just going to run this again, run this again. Now everything's back to normal. Okay, so now if we run this, it's going to overwrite this Amazon webscraper data set.CSV, and it will put the data in properly. So there we go. Oh jeez guys, this is embarrassing. I'm embarrassed. No, I don't want this. Okay, perfect um guys, I if you can't tell, I'm in need of some um I'm in need I'm in need of some help here, but I'm just kidding. I'm I'm doing fine uh I just I don't know why that uh why I don't have my uh subscription activated. It's not going to matter for this video I guess, but that's really random um so we got what we need, that's perfect.

Now what we want to do after this um I I guess actually what is important is some more useful data. Something that I like to do a lot when I do this type of this type of stuff is I like to have some type of date stamp um or some type of timestamp to know when I collected this data. It usually comes in handy later on um I I have never regretted putting it in there. I'll show you really quick how you can do it uh you're going to do import datetime. Geez, I hate having to format stuff like that. And what you can do is you can do date let me get datetime and you do date.today open parenthesis, and that is going to give us this right here uh and so we're just going to do um today that's what we'll call it is equal to this, and we'll say print today, and there we go. So that is today's date is the 20th of August in 2021, so today is now um is now this. So actually I'm going to get rid of that, I'm going to put it back up here, I'm going to put it right there. I'm going to run it again. Let's add this right here, we'll do um we'll do we'll call it date and then we'll add today and we'll just run this again. And what we can do just to check the data without having to open up the data every single time, which is super annoying, is we're going to use pandas again. I should have imported this at the top. I'm just kind of um I'm not doing this off the top of my head, but uh I didn't have it 100% planned, so import pandas, and we're just going to say pd.read_csv, and then we'll read it in um what you can do or what I often do is I go to properties and I go right here, and we'll say boom boom backslash this right here. This I am doing off the top of my head, I don't do this often. I think I have this memorized by now uh I I I hope, and then we'll do print oh no we don't have to do print, we'll just do this uh what do I do R let's actually call this um dataframe and we'll do print. Let's see what happens. Perfect. Okay, so what we have now is the new our new header, our new data that we added in there, so we have our title, we have our price, and we have our date. Now again, you can customize this whatever you want to add, go back here um you know, find what you want, you know, do you want it to make sure it has a men's option or different colors or you want to pull in this information, whatever you want it, it really does not matter um just matters that you know you get what you need for whatever purpose, whatever you're making this for. This is more of an introductory video to how to scrape data from Amazon um the next video will probably be a little bit more difficult and in-depth, but this is kind of let's get you guys started, so um we now have this, and this is beautiful.

Now something that you want to do when you're scraping data and you're getting um I guess data over time and that's kind of what we're doing is going to be almost like um a price tracker over time is you want to then append data to this, so we can't only create it, and that's what this does because if I run this 100 times, it'll only give me this first row. We need to now append data to this, so um let's let's pull this down here uh again I'm I'm not I haven't added a bunch of notes. I'm going to say now we are appending data to the csb. I haven't added a ton of notes. I'll try to go back maybe afterwards and add some notes for people who like to read notes um so what we are now going to do is we're going to change this W to an A+. Now this is going to be how we append the data um and we no longer need the header, so we don't aren't going to do the header anymore, and there we go. So now instead of excuse me, so now instead of creating that header again, creating that first row of data again, we are ignoring the data and we're now going to the next nearest free row and appending data, which means to add on data to that um and so if I run this, which I'm not going to right now, I mean why not? I can I can run it um and then we can read this in, so now there there's our data. I'll run it a few more more times. I ran it like three or four more times. I I run that in and there we go. Now it's all the exact same data, super um boring but very very uh you know good to have. Now we don't want to have to come in here and run this every day. Let's say we're going to do this daily um we don't want to have to come and write run this every single day, right? We want a way where it does it while we sleep, it does it in the background of our laptop um and is easy to do, right? I don't want to come in here every single morning with a set an alarm on my phone every single morning, come in here. I want to automate this, so uh how are we going to do that? Give me one second uh if you didn't know, I have three kids and one of them is waking up. I'll be right back. All right, I think he is asleep um at least let's hope he's asleep.

So now what we're going to do is we're going to put this all into uh this check uncore price. Now you may never have used oh geez, what are these things called? Oh my gosh, super used all the time. You'll know what I what it is uh not a function. I don't even remember what it's called. Maybe this's a function um I can't think. I'm having like a writer's block or whatever that is. We're going to put it all in here, and then we're going to be able to use this price check later um because we want to be able to automate this. So let's go back all the way up here. We are going to use this, so let's copy all of that in and oh jeez, I hate this. All right, everything just like that um so this pulls in our data, pulls in uh or or yeah, pulls in all of our data down to the title and the price. We want to make it look right, so we're going to put it right here. So now we have it formatted properly um we want to add our datetime, do it just like that. I don't know if there's a better I'm sure there's a better way to do this um then we need need this right here and just like that like that. So now we have our header and our data, and then we want to pull this in right here boom boom boom. Okay, so everything that we just wrote out we are now putting into this check price. Now you can call it whatever you want, doesn't matter, but let's run that, see if we get any errors. We don't, so this is now good to go basically um what we are going to use this for um and what this is going to do is we are going to put this on a timer um you know, have you ever wanted to like check something once a day, once every 10 seconds, once a minute, whatever you want, and you don't want to have to actually pull up your phone and look at it? This is how we are going to do that. So we had something called uh let's see time this this Library time right here, that's what we're going to use right now, so we're going to say while oops while True and go like this, do a colon. We're going to say check unor price, that's what we just wrote out, and we're going to do time.sleep. Now this is completely up to you how how much time you want to put in here. For the purposes of demonstration, I'm going to put 5 Seconds, which means every 5 Seconds it is going to run through this entire process, and so let's run this really quick, and I'm going to run it for let's say 30 seconds, and then I'm going to pull this in right here. So we just looked at it earlier, we had four um well five rows of data, right? What we are going to do is in just a second I'm going to stop this, you know, maybe after 30 seconds or so, we're going to see how much data is in there uh and let's stop it right now. It's been going far enough um and La let's run it. So now we have five six seven eight, so I guess I ran for 20 seconds. We can that was for demonstration purposes. I've never do any some anything every every 5 Seconds um unless it was like Black Friday on Amazon. We can put this as long or as short as you want. You can run it every second if you want um that doesn't make sense to me, but you can. What we can do is do a little bit of math uh and I don't know this off the top of my head, so I'm going to uh do the math with you live, pretty exciting stuff. Got the calculator out. So there are 60 seconds in a minute, and this goes by seconds by the way, and you could do you know you can do some um some string up here of calculating this, but I'm just going to put in the number because it's easier uh maybe not easier. I'm just going to do it. There's 60 seconds um in a minute, there are 60 seconds or 60 minutes in an hour, so that's one hour uh and we can do 24 hours in a day, so that's 86,000 400. I believe did I read that right? Oops, did I read that right? Right, yes. So this now if I ran this and I'm going to this is going to check the price every single day, and this is the entire point of this um of of this project, not the entire point, but this is a big part of this project is we want to create our own data set. Now something that I personally really love is a data set that has you know that I can do some type of time series with. Now this is not exciting, it's probably not super exciting for this right, but you get the idea that if this price were to change, we would then see that reflected in the data at some point. You can do this on any item you could ever imagine on Amazon, it's the exact same process, and some items change often. This t-shirt will most likely never change um and so you know again this is for for demonstration purposes. The code itself will be nice to put in a project, although the data set that you get from this probably won't be the best I would imagine, but notice that this is running um I can then minimize this, and this can run on my computer basically as long as my computer uh is is working um one thing I will say before I go on to some more stuff, one thing that I will say is that I personally when I did this for a when I um created this, I did something similar and I put this in Visual Studio Code um and I didn't put it in Jupyter notebooks. That's a personal preference. I would look into that if that is something that you want um I think Visual Studio Code is a little bit easier for automating these types of tasks um but for illustrative purposes and for demonstration purposes, you cannot beat Jupyter notebooks. That's why I did it.

So with all that being said, that is basically the end of the project now um I'm not going to stop this and read it again, but you get the point um we now have um a data set that oh jeez, all this again that now has um data. I'm getting out of here. Oh geez, it's hounding me. Let me get out of here. Oh no, all this is embarrassing guys, I'm embarrassed. We now have a CSV file with data in. Now you run this in the background of your computer, you can do that. I have done it. I've ran it for weeks. I have ran it for months um if you restart your computer, just come back in here and restart running this process um it's the same for any automated process unless you start using some online um automation service which will run it regardless of your computer. They do it you know either in the cloud or on some um server, so you know that this is a really good option again if if you restart your computer or something happens and you lose connection, just come in here, run this through this script again um except for the one where it deletes all your data, don't run that one again. Only run that one time um and then you will in fact what I would do is then um I would just comment this out right, I'd come in here and I would just comment this out so that anytime I come back in here, I would never accidentally delete all my data. But that is what this project does. Now something really interesting, something that I have done in the past that I thought was really cool, really useful, I actually did it for um I actually did it for some watches that I was watching, especially on Black Friday. It's when I used it. I was interested in a price drop or specific price change, and what I did was is I said and I don't know, so what I basically did was is I said if the price is lower than let's say let's say we wanted to drop below $14, it would then send an email um and I'm going to show you the script that I used. It still works um and if this is something that you are interested in, this could be a completely different project. I just think it's interesting and I wanted to show it to you, although I wouldn't say this this is part of the um final project. Let me just come in here and we are going to create this super simple um not super simple, we're sending a mail, we're connecting to a server, we we're using Gmail, we're logging into our account. That is my email, you will not get my password. We're creating the subject, the body um we we configure or or just kind of create this message, and then we send a mail. So then I have this Define uh or this send mail. I am blanking on what this is called. I'm going to call it a function, but that's probably not right. So if that price drops below a certain point, it'll send me an email um I have used this and I used it and was able to buy a watch that was like you know let's say 140 bucks for like 90 bucks um on Black Friday sale. I was really really happy about that. So this can be used in that way as well um not something you to write into your project, just something I'm going to include down here if you want to try it. I think it's super interesting, something really fun um really fun to mess around with. I enjoyed this. So with that being said uh this is this is the project um I in the next one and I promise you this one is probably going to get a lot more difficult. If you thought this one was easy, which I hope maybe I hope you do, then that means you're you know pretty good at Python. You know, in the next the next um web scraping project and I hope to do many of these. I might do um even all the ones that I put in that poll, but I started with the one that was the most popular um you know if you were able to get through this, I think that that is fantastic. I think this is a solid project to create um a data set and so use this how you will. You can copy my code exactly. I don't have a problem with that. Again, I don't think this is beginner. There are some a little bit more advanced things and I not even Advanced just like intermediate level things um that you kind of learn as you get into it and so um I hope that this was instructional. I hope I explained it you know well um and I hope that this is useful. Again, you know, when you actually use this, you'll have 22 23 24 25 you know you'll see a price change a price change a price change a price change. Go use a a product or go to something that you were interested in or that you

Know fluctuates often, um, and there are plenty of those on Amazon. I promise you, there are some that literally change almost every other day, like down a dollar, up a dollar, um, and then Black Friday just goes crazy, um, with these price changes. So use this as you will. I hope that this was instructional. I hope that it's useful. I think I said that before, is you know, I'm doing this because I think it's really interesting; it's really useful, um, um. This, to me again, was a good introduction, a really good introduction to web scraping, because in this next one, it gets quite a bit more difficult, um. I would say, on a scale of like difficulty, this is like maybe a four, and it'll probably jump up to like a seven on this next one, um, just, just much more, um, technical or or coding heavy. So, um, you know, look forward to that if that's something that you look forward to. With that being said, I'm going to go back over here for my send off. With that being said, I hope this was helpful. I hope that you learned something. Um, don't get mad at me if it was too easy; don't get mad if it was me, if it was too hard. Uh, I'm doing my best over here, so I appreciate your patience. Thank you so much for watching. I really appreciate it. If you like this video, be sure to like and subscribe below, and I will see you in the next [Music] video. [Music]

What's going on, everybody? Welcome back to another video. Today we're going to be creating a script to automatically take data from a crypto [Music] API. Now this project stems from an earlier video that I did where I walked through what an API was and how you can use it, and in that video, I showed you how to use Coin Market Cap's API so you could start pulling in their crypto data. And in this video, we're going to take it one step further and automate that process. Now we're going to do a little bit of transformation with the data. I'm going to show you some cool stuff of how you can use it, and maybe we'll do a little bit of visualization at the end, but that is not the main point of this video; it's mostly around the automation piece and a little bit of the data cleaning piece as well. Now, fair warning, this is not a beginners level project; it's probably more like an intermediate project, and it's not even a complete project per se, because we're not doing all the data cleaning; we're not doing all the visualizations, but, but if you follow along, we're going to cover a lot of different things, and you're really going to set yourself up to be able to do just about anything you want with this data or different APIs that you pull from. So, with that being said, let's jump onto my screen and get started with the project.

All right, so this is where we stopped in our last video. So if you haven't watched it, now is the time to go back and do that. I'll have a link in the description. Also, all the code that we're going to be looking at today and working through is going to be in a GitHub repo below, so you can go and get all the code and have it completely finished and just follow along, or you can code it from scratch along with me. I do recommend writing it from scratch if you can, because I think you'll learn more, and you'll make mistakes, and you'll learn from that as we go through it, but it is up to you. So let's get started. And as you can see, uh, we have the script right here, and I'm starting basically from scratch. I have a completed one up here; I'm actually going to get rid of those, um, and what we're going to do is we're going to start from exactly where we started in our last one. I'm going to run the script, um, this is going to pull from our API, and we're going to look at the dictionary, set our option, and do our JSON normalize. So this is where we literally left off from the from the last video. So we have all of this data, and what we want to do with it is we want to kind of automate that process, right? Because we don't want to have to come in here, run this, and, you know, put into a CSV manually or something like that. We want to automate this data collection process so that we can just have the data ready for us to use, um, and it all be ready to go. So we're going to be using this script, um, but you know, we, we might want to add a little bit more to it before we do that. Uh, the first thing that I want to do before, um, before anything is something that I like to do when I'm creating these automation scripts, as I, I like to add a timestamp, uh, and the reason for that is because I want to know when I ran or when each of those, um, loops, you can say, runs through an and does those automated runs, right? So if I do it every day, I want to know what time of day I ran it, making sure each run ran successfully. And so all I'm going to do is I'm going to add a new column at the end and just call it timestamp. So let's go right up here, and we're going to say PD.dot, and there's something called to datetime, so we're going to do to_core_datetime, and then we're going to do now. And what this is literally going to do is take the the date, the the timestamp of right now when it's running, and it's going to show that. Now we need to, of course, add a new, a new column for that. So all we're going to do is we're going to say data frame, whoops, we're say data frame, and let me see real quick, we just have the data we need to add; we need to create this data frame right here. So data frame equals, and then this JSON normalized, and we're going to say data frame, and then we're going to do a bracket, and we're going to say timestamp, and we'll do, well, are all these lowercase? We're going to keep with the the lowercase; we're going to say timestamp, and we do that bracket, and we'll say equals. So what this going to do is going to first off, it's going to create this data or or assign this DF as our data frame, and then we're going to add this timestamp and add this new column. And so let's run this really quickly, and let's go all the way to the right, and this is our timestamp, and this is the time, uh, that it is right now. This is the day that I'm running it; this is the time that I'm running it. And so this is working properly. Now, if you look really quickly, there is a last updated in here, and this is very close to this timestamp, but it is not the same thing, um, but if you looked through this data and you really into it a little bit, there's this last update is coming from Coin Market Cap's API, and this is when the actual, um, cryptocurrency was updated in their system, and so it is going to be really close, but it's not going to be exact. And so I don't like to rely on built-in ones that, you know, are coming from an API or something; I want to make one myself that's running on the system where I'm creating the automated process, just like, just something I do, um. So now we have this original data frame created, right? We, we now have what we need, but what we want to do is to keep adding data to this, um, we don't want it to just go to, um, you know, create these 5,000 rows; we want it to create 5,000, 5,000, 5,000 over time, whether it's a day, an hour, a week, um, whatever you want to run it. So, um, what I'm actually going to do is I'm going to limit this a lot; I just want to look at the top, let's say 15. So we're going to do that, that we're going to run through all this again. So now I just have top 15; it's going to be, um, easier to, to see, and it won't take as much time to run our scripts again. You can keep as many as you'd like; if you want a 100, 200, all 5,000, you do whatever you'd like, but what we are now going to do is we're going to create a function using this original script. So we again, we have this data frame, and we are going to create an automated process that is going to automate a script to automate this that is going to append data to this data frame right here, so that's kind of, you know, the big thing that we're trying to accomplish in this project, um. So let's go up here, and we're going to, we'll just take from here all the way to here; we just going to copy this and going to paste it down here. Now what we need to do is we need to create a function, so we're going to say DF, and we're going to call this the API Runner, because this is going to run our API, um, whenever we need it to run. Now, when you are formatting, um, something for a function, it, it needs to be formatted properly, and so what we need to do is need to go over here, hit tab; we're going to do this all the way down; I'm just going to skip forward when it's all the way done.

All right, so now we have this URL, and what we want to add, because this is again, this is going to run through kind of this, this automated process; we're going to run this, um, this function there; what we want is to also add this right here. So we need to take this, and we're gonna need to add this; we'll just put it down here. [Music] Okay, and let's do that. So what we have so far is really close to what we want our function to be, um, we have this function that we're going to be running through; it's going to call this function; it's going to call the the API; we're going to use our key; we are going to, um, you know, test it, load it, format it, and format it right here; then we're going to add this timestamp, and then we will have this. Now, right now, it's just C, it's just going to print this data frame basically, but that's not what we want. Right now, what we want is to actually append this data. So when it gets to here, when it gets to this data that's going to be right, um, right here, what we want to do now, since we already have the original data frame set up up top, is we now want to say that this is going to be data frame two, and we're going to say it's going to append it to data Frame 2. And so the original data frame, we're going to say data frame 2.append, and we're going to say df2. All this does is this says this new data that's going to be coming in every time, let's say it's a loop, and it's just looping through, pulling the data, pulling the data, pulling the data; we're going to create this data frame; we're going to add, add this timestamp, like, like we want, and then we're going to append that to this original data frame. So as of right now, this looks good. I will, we'll run it in a second. I'll create it. So I just created it. So now we need to actually create our script to automatically run this. So we're going to do something called import OS, and let me tell you, there's a thousand different ways to do this, and there are better ways to do this, but they are much more complex, much more complicated, and some cost money in order to do it. I'm going to show you different options on how to do this in future videos on how to automate your Python scripts, but this one, to me, is one I've used a lot, um, many, many times for different projects, and it works. So I'm not going to show you the most complicated thing in the world; I'm going to show you something that I've just used a lot. And so we're going to say from time import time, from time import sleep; that one's important. And now we're going to create our loop. So what these, um, what the time and the sleep and the OS, uh, your operating system, what, what these are going to do is they're going to give us the ability to track the time, and we're going to be able to run through and call this function in certain intervals that we want. So let's create our for loop; we're going to say for i in, now you can create this specific part in different ways, but what I'm going to do is I'm going to say range of one, uh, let's say 333, and I say 333. And if you remember from the first video on the API, you only have 333 runs per day, and so if I ran, ran this 333 times today, that would be our max, and so that's why I'm using that 333 just for reference. So now we're going to do API Runner. So in this loop, we're going to call this function up here, and then I'm going to say I want to prove or, or show, have an output to show that this is running through successfully. So I'm just going to, and you can write anything here; we're just going to say API Runner completed, completed successfully, successfully. How do you spell that? Successfully? That doesn't look right. I'm just going to say completed. All right, forget that. I don't remember how to spell successfully. If that's, if it spelled it right, you guys spell it that way, but I can't remember. Now we're going to use this sleep right here. Now this counts it in seconds; you can change it to minutes, hours, whatever. We're going to have it run every minute, which is every 60 seconds, and so this is going to, I'm just going to say it's going to sleep for one minute, and then we're going to say exit. So all this is going to do, and this is again fairly simple, it's just a simple for loop, and what it says is it's going to call this API; it's going to tell us that it ran successfully, and then it's going to wait for 60 seconds, and it's going to run again. That's it. So let's run this and see what happens, see if what we did works. So ran the first time. Now I'm not gonna, I'm not going to bore you because I'm doing this live. Exactly what we're about to get is what we're going to use. I didn't run it overnight or, or for a week so that we have a bunch of data. I'm what you were going to work with; I'm going to work with as well. So I'm going to wait a few minutes; I'm going to let this run. I want you to do the same thing; I'm going to let this run for maybe like five minutes or so, and we'll work with what we have, and we'll keep going with the project, because again, we're not the point of this project is not to create the final product or creating all the visualizations that, um, will most likely be in another video where we're taking all this data and doing all these things with it. The point of this video is to automate it, clean it up, to where we have it to where we can really use it, and then I'm going to let you guys loose, and you guys can do whatever you want with it, and I think it's really setting you up for a lot of successful projects in the future that you can do all by yourself without me having to walk you through it. So as you can see, it's already ran through twice. I'm going to pause for a second; I'm going to let that run through, uh, just a few more times, and then we will continue with the project.

All right, we are back, and of course, it's only ran what, five times, um, it has not reached the limit of 333, so we are perfectly fine. What I'm going to do is I'm just going to stop this by clicking this, uh, square up here, and it's going to give us some error, and then we're going to check it, and we will see what we have. I don't know why it's taking so long, if I'm being honest.

All right, so I interrupted it, and let's run this; let's see what we got. I hope we have more than 15, because if not, I'm going to be very upset. Okay, so, okay, well, uh, I made a mistake, um, I was supposed to put data frame right here, and I had data frame too. So, um, take, change your script; do not do what I just did. We're supposed to be append; it's supposed to be data frame append, and we're supposed to be appending the original D, this data frame two to the original data frame. So, so, um, I messed up on that one. Let's rerun that; let's rerun that, um, let's see, local variable DF reference before assignment. Okay, this is perfect, because this happened to me before, um, we're running into all sorts of good stuff. I like to keep this stuff in my videos; I laugh because I hate running into mistakes, but everybody says they, they're happy that I do this, um, so I'm going to keep doing it; I'm not going to cut this out, I promise, um, but what we actually need to do is we need to go back up to this function, because what happened was is we called this data frame, and now it's, it's because it's in a function; it's in what they would call a local variable. What we need to do is we now need to state that this is a global, um, it's just called a global; that's all it is, um, and so what we're going to do is we're going to do tab; we're going to say global, say DF, and what this should do is this should declare it as a global variable, and it should let this run properly. Let's hope it does.

All right, it's running, um, again, I run into mistakes. Let me tell you something while we're here for just a second. This project, I ran into probably a hundred mistakes or a hundred errors, issues that I had to research for hours, um, and hours. I'm legitimately on Stack Overflow and just Googling and figuring these things out. There were a lot of new things that I had never run into before, um, just on this project, and so, um, everything that you're seeing is from after I went through all of those things or after I fixed all of those things and had to really work through them. It was, it was very, um, it was frustrating at times; I just, I couldn't figure it out. And so what you're looking at is kind of the polished version of that now that I have everything laid out, because I, I can't spend 10 hours on a project; nobody would watch it. So just know that if you are running into some of these mistakes or you run into mistakes later on when you're expanding this project, that's completely normal. So what we're going to do is we're going to let this run for a little bit, and then after maybe three or four minutes, we'll come back, and we'll keep going with the project.

All right, so let's run this and check and see if we have, uh, the data that we're looking for, uh, and it looks like we do. Let's go actually back up here really quick, um, we want to set this to display max rows because I want to be able to see all the rows and not just, um, a few of them. So, and that just instead of it gives us this scrolling instead of that dot dot dot that shows us just a few. So there's our original 15, and then we have the next, um, the next loop, and then we have the next loop, and let me scroll over to the timestamps, and I'll show you what I mean, um, so was ran on 52651. Let's go down 526 at 150, 2905. I say 1501, 2905, and then the next one you can see was ran at 36, 31. These are all the ones one minute after each other. My original one was from earlier, 32, 33, yeah. So you can see 32, 31, 3030 or, um, 3029, and this one was about 15 minutes ago when I first, um, ran the original data frame, right.

All right guys, this is Alex from the future. I've actually completed this entire project, uh, in the video, and you're about to see all that after this, but I wanted to show you one more thing that you can do in this function up here that I didn't show you, uh, originally that I'm coming back to show you, and that's how to actually put it into a CSV. Now all we've done

In this one, is we we've kept it all enclosed in a data frame, and that's it. And that may be great, but a lot of you guys are going to want to automate this and put it into a CSV. And I want to show you how to do that. All right, so what I'm going to show you really quickly is right here in this, uh, in this folder right here. I have all these different API 3s and 4s. These were tests that I did before, but what you can do is, instead of just putting it into a data frame, you can actually append the data to a CSV and have that CSV sitting out there for you instead of just keeping it all in the data frame. And there's a lot of different uses for that. You may want to have that file separately from here, just in case something times out or something breaks, which is a legitimate concern, or your computer shuts off, or or something like that. That is a legitimate concern.

So what we're going to do is we're going to say, um, if not, and this is basically an if statement, we're going to say os.path.isfile. So what this is going to do is check if there's already a file under this name, and we're going to do r.or or R. Um, if you have never done, um, if you've never done CSV stuff before, it's really important that you put that you you're going to get an error every time. So we're going to take this right here and we're going to copy that, and we're going to put that right here, and then we're also going to do a slash, and then we're going to name it basically, um, let's name this API because I don't think I have that one in there. I think I deleted it. Yeah, so I don't have API, so I'm just going to keep it api.csv, and then I'm going to close that parentheses, and then we're going to add a colon right here, and we're going to say: if that does not exist, we are going to write this to it and create it. So we're going to say dataframes, that's this data frame right here, dataframe. We're going to say to_csv, and we're going to do that R, and then we're going to copy this, so let's just let's just replace it like that, and then we're going to say comma header, oops, header is equal to column_uncore_names.

So what this is going to do is, if we run through this, and what we would have to do is, um, I'll talk about this in a little bit, we'll have to change this up a little bit, but what this is going to do is going to check to see if this file right here exists. If it does not, it is going to create it and create the column headers based off the this data frame. That is what that does. Now what we want to do is say else, and this next part that we're going to write is saying: if there's already the API file there, we want to append the data; we don't want to overwrite it or anything like that; we want to append the the data. So we're going to say we're basically going to copy this, maybe not the whole thing, but I already did it, um, so we're going to copy that and we're going to say mode, oops, mode equals a, and a stands for append, and then we're going to say header, oops, keep messing up, header, and we're going to say false, oops, we're going to say false, which means when it appends the data, it's not going to use those the column headers every time, which you don't want because every time you append it, if you added the headers every 15 rows, every 15 rows, you're going to have another headers that you're going to have to like go out into that CSV and filter out and and get rid of them. So we're going to say header equals false.

Now, just a second ago, I said you would need to mess with this just a little bit, and you would, because every time, um, you'd be putting in this data frame, which it's already appending it to this data frame, so every time you'd be creating a lot of duplicates if if you kept it exactly as is. What you were going to need to do is basically take it back to its to its, um, bones, um, so you need to kind of keep it like this. So what you need to do is just now run this, and it would work perfectly. Uh, let's test it really quick, um, to see if it works, uh, because I'm I'm promising you something; I want to make sure it actually works. Let's run it this time. Okay, so it just ran for the first time, so it should have created this file. Let's go see if that works properly. So now it just created that file, and now we're going to see if it actually appends the data. So let's wait just one time, um, and then I'm going to stop it. I'm going to see if it works again. I'm just verifying to make sure that what I'm telling you is actually working, uh, because if it doesn't, I would feel terrible. We don't want that. And while that's running, actually, I'm going to add this because now I want to show you how to call it, um, super easy. We're just going to do pd.read_csv; we do that; we're going to call this just like that, and then we're going to say dataframe, and we're just going to do 72, something random because I've already done this whole project; I don't want to mess anything up, so we're going to say dataframe72. So now let's stop this, um, and what we're going to do is, once that stops, we're going to run this and see if it actually, um, worked and see make sure that this actually pulled the data in. All right, so we interrupted it; the file is ready to be read in, so let's read it in. There's our file, um, let's see what did I mess up, or did I mess anything up? Ah, I didn't mess anything up. This is the index for this file, and we already had this in here; we'd probably be able to get rid of it, but if you see, we have 0 1 2 3 4 5 6 7 8 9 14, then we have 0 1 2 3, and if we look at the timestamp, it should be one minute apart, so it's 11:19:45, it said 12:04:45, so this worked exactly as planned.

Again, you have two different options: you can just keep it how it was before, and I'll leave both of those options, you know, in the in the script so that you can kind of choose which one you want, but, um, that's how you do that. So then right here, you're appending it to a CSV file, and then if you just keep this and you get rid of all this, you're just appending it to a data frame. Now, please continue with the rest of the video that I already have done, um, but again, I'm future Alex, so, uh, please continue with the rest of the video. Okay, so we have all this data; we have we have so many columns we can do now, you know, if you want to completely just go and do your own thing, you absolutely can do that. I'm going to mess around with a few things, um, kind of show you something that I did that I thought was really interesting, um, in order to visualize this data a little bit and transform it a little bit to make it more usable, um, but we're not doing a full data cleaning; that's not what this project is; I'm not doing a full data cleaning of this data; that would be a ma a very large undertaking because honestly, this needs a lot of work. One thing that I do want to clean up really quick, uh, is is this right here; I this the math will be fine; it's just the way that it's shown on here is in state the scientific notation, and I don't like it. So what I'm going to do really quickly, I is just, um, get rid of that. So we're going to we're GNA say pd.set_option, and this is going to be do parentheses; I'm going to say display; this is just this how this is formatting, so we're going to display.float_format, and we're going to say comma, and now we're going to use this lambda, say x:, and we're going to say %.5f, and that right there, and we're going to say %x. Now, if you don't know what lambdas is, lambdas are, um, I highly recommend looking those up, um, again, this is not a beginner tutorial; whoops, no such Keys display floor format; that makes sense; uh, this is float; yeah, guys, this is not a beginner's level. All right, uh, you can't use the floor format; this is the float format. All right, so now let's take a look at this, uh, this DF, uh, this data frame that we have, so we're just GNA hit DF, hit enter, and now our numbers are a little bit more easily readable. I prefer it this way; you do not have to do this; I'm doing this just because this is what I prefer. So let's jump right into it, um, something that when I saw this data, I was like something that I really thought was interesting is this percent change of one hour, percent change 24 hours, 7 days, 30 days, 60 days, 90 days. If you're not in crypto or you don't do investing or anything like that, what this is going to show us is how I mean it's pretty obvious how much the price of this coin has changed over the last hour, 24 hours, seven days. So as you can see, it's it's barely fluctuated over the past 24 hours, a little bit over the past, um, seven days, a lot over the last 30 days, 60 days, and 90 days, 20 minus 26%, minus 33%. We're in May; we just had a kind of a crash in crypto a couple weeks ago, so I mean this tracks right, but I want to visualize this, see this, and kind of see, um, you know, how this is going to look and how if I can gain any insight from that information, and just having it all displayed for me, but in its current state, um, you know, we really cannot do that.

Now, another issue, not an issue, but another thing that we have to take into consideration is we have Bitcoin net right here; we have Bitcoin right here after different polls. Now, we just did it a minute after each other, but for your project may do it a a run each day, a run every hour or something like that, right? And if you did that, your data could be very different, and so you may just want to take this first one, but what I'm going to do for the sake of this project, I'm going to group them. So let's go down here, and we're going to say DF.groupby, and so if you've ever done something like SQL, uh, this is how you Group by in pandas. Basically, we're going to group by, uh, the name, so so on bitcoin, etherium, te, so we're gonna we're gonna do that on name, and, uh, I'm not gonna I'm gonna say sort is equal to false, oops, I'm not going to sort it, uh, you could say true there, but we're not going to, and I guess you'll see why later. We're going to do an open bracket, and now we need to choose what we're going to group by, uh, or what we're going to what columns we're going to have. So I'm going to do another open bracket, and I'm just going to copy and paste these, so I'm going to start right here at quote percent_one_hour, so I'm going to do boom, and then go over one, and we're going to take 24 hours, paste that, comma, we have the 7day, 30-day, and we're going to do like that, and I'm just going to do comma, I'm gonna do the same one, but I'm just going to manually change it to 30day, rid of that at the end; I don't know what that is, uh, then we're going to do 60 days, and comma, and we're going to do our last one, which is 90 days, and let's see what that gives us, uh, doesn't give us anything. Okay, I know what's wrong here, um, we forgot to add basically the what we're we have; we're grouping by something; we need to have like an average, a mean, a mode, or something like that, right? So all we have to do is go to the end right here, and let's just do we're going to do an average, um, and so we're taking this number, let's say this is for Bitcoin, so we're going to take this number in this one hour for every time it's Bitcoin; it's going to group them all together, um, and then it's going to average them, so in the past five minutes where it's been running, we're going to take the average or the mean of that. So let's run this again, and so now this is our output. Let's take a look. Oops, I meant down here; let's run this now. Now what we have is all of these, um, cryptos; these are all 15 that we have, and this is the average, um, for this 1 hour, 24, 7 days, 30 days, 60 days, and 90 days. So now we have all of our cryptocurrencies over here; we have our percent changes up top, and then our averages, um, here as well. And so now what we're going to do is, you know, if you try to visualize this as is, doesn't really work because these percent changes are up here as columns, and we don't really want them as columns because that it just doesn't work for visual for actually creating the visualizations; we really need these to be rows. And so my initial thought when I was doing this was I of course I need to pivot, um, you know, if you've ever used pivot like an Excel or Power BI or something like that, that was my first thought, and I tried everything and I could get not could not get it to work, and I almost gave up until I I ran across, um, something called stacking or back and and so this was not something that I I I think I have used it before, but I I couldn't remember to be being completely Frank; I couldn't remember how to do this, so I just did, um, once I saw what it was, I did stack. Let's make that data frame four; you don't have to do this; you can keep this all the original data frame; I'm just I like for visual purposes; you can see like the progression that we're making, um, but I like to, you know, create its new data frame, and I can always go back and look at this data frame three, um, as we go, but you don't you don't have to do that; that's just what I'm doing. So now let's take a look at this now, uh, up here we had Bitcoin, and we had all these columns, and we had, uh, these numbers as rows, but now we have all of these as rows as well; this how we have this is much much more usable, um, and if you've ever done something like pivot or the stacking before, you'll know that you you kind of have to do it if you really want to visualize this well, but, um, you because we just stacked it, it kind of changed it, so if we look at, um, let's look at the type of let's do type of dataframe three; this is before, um, before we stacked it, this was in a data frame, but now let's go and look at dataframe four. So this is a series; this is no longer a data frame, so we have to remember that that's that's really important because we can no longer treat it as a data frame; it's now a series, so we want to get it back to a data frame; we don't want it to be like that because you can't really use it in the series. So what we're going to do, and let me just create a few of these so you can be up here better, so now what we're going to do is we're going to say dataframe4. and something called to_frame, so we're going to make this into a frame, and now we're going to specify the name, and it doesn't mean, um, the name like right here; we have actually mean the name of these values right here; this is part of the stacking process in these columns or these two columns. So let's go right here, and we're going to call it let's just say values, and let's make this dataframe five, and let's see the output, whoops, for dataframe five, and now so there's that values, and now this already looks a lot better, right? So it's in this it's in this more, um, this is already a data, so this is a data frame, so let's look at type dataframe five, so now it's in a data frame, but the issue is is that this name is kind of acting like a an index, which we don't want because we want to be able to use this, so it doesn't really have an index at the moment, so we need to give it an index, but typically when you give an index, you'll do something like, um, we'll say dataframe.5, we'll do set_index, and then you'll do something like, um, name. So let's just do dataframe six is equal to we'll see we'll see what happens here; it's going to give us an error. Oops, what I meant is we're going to do dataframe five bracket, uh, name, and that's a column, right? We're going to do that, and it's basically going to say that that's not going to work, and and what we need to do is what or at least what I want to do, and what we're going to do in this video is I'm going to create numbers; I really would just want it to be numbered 1 2 3 4 5; that's what I want, um, but we don't have that right now; I can't just will it into existence. So now what we're going to do is kind of create, uh, an index basically out of thin air, so we're going to do pd.Index, and we're going to say, uh, you know, we basically want how many, um, rows are in here; that's where we want our our, um, index to be; we want it to count how many are in here. Now you can make this dynamic, and I it probably wouldn't be that hard, but I'm gonna take this super lazy route, um, and I'm just GNA say let's do DF.5 or oops df5.count, and there's 90 values in here, so what I'm going to do is I'm going to do a range of 90, uh, and this is not, uh, I would definitely make this dynamic, but I'm again I'm just being being a little bit lazy; we call this index is equal to, and I'm going to put this Index right here, so now this is a number, so now it's going to literally Index this for us. Now I've ran into this issue many times, um, so what I need to actually do is to reset this index and then do it properly the first time, uh, so let's do re let's get rid of this; let's reset this index, um, and it actually fixed itself, um, so what was happening was is we were indexing something that was already indexed; we were causing issues in a nutshell, so we reset the index, and now this is what it looks like, and this is exactly what we want; this is really how we wanted it formatted in order to for our visualizations; we have multiple rows for the Bitcoin, um, each of these columns are is now a row with the value attached to it; exactly what we wanted, so, um, really quick, I for whatever reason, it it makes that, uh, level one; I don't know why, but we're just going to rename that column really quickly, so we're going to do dataframe6.rename, and then we're going to do and open parentheses, say columns equal to, we're going to do one of these these bad boys, oops, one of these bad boys, this this type of bracket, and we're going to say level_one, and we do a colon, and then oops, and then a colon, and then we want to change it to, and I'm just going to call this the percent_change, so let's call this dataframe seven; again, you don't have to do that; I'm just doing it, so now this looks much much better. Now let's try to visualize this one, um, because we haven't done any visualizations yet; we've just been messing with the data a little bit; I I, you know, I kind of want to see how we can use this; it's something that I personally am interested in, so I kind of wanted to see visualize how these changed over these these time periods, um, but we need to, um

Import some stuff in order to be able to visualize this. So we're going to import cbor as SNS, and if we need to, um, we're going to import matplotlib as well. I don't know if we'll use it right now or at all, but um, we're going to we're going to add it in here either way. So now those are added, and so what we're going to do is come right here; we're going to do SNS.plot, and we're going to oops, we're going to say the x axis is equal to, and we want to do this as the percent change, percent change, and then we have the Y axis. Now we want the y-axis to be these values right here. Say, comma Y is equal to, and we're going to say values, oops, and then we're going to say comma, and we'll say we want to basically create a legend, um, I guess you could call it. We're going to say Hue is equal to name. Um, I'll show you what it looks like without it, and then you know you can see that we need that. We're going to say the data is equal to this data frame seven, data frame seven, and then we are going to say the kind is equal to. Now let's run this and see what we get. And super quickly with just, you know, limited um inputs, here's what we have. Now this looks really good. We can narrow this down if we wanted to to a few less because there's a lot here, and there's a lot of colors, but again that's just because we have a lot of different stuff. But there's a few that are doing really well. I think this is Tron, um, and then we have a few that are not doing so well. But it's really hard to see; if you look down here, it's really hard to see this, um, and that's just because of the the column name. And so I actually want to change these column names or these values so that when we visualize it right down here, it it doesn't look like that. I kind of want this to be, you know, at least one good visualization you can take out of here. This is definitely not perfect or complete by any means, but you know, you can take take that away from here.

Um, so let's um I did Alt Enter, which adds another row. I could have just pushed plus; that's was kind of the lazy way. Um, what I'm going to do is I'm going to change these um these values in here. So how I'm going to do that is I'm going to do data frame seven, and we only want to look at this one column, so we'll do that right there, and we want to say .replace, and we're going to open parenthesis and then a bracket. Now what we need to do is, I'm just to show you, um, one of them is I'm going to say this one hour. Do that, oops, and then what I need to do is a comma, another bracket, and this is what it's going to change to. I'm just going to say one hour, oops, one hour, um, and we'll do this one really quick, and then I'm gonna I don't want you to have to watch me type all this out, but I'm going to go through and basically do all of this uh for those. But let's let's see this really quick. And so now as you can see that um the originally it said "quote. USD percent change 1 hour" is now only 1 hour. Now this didn't actually do anything; we need to apply it to this right here, so I'm going to say data frame 7 is equal to, and then we'll run data frame 7 again. So now that has actually changed that value. Now I'm going to go through and I'm going to update that for every single one.

All right, so I basically just put the other ones um in here that we wanted to change with commas afterneath, so I have 24 hours, comma, with the 7 days, 30 days, 60 days, 90 days, and then this bracket over here, which tells uh it what to change it to: 24, 7 days, 30 days, 60 days, 90 days. So let's run this; I haven't even tried it yet, uh, and it looks like it obviously worked properly. So now let's go back down here and let's run this again, and look at that; it looks so much cleaner, so much nicer, um, and as you I mean all of them with that 1-hour change has very little change, and then you can look back, so we can see back within 90 days it's gone. A lot of these have gone down, which again, if you're following crypto, you know there's a big crash recently, um, especially with with you know all these altcoins um that you're seeing right here went down a ton. So I think this is um Avalanche or die or whatever these ones are, you know, went down dramatically, whereas there's one up here, this Lone Wolf, um, that's just that's just did do really well for whatever reason. So it's really interesting um to see. Now this is a pretty specific um visualization that I personally wanted to see and I thought was interesting. You can do absolutely whatever you want to do with this data; I mean, there's so much here, you can do a lot, I mean a lot with this data, especially depending on how long you track it. Right? I only did this over the course of like five minutes, but if you set this up um and you can track it over a longer time now um let's say you wanted to do something much simpler; uh, you just wanted to look at like Bitcoin over that time that you you know uh uh took the data in; that's going to be a lot simpler than what we just did, and I'll show you how to do that really quickly. So we're going to look at the data frame, and we are going to say uh or we're going to take specific columns; we just want um a few columns that we want to keep or or pull from, so we're going to take uh oops, we're going to take the name column; we're going to do uh might be easier if I copy them, but I'm just going to write them out: "quote. USD.price"; this is the price of the actual cryptocurrency; then we're going to do timestamp, and let's make this data frame, and we're just going to do 10 for absolutely no reason; maybe made at n; it would have been easier. So now we just have these um these columns, and you know we have all these separate columns, so what we can do and the re kind of the reason I want to show you this is you can just query this really quickly and just take the columns that you want. So let's say we just wanted to look at Bitcoin, so we're going to say data frame 10.query.open parenthesis, and we're going to say name is equal and equal is not like that uh when you're doing it like this, you need to say equal equal equal to oops, ignore that uh is equal to bitcoin, and we're going to do it just like that, and we're going to say data frame 10 is equal to. Let's try running that; I think something's wrong with it; try it like this; oops. All right, let's try that; there we go; it was just the I needed a double quotation instead of a single quotation; that was the issue. So now we have Bitcoin; we have the price, and we have these timestamps. So this is the actual time when we ran it. So this is the original data frame, and then in the you know this this project, it took me 15 more minutes to get this one, and then we had it running properly for the next five minutes. So that's you know that's actually what we have now. If we want to just visualize this really simply, what we can do is we're going to say uh we're going to do SNS.lineplot, and that's going to be like a little line chart or line graph, whatever you want to call it, and then we're going to say x is equal to and we'll say quote no actually we wanted the timestamp to be on the x-axis, um, and then we'll do y is equal to "quote. USD.price", and let's see if that works. Good; not interpret timestamp for the parameter uh that's because it's not understanding that data equals data frame 10. Now let's try this. All right, so this is uh looks terrible. Let me me just say SNS.set_theme, open parenthesis, we'll do style is equal to darkgrid. This looks a little better. Now again, we are looking just at a very very short time series, but we can look at just Bitcoin, or we could look at multiple, and we're showing this you know this line that's showing us this trajectory over time. So you can get really creative with this; you can run this for a long time; you can show Bitcoin over days, weeks, or months, months, however long you run this. And so that's really all I've got. Um, honestly, like I said, this is not a I wouldn't say this is a complete full project, but I'm showing you how to do something to enable you to kind of run with it and run with the ball and do basically whatever you want with this. You can pull it from you know data from a different API; you can use this exact API in data, but I wanted to show you just a few things that I initially saw that I might do with the data, and you you have so much. Let me go back to this original data frame; uh, right, we'll use this one right here, this one right here; look at all this data; I mean, you have so so so much data. Actually, let's go to this one; this one's better. You have so much data, so many numbers here, um so many columns that we didn't even look at that you can use, um, and so you know there's a lot that you can use here, and I'm really trying to just set you up so that you can run with it and do whatever you want. I could have done a thousand different things here, but you know I tried to just show you two things that you can do with the data that I thought were pretty interesting or or simple to do, and you know I want you guys to go out and do something way way better than what I did. So I hope that this was helpful; I hope that this showed you how to automate that process so you don't have to sit there and click it and append it and do all these different things that it can show you how to kind of automate this process, and hopefully that will be helpful in your future projects. So with that being said, thank you so much for watching. If you made it all the way to the end, you guys are fantastic. If you like this video, be sure to like and subscribe below. I'll see you in the next [Music] video.

What's going on everybody? Welcome back to another video. Today I'm going to be walking you through how to create your very own portfolio website. [Music] Now we just completed our data analyst portfolio project series where we walk through four projects in SQL, Tableau, and Python. And so if you have completed those projects, you now want to share them with potential employers, and I think the best way to do that is to create your own website. In just a little bit, I'm going to show you two options on how you can actually create your own website. The first one is a website builder like wix.com, and the second one is hosting your own website through something called GitHub Pages. Now if you have never created your own website before, it can sound a little bit daunting, but don't worry; I'm going to walk you through every single step of the way, from the very start to the very end, and once you reach the end, you'll have a complete data analyst portfolio website. So without further ado, let's jump on my screen and let's get started.

All right, so the website that you're looking at right now is the actual website that we are going to build in this video; um, it is hosted on GitHub Pages, or github.io. So this is actually being hosted right now by GitHub pages. So if you type this in—I'll leave a link in the description—if you type this in, um, you will get this page, and you can check it out for yourself if you don't want to just watch me look at it. Um, so you know it has this little header, and you can write a little bit about yourself, and then these are our actual projects. So this is our data cleaning in SQL project, um, and then there's the COVID uh data exploration Tableau dashboards, movie correlation with python, um, this is a future video; I plan on doing a few more of these projects because I just really enjoy them, so uh, you know, and then there's this contact information at the bottom. So it's a really simple website, and it gets the point across, and uh I have something similar to this for my own personal one; I I use a different variation, but um this all comes from this website HTML5 up there; are lots of templates, lots of options that you can use. Um, again, the one we're going to be working with is this one, but I use a different one for mine, and they are really good; I mean, super easy to build and customize yourself. And I will say again, I have no experience doing this; I just watched a YouTube video that showed me how to do this, and now I am creating my own YouTube video to show you how to do this. So it's coming um pretty much full circle. So like I said, there's no no real narrative to it; it just clicks to your project. Um, if you click on this and let's just open a new tab, it'll take you right to our to the GitHub project, um, and then you the the whoever is checking this out, like an employer or a recruiter, can see your code. So super simple. Another way that you can do this is kind of creating your own website through like a template or something like that, um almost like a Blog style. So I imagine it being very something very similar to this, where there's this introduction, and you can talk about you know where you got the data set, how you got the data, um and then you can kind of have a more narrative uh approach with screenshots and with some code as well. So you know this person included screenshots, um and then there's the code right here that I can actually copy um and paste that, and it just walks through the logic of how the project was done. Um there's a story to it, really, and so that might be something that you're interested in. Now I have done something like this in the past, and I used Wix, and there's a you can do this completely for free. Um the one we're doing today is completely free as well, but you know if you want the customized um the customized URL, you do have to pay for it on Wix, but you can get a free Wix website with the Wix um in the URL. So you know try this out; these are super easy; you can find thousands of templates and a million tutorials of how to do them, um so that's not the one we're going to be working on today. So with that being said, uh the very very first thing that we need to do before we do anything is actually download Visual Studio Code. This is where we're going to download that HTML, and we're going to be working with it in there. Um again, I don't know if I said this before, but it seems a little bit intimidating at first, but once we actually start looking at it, it's a lot easier than it looks; I promise you. So if you are me and you have a Windows computer, you'll just go right here; you'll install it; um super easy to install; I'm not going to walk you through how to do that. Um of course, I already have it up and running down here. So once you have that installed, what you're going to do, going to come to this website—a link should be in the description—we are going to download this; all you have to click is the free download; it's going to pop up; I'm going to put it in my downloads; I'm gonna click save; fantastic. Uh, so let's go to the downloads, and it should be right here. Now if we open this up, it has a few different things in it. Okay, so um I'm using the Brave browser, so that's going to be right here, so that's this the symbol, but for you, if you're using Google Chrome, that should be the symbol there as well, but this is everything that you should be seeing, and what we want to do is we want to take it out of this um zip folder because there are things that can read into it with Visual Studio Code, but I want to make this as user-friendly as I possibly can. So what we're going to do is we're going to make create a new folder, and I'm just going to call it massively, or you can call it um Portfolio Website, whatever you want to call it; I'm just going to do Portfolio Website, um and we are just going to I'm going to copy this in; I'm not going to cut it in just in case I make a mistake, so going to put all of those um all of those things in here, and now what we're going to do is we're going to go to Visual Studio Code right here, and you should be greeted with this um this right here, and we're just going to click open folder, and we're going to go to Portfolio Website and we're going to go select folder, and you're going to say say yes, I trust this one, and right over here is all of the documents that we were just looking at. Now the one that the only one really that we're going to be working in um we'll work a little bit in the images um because I'll show you how to add your own images; the really the only one we're going to be working in is this index. So again, it looks complicated um if you've never looked at HTML before, um it does look a little bit complicated, but HTML to me is one of the more easily understood languages um once you start kind of getting into it, which we're about to; we're going to walk through the entire process; it actually makes a lot of sense, and it is pretty simple. Um something that you're going to want is you're going to want something called a live, so like if I click right here and I click open with live server—you don't have it yet, I'm guessing, unless you've done this before—um it's going to open up this website, and this is what we're looking at right now. So it has a bunch of um gibberish or some language that I do not know, and so we can view this live um in just a second. I'm going to take myself off screen, but before I do that, um let's download or let's um search for that that live um I think it's called live share, live server, um let me see what this is called. Yeah, live server. So come right here; it's called this live server; there it is; yeah, that's the one. So this is our live server; you just need to click install; it takes like 5 seconds, and it should be completely installed. Um what this does is it just hosts a local website; it's not something that anybody can access, um but it connects to your code, and when we make updates, it'll make a lot; you can see it live; you can see those updates live. So I'll show you all that in a second. Just be sure to um be sure to download that or install that. Uh, with that being said, let's get out of this; let's go all let's go back right here. Uh, with that being said, I am going to take myself off screen so that you can see everything that I am seeing as well. Um it's been really great seeing you; have lots of different videos coming up; lots of new projects; um I just I really enjoyed this project series; I think I'm just going to do more of them; so uh all right, I'm gonna get myself off screen, so let's look at what we actually need to do. So I'm going to um so let me see. Okay, so we're already connected to the live um actually I got rid of it; whoops; let's pull this over and let's pull that, and we're going to open in live server. So if we look right over here, and I know this is going to be a little bit squished, and I'm sorry about that, um but if we look right over here, this

Says this is massively, so you you can change that. That's that's this right here, and you can say we're going to say Alex the analyst portfolio, and we'll get rid of this massively. I'm gonna hit control-save. You can also go up here and hit save, but I'm I'm going hit control-s. So I hit control-s, and just like that it updates on the website. Now again, this is just a local, so it's nothing that anybody can see, so don't worry. But what we're going to do is I'm going to walk you through the entire process of creating this, and then at the end I will show you how to host it on GitHub. Um, and it's honestly, it's it's a fairly easy process; it just takes a little bit of time to customize it all. So let's get into it. So we have this; um, you may not be able to see it. Let me actually pull this up, so it says massively by HTTP. We're going to customize that, customize that as well. Whoops, I don't want to do that every single time. I'm I'm going to try not to go full and go back and everything like that. So we're just going to say Alex the analyst portfolio, um, control-s, and right up here that changed it. You may not be able to see; yeah, don't ask me that again, thank you. Uh, right up here you probably can't see at the moment; we'll see that later. Um, but it it customizes this um tab, which is really cool. So let's go right down here now. This is where it says a free fully responsive HTML uh five template. We can customize that, and I highly encourage you do so. What you can do, and they actually included their Twitter handle right here, and you can do the same. If you look at this one right here, I included my Alex the analyst handle; that that goes to my YouTube channel, and you can do the exact same thing; includes your LinkedIn or your GitHub profile or whatever you want to include in there. Um, and so, you know, be aware that you can do that. So let's say, um, oops, I need to click back in here. So we're going to say, um, data analyst skilled in, and then again, don't write what I'm writing; um, you can, it's I'm just going to make it really simple, but you know this part is meant to be a little bit about you, um, as who you are. So I'm going to say data analyst skilled in SQL, Tableau, and Python, and then I'm just going to get rid of all of this. Yep, yep, yep, everything from here over, and control-s. And so super simple. Um, actually let me, where was that four, four, here it is. We don't need that; actually, we don't need anything from here over, probably here honestly; see what that looks like. Um, and yeah, and I can again, you can use any website right here that you want, and you can customize what it looks like. So I'm going to say Alex the analyst, um, and then whatever URL you want to include in there, that's what you need to put. So now if I save, oops, if I hit control-s, so now it says Alex the analyst, um, so pretty easy. Now we're going to go down, and you can use this however you want to use it. I would, you can even make this, um, you can make this like one of your one of your READMEs, like a YOU, and put the link for that. I decided to include, um, again on this one, I decided to include the project that I thought that we've done that was like the most impressive, or the I don't know, the coolest one. I don't know if you consider data cleaning and SQL cool, but um, I do; I think it's cool, so I included that one as my very first one. So that's what we're going to do, um, right here. So we're going to go down, and it's going to say, let's say it says this is massively; that's not it. Uh, cool. So let's see what, oh okay, I know what that is. We'll come back to this up here, um, in just a little bit. I'm going to go full screen; I'll show you what this is, and then we'll come back to it. But if we go right down here, this is our what they're calling a featured post, and then the ones below this are posts. So in our featured post, um, I'm going to get rid of the date; I don't want them to know that I just created it like, um, I don't know. Oops, I keep doing uh control-a, selecting everything. Whoops. So we're going to say, um, data cleaning in SQL, and we'll get rid of this, and control-s again. I'm just updating it a lot so that you see what I'm doing and where it's going, and we're going to get rid of basically all of this and go back, and we're just going to say in this project we clean data in, we clean, let's do we clean housing data in SQL Server, and control-s. So super easy again. Uh, give a little bit more description; I did in my other one, um, and you have the you have you can see that website, so go check it out. And then we'll have an image, and I'm going to show you, um, at the end we're going to go back and redo all the images, but I'm not going to do that at this very moment. Um, so what, now you can have this full story. I chose to do view project, and I hit control-s; it says view project. I think that just looks better, especially if you're displaying a project; I think it is nice. Uh, now we go into all the individual posts. Um, actually, no wait, what I want, I want to show you really quick is how you actually link it to this. So let's go right over here; this is our co, uh, that's our Co. One. Here's a data cleaning project. So all you have to do is take, um, take this website, so that's the URL, and you're going to put it right here. Now there's three different places this href is, places are places where you can put a link to a website, um, and on here it references this right here, so you can they can click on this data cleaning and SQL; they can click on the image, um, as because you know this href is right next to this image; they can also click on the view project button. So you can put it in all three, um, and you'll just go like this; you'll you'll stick the URL right where that um hashtag or pound sign is, and then we're going to save that. Oops, oh, I I this is embarrassing; I am not a website, I am not a web developer, as you can see. Um, but then if I go in here and I right-click and I say open link, it is going to take me to that project. So super super simple, and we're going to do basically that for all of these. Um, I'm only going to show you three, and then you can do the rest, but I want to show you how to also do the, um, put the Tableau; it's the exact same thing, but you know it's different, so wanted to show it to you. So the next one that we're going to do is go down to posts, and again I'm going to get rid of this date. You can keep that in there if you want; excuse me, and that's totally fine; just update the date. Um, this is that said mag again; I think this might be like some language that I just don't know about. Um, the next one is data exploration in SQL, and I'm going to get rid of this, and we'll save that. Perfect. And we'll do view project. Cool. And yeah, so now we need to, um, customize this summary, and so I'm just going to say something really simple, um, data exploration of COVID-19 data set in SQL Server. There we go. Let's save that. We have view project. Now let's go get our project. So this is the data exploration; we're going to take this, we're going to copy it, and we're going to put it right in here and right in here as well. And if you want to, you can also include it right up here, so we have it in all three places. Uh, again, once you click on these, they will come up. Let's go to the next one. We're going to get rid of this; this one is going to be our Tableau projects. So actually let me just copy that while we're here. This is going to be our Tableau projects. So if you have one specific project that you want to include, what you need to do is actually go in here, click view, grab that URL. What I am doing is I am just sharing my Tableau Public page, so if you have tons of projects in here and, um, you want to display all of them, then or you want them to be able to see all of them and go and pick and see and choose what they want to look at, then just choose this URL that we're choosing right here. So, um, in here, on in the, um, HTML, we're going to put, I'm going to put tab projects, and let's go like this, and then we will get rid of uh that hashtag, pound sign, whatever you want to call it, and we'll hit control-s, and oh, we got to do the, um, this as well. This is my, this is going to be a terrible, don't use this; this is my Tableau; this holds, I'm just, this is bad; this holds all of my Tableau dashboards; don't please don't do this. Um, I am doing this because I don't want to take forever in a video to make it perfect. Um, and then you know you're going to do the exact same thing. So in this one right here, I included four, so I'm going to keep four. Um, let me do the, no, I'm just going to do these three; I'm not gonna take up more of our time. Um, so we did those; I'm just going to keep these three in for visual purposes, but once you get down here, um, you know what we're going to do is delete some of this right. So we this is our data exploration, and where's our Tableau? This is our Tableau right here, so Tableau projects; they're separated by these articles. So what we're going to do is go around right here, and we're going to go down, down, down, down to right here. This is going to get rid of all these other articles or all these other what they're calling, um, posts. So we're going to get rid of those, and we're going to hit save, and now as you can see we have our header, we have our first project, and we have our second and our third. I would include those other projects that we've done in here so that it looks good. This is this footer right here; we don't need that because we don't have any, um, anything else in there, so we're going to get rid of that as well, and now we just have this information. Now I don't have anything where they can do the name, email, message, or you can keep that in there if you'd like, um, but I am going to get rid of this. So we're going to go right here; that's the section, so don't delete the section; we want that. I'm going to delete this footer section, as what they're calling it, and now we have this address, phone, email, social. Um, and I'm going to get to the social in just a second; it's again super easy, but for the address I just put location; I don't want to give somebody my address or put it on a website anywhere; um, it's not something I want to do. So what we're going to do is just put, I'm going to put Dallas and Texas, and we can keep it like that, and we'll hit oops, we'll hit save, and it'll have Dallas, Texas. Um, hate the look of the zeros, 678nz, so we're we're going to do that phone number 23567890, and then email, and we'll put Alex the analyst95@gmail.com. If you have issues with this, um, you can email me, but I'll try I will try to respond to all your emails; I get a lot, um, so I will do my best, but that is my actual email if you are curious. Now, um, now that we have this, we also have these, the social media. Now I want to display my LinkedIn, and I also want to display my GitHub. So what I'm going to do right here is I'm going to go over here and do LinkedIn. Perfect. Let's go to this. So I'm going to take my LinkedIn URL, and I am going to get rid of these first two because I'm only going to include two, and for this one I'm going to do uh LinkedIn, oops, LinkedIn, and then for right here I'm going to replace that with LinkedIn, and what you're going to do is put this link right here, and then we're going to go get get the GitHub. So let's do GitHub. Oh, who is this sign up? What is going on? Um, I don't there, let's just go back here; I that was some I was like viewing a while back or something. Um, so we're going to take the GitHub, and we're going to put that right here. So it already has it as, um, the GitHub; is this supposed to be lowercase? I think it is. Let me see if this is lowercased as well; yeah. Um, so do it like that, do it lowercased. Um, I forgot that that was how they did it. Um, and oh, that's the label; that doesn't matter as much, but this right here is the class is actually the important part, because then when we go back here, there is no LinkedIn image, but when we save it, oops, when we save it, it has the LinkedIn image because it's already a class that was created in this HTML, um, template. So we have that. Um, and let me bring this full screen really quick because there are a few things that we couldn't see in that that screen. These right here are things that we could not see before, um, and these as well. So what we can do is we're going to go down here; we're just going to copy these social; we're going to replace them right here, so they can have those, and then we're going to get rid of these two right here, and this says this is massively, um, and we're going to change that as well. Let's make this full screen for the first time; feels good. Um, I hate doing split screen, but I do it for you guys. Um, so this is massively, and we're just going to put, we're just going to get rid of these two; this is, um, it's called The Navigator, the the different tabs; we're going to get rid of those two tabs, and then for this I'm just going to call it projects, and I'll once I once we go back and update all this, then you will, um, you'll see those changes. So let's see. So we made those changes; here's our social or the social medias, uh, Social Media stuff; we're going to go and copy, copy these two, and we're going to replace all of these with this, um, and let's save that, and let's go back. So now as you can see those two are gone; this says projects; there's only two right here, and if you click on it, it's going to go to my LinkedIn or your LinkedIn when you do it, um, and this will take you to the GitHub. So it is all working as intended; this is great. Um, when you scroll down and it says massively, we can change that as well, and we should; let's do that really quick. Um, we'll just say Alex the analyst, and we'll update that, and there we go. So in a nutshell, this is the a lot of it, um, we need images, and I don't think I set this up for this video, so I'm going to I'm going to like cut myself off for like 2 seconds, go pull those images in, um, because it could take like a few minutes; I don't want to waste your time, and then I'll come back. So I'll see you in two seconds. All right, so I just pulled over the images that we are going to use. Let's go to the downloads; um, they're right here; they're the housing, Tableau, and Co. If I open up this Co one, this is what the image looks like; this is what we're going to use for that COVID project. So I'm going to copy these; I'm going to go into the port website, um, that we just have; I'm going to go to images, and I'm going to insert these in here. So now that we have those images in here, let's go back and let's see what we got. So we just put these images in this; um, you'll have this folder right here, and you can open it up, and you can see all of these that we have. So all we're going to do is go and replace the images, these these, you know, temporary images that they had for us, and we should be gold, and then we're going to actually upload it to to GitHub and then create our website for free. So let's go right down here; this is our very first, uh, one; this is our data cleaning in SQL; this is with the housing data. So this image right over here, it says images p1.jpeg; so jpeg, I don't know why I said it like that. So this is the housing, so what we're going to do right here is do housing, and it'll autocomplete for us, um, so that housing should be in there. Now next one is the data exploration in SQL; that was with the co, so we're going to get rid of this; we're going to say Co, um, because that is the image that I have right over here, and then the last one is excuse me, Tableau. So let's go right over here; let's do TBL, low; let's get rid, oh, I got to save that, uh, control-s, perfect. And now let's look at it. There you go, there you go, go. Oh, this one still says full story; go change that. Um, I'm going to go change it; just doesn't feel right. Uh, view project; oh, that's not how you spell it. Okay, control-s, perfect. Okay, so now this looks a lot better, um, and when we host it, um, through GitHub Pages or github.io, this is going to be what it looks like; I mean it is, and you can add a lot more to it; you can take away from it; you can add as many projects as you want; you can keep adding; you can copy those articles or those posts, and you can just keep adding them. Um, so this is kind of what it's going to look like, and it was not that hard; I don't think I hope this was not too difficult; I really don't think it is. Um, it's really just using a template and kind of understanding a little basics of HTML, so, um, we are going to take this, and we we have this saved already; we have this all saved. What we are going to do now is upload this to GitHub. So let's go right over here; let's go to here, and let's go to repositories, and how do where where's the new one? Oh, I need to sign in. Okay, I'm going to get rid of this part so you can't see it. So we are going to say a new repository; we're going to call it Alex the analyst2.github.io. So we're going to write it just like that; you know, if your name's, um, Alex Jimmy, I don't know why I said Jimmy, Alex Jimmy, Alex jimmy.github.io; you can always go back after the fact and change this, so it's not a big deal whether you change it or not, and we're going to create this repository; we're going to say upload an existing file, and instead of choosing them, what we're going to do is just go right over here, go to this, and we're just going to copy this in or not copy it in but drag it in. Okay, so we're going to take this, drag it in right here, and it can take a it'll take a little bit; has a 75, but it shouldn't take that long, and let's just wait for it. I'm taking a sip of water; I apologize, but it is literally uploading just everything that we had in there, so all the updates and all the changes and all the stuff that we, um, had, and it looks like it's done. So let's just write initial commit; commit changes; it is processing it. All right, and it should be done very very soon, as long as I have a good internet connection; we shall see; stick with me; it's taking its time. Um, while while it's loading, let's go over to oh, oh, there it is; so perfect. So here's everything that we have; has this README that it generated; let's over to settings, and

What's going on, everybody? Welcome back to another video. Today, I'm going to help you create a data analyst resume.

[Music]

Now, when I say data analyst resume, it's not that much different than a regular resume, except that it's going to be catered for a data analyst job. In just a second, we're going to take a look on my screen at a sample resume. I'll have the template in the description so you can just go and download it and fill in your information. But it's a fantastic starting place to actually creating your resume. When we're looking at this resume, we'll take a look at each section, kind of dissect each part of it, and then at the very end, I'll give some extra tips on what you should include and how to actually write your resume as well. So, without further ado, let's jump onto my screen, take a look at the resume, and see how you can create your own data analyst resume.

So here's our sample resume. I'm just going to walk through the entire thing super quick, and then we'll break down each section individually. I'll give my thoughts and some tips on each section. And remember, you can download this exact thing in the description below. I'll have a link; I'll probably put it on my GitHub or somewhere else, but it'll be free to download, uh, so you can go ahead and do that. But let's zoom in just a little bit. So at the very top, we have our header; we have some just basic uh contact information; then we have skills; then we have projects; and notice the projects are up here at the top, and we'll get to that later about the order of where you should be putting your things; then we have work experience; and then we have education. So really quickly, I'm going to zoom out, and I hope you can still see it. The order is actually quite important. Now, there is one piece that is not in here right now, and that is a summary section. I don't have a summary section on my real resume; I just—I don't think it's useful or helpful. I don't have one. You can include one, and it would be right up here at the very top. Now, why do we have the skills and projects at the top? Well, it's because that most people who are trying to break into a data analytics don't have any experience in data analytics. If I am reading this resume as a hiring manager and the first thing that I look up here and I see is experience, and it's not analyst, it's a teacher or a nurse or something, I'm going to be like, "This person doesn't have any experience; I don't want to hire them." The first thing that you want to have in your resume is something that is good for the hiring manager to see. The first several things you should put—all your best stuff at the top. That's my uh—what I believe. So I think that these skills are really strong, a lot of great skills, and then these projects are all really good projects. Now, this is just a sample; these aren't all real projects, um, or they are real real projects; they're just not, you know, ones that I built myself. It's just a sample. So, uh, then right here we have our work experience. Now, if you're, like I said, a nurse or a teacher or a lawyer or something that's not relevant to data analytics, you want that at the bottom, um, and then you're going to want to tie in uh some things in these descriptions, and then the education at the bottom. My education was terrible. Okay, I had a bachelor's in recreational therapy, which had nothing to do with data analytics. So for a tech job, has—was not good. I always had mine at the bottom.

So let's start at the very top and walk through each section. So at the very top, you want to have maybe a title, but for sure your full name. You definitely want to include your phone number if you're okay with them calling you, but definitely an email. For sure, include things like a LinkedIn profile or a GitHub profile. You can also put your portfolio; in fact, I highly recommend putting your portfolio because it just looks good, or if they check it out, that's a really good thing. And then your location, 'cause sometimes your job is going to be location based, whether you're in Dallas or another Metropolitan City. It's just nice—nice to have that on there. This should be the simplest one to fill out, unless you haven't built out something like a portfolio; you just don't include it, um, but this one should be the simplest one, right? You're just putting contact information, maybe a link to a website.

Next, we have the skill section, and this one on my own personal resume, I have at the very top. I typically recommend anyone who does not have experience, who is trying to break into data analytics, to put this at the top as well and have these skills and know these skills; that's important. Um, but when the hiring manager first initially sees this, there's just going to be a mental check, "Okay, they have the skills that we're looking for; let's move on to the rest of the resume," um, but you want as many mental checks for what they're looking for at the beginning, just going to—I'm going to keep repeating that—um, this is how I personally write my skills. So I write something like SQL, and then I'll say SQL Server, MySQL, PostgreSQL. Now, I have used all these different types of SQL in my actual job. If you don't—you haven't done—done that, and you're just starting out, maybe you put something like, um, you know, subqueries, store procedures, joins—whatever the actual things within SQL. I don't really think—I don't recommend that as much because typically people know what SQL is like; if they use SQL, they know what SQL is, so they're just going to expect that you know those things. Now, for something like Python, it's different because there are packages—something—are there are packages and libraries within them, so you can specify, "I have worked with pandas in my actual job," and I look for people who know pandas as well because, you know, we use it. So actually specifying these packages or libraries is really helpful. So this is how I would put these things on a resume. Now, this is another resume; this is our sample two. I'm going to maybe include this one down below, although I don't like this format as much, but if you like it, you can. But here's another way that you can um show these skills—just a different way to do it. I want to show you both ways. Um, we have like Python and the libraries underneath it. I've even seen it to where people will write out almost like—let me go down here—they'll write out like a narrative; um, they'll do Python, and then they'll have like a colon, and then they'll say, "Used to—manipulate data in pandas..." and they've write it out. You can do that as well. Again, I'd like bullet points because it's to the point; it's exactly what you need. Let's get rid of this one real quick. So this is the one uh that I like. So that's the skill section. Let's move down to the projects. Now, the project section is almost primarily for people who are just starting out. Once you get experience, typically you maybe have one project on there or no projects at all, but the project section is used as kind of um—in lieu of actual experience, right? I've always said that you need to build projects, not just for your resume, but also for the interviews. So, so then when you get into an interview, you can point to these projects and say, "Yes, I've used SQL; I did it in this project," and they may have seen it, and you can walk them through how you actually used it. It gives you more credibility than just saying, you know, how to use SQL. So within the project section, we're going to have a project like this one says, "Data science job market exploratory data analysis." So this is a personal project, and then within it, they did some really great stuff. Here's usually what I recommend, and this is in here, which is you specify what you did. You say, "I used Python and what did you do to analyze this and gain insights in the job market?" Then you walk through some of the things that you actually did—things like regex techniques, you used pandas, matplotlib, you built a wordcloud. These are keywords that somebody will look for, and they even highlighted them, which I personally like and do as myself. They highlighted these things so that the viewer or the um hiring manager is actually seeing them, making sure that they're bold so that they are catching their eye. So I personally do this, and I recommend this. That's all it needs to be; it just needs to be, "I built a Tableau dashboard doing this from this data set; I cleaned it in SQL," and you show those skills. Something that's important in both the skill section and the project section is using and highlighting your skills as much as possible, especially if you don't have any experience. If you've never had a job before, once you have a job and you come down to like the work experience, then it kind of speaks for you, but if you don't, you want the projects and the skills to speak towards your skills and credibility. So we have this right here. Now, one thing that's not in here that I actually do recommend is a hyperlink, maybe right here or actually this being a hyperlink to the project because they might read this and be like, "I—we work with, you know, data science job market data; I don't know," and then they'll click on this link, and they can see your work. That is the one thing that I would change—change in this, other than that, this is exactly how I would have it—very, very, very similar to my own, um, and a lot of this that I did, I actually took from other resumes and formatted how I prefer and like it, um, so again, some of this is personal preference, and you can change it however you want; that's just how I like it. So that is the project section. Now we're going to go down to the work experience section. Now, this person does have a little bit of analyst uh experience, so, you know, if you don't, that's okay, but you put your previous experience. Now, here's what I recommend: If you've been a teacher for 15 years, you've been a nurse for 10 years, you've had 10 different jobs, don't put all your experience on here, um, maybe put your last two jobs, going back maybe three years. I don't recommend you filling it up because it's not going to be super relevant, unless you're applying for a health care data analyst position and you have a nursing degree, then it's relevant, and that experience is super helpful because it's domain experience, right? Then you may go back five years—just, you know, use your discretion. But what you need to include, of course, your title, where you worked, your location, and the times—that's standard for almost any resume. But within here, uh, what you really want to do is highlight again the skills, if you can. If you can't, that'll change, but in here he says, "Implemented a new reporting using Excel pivot and VBA, which reduced processing time by 50%." These types of um quantitative information—"I reduced time; I—I saved the company money; I—I did something quantitative"—putting that in here is always helpful—always highly recommended, although it can be tough to measure these things, right? Typically what I recommend, especially if you're first starting out, is to highlight skills. If you're a teacher, you've probably used Excel, and you've probably used Excel for closer to data analytics than you think, just in a teacher way and not a data analytics way, but you can reword these things and make them sound good. If you are a—a nurse, like I was saying, you've used—used Excel, you've used a health information system, you've used uh some type of database—talk to that—include that in here, um, and it can be hard to write these out, and I'm going to show you away in just a little bit about how you can write these out and think about these things or have a way to help you write them or give you ideas. We'll get to that in a second.

Lastly, we have the education piece. This is again really simple: at the very bottom, education, what your degree was, where you went, um, and if you have, you know, some helpful things to include, you can do that, and then when you actually went. Now, you can include other things in here as well, like boot camps, if you went to a boot camp, or you could also include things like a GPA, although I don't personally recommend it. GPA has never been anything that I've ever cared about or I've seen anyone care about ever, um, so you don't normally have to include it. One other thing that you can include at the very bottom is something like certifications. Uh, I personally don't put a lot of stock in certifications unless it is one that I have recommended in previous videos, like the Tableau certification or Tableau Desktop certification. If you're applying to a job that uses Tableau, that actually could be really good, so definitely include that, but ones on Udemy, ones on Coursera, or like my Alex the Analyst boot camp that I have on my channel, I wouldn't really include that in your resume; it's mostly for learning. If you get something like the Tableau one or the AWS uh Cloud one or the um Azure Cloud one, those are all actual certifications that can help you and give you credibility towards a certain skill.

Now, really quickly, let's just take a glance at the other resume. This is Resume 2. So we have the education at the top; doesn't have to be at the top unless it's relevant, which you could put at the top. We have a skill section; they—again, this is the projects—same projects—and then work experience. This is just a little bit different um order, so you can do it like this as well—in different ways you can write the skills, and you can also include a summary section as well. So that's the meat and potatoes of how I would create—create a data analyst resume. Now, writing it is actually a different beast, right? You have to actually write it out, get something on the resume, and then apply using that resume, but it can be hard to come up with these ideas. So uh, I just want to show you something that a lot of people have been using; I personally haven't written a resume in a little while, so I don't use it for my own resume or haven't used it, but I will, um, and that's using ChatGPT or some variation, whether it's on Bing or, you know, you get some different version or some new product that's out there at the moment. I'm just going to show you how to do it in ChatGPT; some of the things that you can prompt it to do, and that'll be it. I'm just going to show you kind of some ideas that it can generate for you to help you write these things.

All right, so here in my screen, we're on ChatGPT. If you haven't used it, I'll leave a link in the description. I also have a whole video on how to use ChatGPT for a data analysis, um, so I like ChatGPT. Now, I've already written out these questions because I don't want to wait for the responses, but here's what I asked it to do, and you can do some variation of this whether you're a nurse or a lawyer or a teach—teacher or whatever. I said, "I'm a math high school teacher trying to become a data analyst; how can I use my experience on my resume to help me get a job?" This is just to help provoke some ideas, and it says, you know, you most likely have some skills; emphasize your quantitative skills; so those are some of the things you can focus on; showcase your ability to communicate complex concepts, which is really important in data analytics; being able to present information, which teachers have; highlight your experience with technology; hopefully you're using some type of uh, you know, database for students or, you know, Excel or something like that; you can highlight that; and showcase your ability to solve problems. Now, the next thing that I asked it was, "I built a COVID Tableau dashboard using Tableau; how can I add this to my resume?" And then it's going to tell you exactly how you can do that. It's going to say, "Include the link to your dashboard," which I also recommend; "provide a brief description; highlight your data visualization skills; include screenshots or images," which that's what I would be putting in the project itself, not on your resume; "then provide context for the data"—all really good stuff—really great.

We have this U github.io, and if we go right down here to GitHub Pages—pages settings now has its own dedicated tab. Let's check it out here. So it is um—it's currently disabled, but we're going to say want it to do pull from the main um—I think it's the doc; we'll see. I'm going to save this. Your site is ready to be published. Let's open this up. Okay, site not found. Maybe it's from the root. Save. Um, your site is having a build a problem. Let me see if I can actually change the name. I already have an AlexAnalyst, but I'm gonna see—it's already taken. Um, I'm just going to try this one one more time. Oh, and now it's working. Uh, I have no idea why it uh didn't work before, but this is fantastic. It was giving me all this—I was—maybe I was just reading too much into that. I had—I had never tried to create another um .io or or GitHub pages on this. So anyways, thanks for sticking with me through all that um stuff. So now we have our actual website. Um, it doesn't look the same up here because of that thing that we were just looking at; it should just be this part right here, but um this is an actual website now. It's being hosted through GitHub, and it's completely free. If you want to pay, you can hide this from your GitHub—your repository has to be public—something I didn't mention: When you're doing this, your repository has to be public. Um, if I change the visibility to private, um you will not be able to see it anymore. You'll have to then pay. If you want to make this repository private, you have to then pay—I think it's like $4 a month or something like that. So worth looking into, um, if you don't want to display that on your GitHub—worth looking into. But this is our final product. I mean, it looks pretty fantastic, and you can use any of these templates, right? There are lots of different templates that are fantastic. I mean, they look amazing; they look professional. Um, it's really up to your style. Like this one looks kind of cool—a little bit um edgy for—for my taste—but uh this one looks really good, too. Might—might be able to add some more narrative to that one. So again, go through it; make your—make a good choice in it, and then update it how we updated it. Uh, I will include the um—let's see—I will include everything that's in here, and I'll keep this on my—on this GitHub that you can go in there, and if you want to download these images, you can download the images that I—I used, um, or you can go find your own—just um, you know, look for—try to get like HD images on Google. Just type in Google Images and search for whatever image you want to search; try to get an HD image. With that being said, that is the entire project. I—I—I—I hope this didn't go too long. Um, this may have gone—you know, this may have gone like 30, 45 minutes, but in the end of it—at the—at the end, which is where we are now, we have an entire website; it was completely free, and I hope that you can host the projects, and you can create—create more projects. I will be coming out with more projects myself that hopefully will be interesting to you in the future. So, with that being said, thank you guys for joining me. For you who stuck it out to the very end, you are fantastic. You know, send me a—post your website on LinkedIn and tag me in it because I love seeing um you guys do these projects and this stuff, so I'm super excited to see all of these um that you guys tag me on—on LinkedIn and whatnot. So, with that being said, this is it. I hope you learned something; I hope that it worked for you, and I appreciate you watching. Be sure to like and subscribe below, and I will see you in the next video. [Music] Goodbye.

Now, the last thing is kind of what I'm trying to get at as a whole: it can help you write things. So I'm going to say, write a two—I said write a two—write two sentences highlighting my COVID Tableau dashboard to add to my resume. And it's going to say, "Developed a COVID Tableau dashboard to visualize pandemic trends using real-time data sources, demonstrating strong data visualization and analysis skills." So this can help you generate those descriptions in your work experience; it can help you generate the descriptions in your projects. And this can be really helpful to just generate some ideas, cuz I personally really struggle with, like, highlighting my skills and descriptions within those things. This can be a way to kind of help you do that. So don't, you know, just copy and paste, but let it prompt you; let it give you ideas.

Now, the last thing that I want to mention is just your overall resume as a whole. The template that I use, the template that I recommend, is very, very friendly to these automated systems that check your resume. If you did not know, most companies, especially big companies, use these automated systems that scan your resume to see if it has what they're looking for. And then that resume, if it gets through that system, gets passed on to a recruiter or hiring manager. Typically, most companies don't go straight to the hiring manager. So you need a resume that can pass through those initial systems and pass those tests. The resumes that I've shown you today will do that; they have bullet points, they have the keywords, they have everything you need. That's why I recommend—or partially why I recommend—this type of resume. Other ones that have images and different fonts and different stylings can cause issues with these automated systems, where it just doesn't read it properly, or, you know, it doesn't read the right words that you want it to read. So just know that these types of resumes have different uses, right? You're not just handing it off to somebody to where they can read it, and it needs to be visually stimulating. Really what you need is you needed to get through those initial systems, which these resumes—uh, if you write them well, you have good, you know, skills and the right things on your resume—they will pass through that first layer to get to those hiring managers. So again, be sure to download those; those are completely free. I just—I highly recommend using them; I think they're really good. So be sure to download those, use those, just put in your own information; be sure to build out your own projects. Don't just keep the ones that are on there, because you'll need to be able to speak to them. Sometimes recruiters or hiring managers are going to ask you about them—how you built it, what you did—and you can also point to those projects in your actual interview.

So I hope that this was helpful. I hope that your resume is ready to go. I hope that you're ready to start applying for those data analyst jobs. Thank you guys so much for watching; I really appreciate it. If you like this video, be sure to like and subscribe below, and I'll see you in the next [Music] video.

What's going on, everybody? My name is Alex Freeberg, and today we're going to be walking through my top three tips on how to use LinkedIn to land a job. LinkedIn is a fantastic place to look for a job; it's its own little ecosystem where career-driven people can connect and talk with one another and help each other find jobs. I personally have landed jobs through LinkedIn, and so I know how effective it can be. Let's jump over to my screen, and I'm going to show you my top three strategies that I have found to be the most successful to actually finding a job. So I'm logged into my completely anonymous account here, and I'm going to show you the very first tip, which is you shouldn't be just applying to a position; you should be actually reaching out to the recruiter. And I'm going to show you exactly how to do that. So the first thing that we have to do is actually find a job that we want to apply to. So let's go to the job section right over here, and let's search for data analyst, and let's do that in—let's do Chicago, because why not? Uh, so it's going to search for data analyst positions in Chicago. We have one right here. Let's see what it looks like, cuz, you know, I don't want to apply to jobs that I'm not extremely qualified for. So this is a job that I want to apply for, and before I actually go and apply to the job, I want to see if I can reach out to a recruiter and talk to them beforehand. So let me show you how to do that. So what we're going to do is actually click on the company right here; it's going to take us to basically their LinkedIn profile page for their entire company, and we're going to scroll down; we're going to go over to people, and then we're going to search for recruiter. So if we scroll down all the way to the bottom, we can see that there are recruiters that actually work in-house for this company. And so now would be a time where I actually reach out to some of these recruiters and I say, "Hey, I see a job that I really like; I think I'm really qualified for, and I would love to talk more about it with you." You can ask them things about the job to make sure that it is a good fit for you, and then I highly recommend you asking them what they think is the best way to apply for this job to make sure that your resume gets noticed and you get an interview. Since they are a recruiter who works at this company, they may be the—the one who's actually going to be looking at these resumes, and so they may give you a tip on the best way to actually apply. They may also just ask you to send them your resume directly that they can look at it, or maybe later on down the line this actually is a person who is reviewing resumes, and so if they come across your resume they may be able to put a face to the name, and that may give you bonus points. I'm going to leave a template script in the description in case you don't know exactly what you want to say to this recruiter, and it'll give you just a baseline of some of the things that you might want to say.

Number two is to actually ask for a referral. Now, if you don't know what a referral is, it is—is where somebody who already works at the company can refer you to a specific job, and then might get you a little bit higher on the list for interviews. So I highly recommend reaching out to somebody who already works at that company and ask if they're willing to be a referral for you. I get people reaching out to me all the time asking to be a referral for them for my company, and nine times out of 10 I say yes. I always ask to see their resume first, just to make sure that their resume aligns with the position at least a little bit, but there's basically no harm in me being a referral for somebody; in fact, I may actually get a bonus if that person ends up getting hired. And so for the most part, there's almost no risk for the employee to actually being a referral, and so a lot of times they will say yes. Now let me show you how to do that, and it is very similar to finding a recruiter. So we're going to stay on this people section, but instead of searching for a recruiter, we're going to search for a job title that is similar to yours. So let's actually see if they do already have any data analysts, and if they do, that is the person that we're going to reach out to, because that is the person we'll probably have the best connection with. So it looks like we have six employees, and let's scroll down, and so it looks like all these people have data-related jobs, and so I would reach out to these people and say, "I saw an open data analyst position at your company; I would love to know more about your company as a whole," and then you can talk to them a little bit, and then in the end your goal is to ask them for a referral, and if that happens, that is fantastic, and then you can go ahead and apply for the job and mark them as a referral for you.

Now my third tip on how to get a job through LinkedIn is to actually have recruiters reach out to you. So let me show you how to do that. The first thing we're going to do is actually go over to my profile here, and we'll click view profile. Now there's a few things that we want to make sure that we have on here so that recruiters can reach out to us. The first thing that I want to do is to actually come to this section right here, which is show recruiters you're open to work, and when I click on this, I can actually choose some job titles and some locations where I actually want to apply and have recruiters reach out to me. And so right now I have data analyst, I have in the DFW area, which is where I live. I can also add titles like business analyst, um, and then maybe junior data analyst, entry-level data analyst, or things like that that could potentially have recruiters reach out to me for positions that I'm interested in. And then you can say that you're immediately and actively applying, and you can also say that you're only looking for full-time positions or contract positions, and then you can actually add this to your profile, and I only want recruiters to see that because I do currently have a job at McDonald's, and so I don't want McDonald's firing me because I'm looking for employment elsewhere. So let's save that, and it looks like it was updated, and so now when recruiters are searching for candidates for a specific position, you will be on that list so that they can find you and reach out to you. Something else I should mention is on your profile page, I would try to have some type of professional photo so that you look really good. I would also try to include data analyst somewhere in your title. If you already have a data analyst job and you're looking for another one, you can just have your previous company, but if you're looking for a data analyst job, you can always put seeking data analyst position or something like that. Another thing I think is really important is having really good descriptions for your previous work. I don't currently have this, but I would go a little bit into the work that I actually do; make sure that the experience matches kind of what you're looking for, if you do have previous experience; if not, that's totally fine. The next section on your profile page that I would recommend looking at and updating is your skill section, and so you want to go in there and make sure you have all of your relevant, really data analyst heavy skills on there, specifically hard skills, because soft skills aren't going to translate too much into this section. I would definitely stick to things like SQL, Python, Tableau, Excel—things that data analysts are going to use—because this is where they're going to actually look and see if you have the skills that they are looking for for that position. When I was applying to jobs, in only applying to job postings and not using any of these strategies, my success rate was 0.04%, which means out of 1,000 applications that I filled out and sent my resume to, I only heard back from four of them to actually get an interview. But with these strategies, I was able to get that up to 10%, and at my best I was able to get that up to 15%, but that's because I was applying to a lot less positions, and I was targeting jobs that I really wanted to work for, and so I put in more effort in order to contact people and work with recruiters in order to get that job. I genuinely hope that these strategies can be helpful for you, especially if you're trying to apply for jobs right now. Thank you guys so much for watching; I really appreciate it. If you liked this video and got anything out of it at all, be sure to like and subscribe below, and I'll see you in the next video.

Hello everybody. Congratulations! If you are watching this, that means that you completed the data analyst boot camp. If you haven't, don't keep watching; this is only for people who have completed the data analyst boot camp playlist on my YouTube channel. Woo! All right. Now that we filtered those people out, I'm going to show you how you can download your certificate and your certification. Now that you've completed the data analyst boot camp, I will leave a link in the description, but let's go on to my screen; I'm going to show you how to actually access this and download your certification. All right guys, don't go around telling people this or sharing this, uh, but this is our data analytics boot camp on the Alex the analyst GitHub right up here. I will have this link in the description. What you can go ahead and do is you can come right here; you can download this; you'll just right-click or click download, and you just do something like save image as, um, or you can come to this one; this is the one that I think is the—the real money maker here; this is the certificate of completion for the data analytics boot camp. I have my—not signature—but my name, as well as my position, with a blank space right here to fill in your name. Feel free to put this on LinkedIn or Twitter or Instagram and tag me in that because I would love to just say congratulations, because honestly, it's a lot—lot of work to go through all those videos and learn all of those skills. So congratulations! I hope that you learned something along this journey—a new skill, a new thought, a new idea—and I'm proud of you; I'm proud of you for putting in the work. It's not easy, but you did it, and I hope that you came out on the other side better for it. So congrats! I'll see you in the next [Music] video.