Transcript

Use with ChatGPT / Claude Auto-scroll A

1. Boot Camp Introduction and Roadmap

Introduction to the 2026 data analyst boot camp, covering new content added since the original version and an overview of Analyst Builder. The speaker outlines the full path to becoming a data analyst.

0:00 - 0:46
Hello everybody and welcome to the 2026 data analyst boot camp.Back in 2024, I released the first ever data analyst boot camp on YouTube.It was about 24 or 25 hours worth of content that I've been creating for the past four, five, or even 6 years.Believe it or not, since then, I've been creating even more content.And so, I'm adding a lot of those new things into this boot camp to make it even longer and cover even more things.In the original boot camp, we covered a ton of stuff already.And I'm going to read it because it's too many things.Uh we covered my SQL, Excel, Tableau, PowerBI, Python, Pandas, Python projects, building a portfolio website, creating a resume, practicing for technical interviews, Azure, AWS, and then how to use LinkedIn to land a job.That is a ton of stuff.And those are just videos I've been making for the past several years, and I put it into one really long video.
In the boot camp that you're watching right now, we are adding a ton of new content.The first thing being a data fundamentals playlist.These videos cover things like what is data, what are data types, what is data cleaning.A lot of things that data analysts need to know.We're also going to be adding in our entire Git and GitHub series because Git and GitHub are just really useful to know and they're being used more and more especially with AI becoming so popular.I'm also adding in the R for data analyst series which is basically just R programming for data analysts.And so if you like R, you are in luck.I am adding it to this boot camp.Lastly, we're going to be adding in data bicks.And data bicks is a phenomenal data platform to know how to use.It's super popular and a lot of people say you either choose data bricks or snowflake and I'm going to create a snowflake series in the future, but we're adding in the data bricks series and so that's going to
cover how to use data bricks and how to create ETL pipelines within data bricks as well.So there's a ton of new things that we're adding to this boot camp and it all is here just to help you learn the skills that you need in order to become a data analyst.If you did not know, I also have a paid platform called Analyst Builder.Analyst Builder is where I have all of my full courses.It is my paid platform and so all the things that we're covering within this boot camp, I have full courses that dive even more in depth and have more advanced projects within Analyst Builder.We also have a part of the platform where you can practice for interviews.So you can practice SQL and Python and R all within the platform.And there's also general technical interview questions.If you don't know how to answer some of these questions, we have an entire part of the platform where you can practice and get better at answering those questions.
And if you are looking for projects to build, we have a whole section on the platform where you can find projects and you can build them out and share them with others.Analyst Builder is my paid platform.YouTube is where I have all of my free content.So, they're two separate things.If you just want to stick to the free content, this boot camp is the best boot camp you are going to find on YouTube.Hands down.I promise.But if you're wanting to go even more in depth and you're willing to spend a little bit of money, Analyst Builder is where I would go.I truly hope that you learn a ton from this boot camp.I have spent years creating the content to put into this boot camp and I hope that you really enjoy it.I have no idea how long this boot camp is going to be.
The last one was like 25 hours.So, I hope you enjoy the somewhere between 25 and 30ome hours worth of learning.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 and 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 jump to number one and that is learn the data analyst skills.

2. Core Data Analyst Skills to Learn

Covers the five core skills to learn first: SQL, a BI tool like Tableau or PowerBI, Excel, Python, and a cloud platform, with reasoning on why each matters.

Now, there are literally a hundred different things that you can learn for data analytics.You can learn things like AlterX 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'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 will learn is a business intelligence tool like Tableau or PowerBI.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 PowerBI is pretty transferable to almost all those other BI tools.
They're all fairly similar in how they do things and how they show and display the data.You most likely won't have a technical interview asking you about Tableau or PowerBI 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 PowerBI 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, 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 100 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 learning, and this is the only one that I don't have a series on yet, and 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 on 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.

3. Building Projects and a Portfolio

Explains what building projects means, how to create a portfolio website, and why projects help land interviews and answer technical questions.

After you learn all of these skills, the next thing that I recommend you do is actually build projects with those skills.Now, what does 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 learned Tableau, you could 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.

4. Creating a Data Analyst Resume

Guidance on building a data analyst resume without experience, emphasizing placing skills and projects at the top above unrelated work history.

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.

5. Applying for Jobs and Using Recruiters

Advice on applying for data analyst jobs, why blind applications alone fall short, and how working with recruiters on LinkedIn increases your chances.

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 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 and my career.The first thing that I want to mention is actually what I would not do, which is just blindly apply on Glass Door, Monster, Zip Recruiter, and all these other platforms to just any data analyst job that you canfind.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 chances 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 and 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, in 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.

6. Timeframes for Becoming a Data Analyst

Breaks down how long each step takes, estimating roughly six months total, and shares the speaker's personal story of landing a first data analyst job.

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 upfront, 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 four 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, ABI 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 the 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 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 two 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 where they help you build a resume, it can take one to two weeks.The two last steps which kind of go hand inand 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 four 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 six 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.

7. What Is Data? Fundamentals

Starts the data fundamentals series by defining data, showing real-world examples like weather and banking apps, and contrasting structured, semi-structured, and unstructured data.

What's going on everybody?Welcome back to another video.Today, we're going to be starting our data fundamentals series.
15:10 - 15:47
Now, in this series, I'm going to be walking through some really core fundamental concepts about data.If you've been on my YouTube channel for any amount of time, you know that we talk a lot about data, specifically about how to use tools to work with your data.But up until now, I haven't really dived in and broken down the core concepts of what data is and how it's used in the real world.So, in this series, that's what I aim to do.And in this video, we're going to be starting off with what is data.Let's jump over to my screen and take a look.All right.Right.So, in this lesson, we're going to be talking about what data is.Again, we're starting from the very basics.We're working our way up through this series.So, by definition, data is just raw facts and figures.
It doesn't even necessarily have to be on a computer.It could be on a notepad.If you're writing down 1 2 3 4 5, that is data that you're writing down.That's going to be harder to use that data necessarily because, you know, on a computer, it's easier to process and use data.But that is data.Some examples of data are things like a number, the number 45, that is a piece of data.A word could be data.Just the word completed or a sentence that is also data.And then a date could be data as well.So we have 1210 of 2024.This is a piece of data.Now the thing about data is is that data is everywhere.It's in everything we do all the time.But without collecting it, without context of what this data actually means, it's basically useless.Look at some examples of how data is used in the real world.
Something that a lot of you will use almost every single day.So, let's take a look at this first one.This is a weather app.I use my weather app almost all the time.I got to send my kids to school and I want to check if it's rainy, if it's hot, if it's cold, if they need a jacket, if they don't.And that is something that requires a lot of data.Meteorologists use tools to collect data on all of these things.Then they're presented in these apps.So they collect data about weather, temperature, humidity, location, time, and they take all of this and they aggregate it.That just means they bring all of it together into one place and they aggregate these numbers.And finally, they'll present it to you based off of your data, your location, where you actually are.And so that is something that is extremely data dependent.
They typically will process this as well as forecast, which means they're going to kind of predict out what they think is going to happen in the next hour, two hours, maybe it's a day or several days ahead.They can also use this data to predict what might happen in your location.Another example would be a bank app.So, I go on my phone all the time to check my banking statements to make sure that, you know, I didn't spend too much money.And everything in your banking app is data.And so when you go on this app, like you can see in this image down here, you can see where you spent your money, you can see the amount you spent your money, the date and the time thatyou spent your money.These are all different points of data that the bank has collected.
Banks collect hundreds, if not thousands of data points, but really common ones are things like bank deposits and transactions and payments that you've made.All of these things so they can put it in your dashboard so that you can track your money.Now, let's take a look at different types of data because there isn't just one type of data.Data isn't just one thing.Data is really complex and there's a lot of different things to it.So, really briefly, I'm going to touch on structured, semistructured, and unstructured data.Structured data is really neat and really easy to visualize and see, as you can see in this uh image right here.That typically refers to something that has columns and rows, something like an Excel file.Everybody's used an Excel file before, and so that is something that is very structured, very easy to kind of visualize and use and understand.
The exact opposite side of this, we have unstructured data.Unstructured data is kind of all over the place and it might be a lot harder to use.For example, that could be something like a photograph that you took or maybe a video or an audio file.These are all examples of unstructured data that you can't really put into something like an Excel file for it to be in columns and rows.Then we have something called semistructured data.Semi-structured data is closer to structured data than it is unstructured data, but it is more complex than something like an Excel file.For example, semiructured data might be something like a JSON file.Now, we haven't gotten to file formats and file types yet in this series, but when we do, I'll dive into what JSON files are because JSON files store things differently than something like structured data where they nest data
in kind of these hierarchies.Let's take a look at the two main ones.Structured versus unstructured data.Structured data is the data that I primarily work with as a data analyst.This is typically going to be something like a row and column in an Excel file or a CSV file or in something like a relational database.A database is just a place where you will store a lot of data and all of that data typically connects in some way.So you can work with a lot of it.Structured data is also quantitative versus qualitative like unstructured data.Structured data is numbers based and it's measurable and so you can easily kind of track it and use it.Whereas qualitative could be something like a survey where it might be free text where it's someone saying you know I had a really great experience at this and I really liked this and I liked this.
That's a little bit harder to actually put into numbers how much that person liked.But quantitative may be hey how much did you like this on a scale of 1 to 10?And if the person puts a seven that's a very specific answer.Now the amount of data that sits as structured data is significantly less than unstructured data.Structured data is only about 20% of enterprise data compared to 80% of unstructured data.And so there's a lot more unstructured data in the world.And so what a lot of people in the data world do is they try to take that unstructured data and they try to make it structured.And so that is a big part of what a lot of data professionals do.Lastly, and we just touched on this, but structured data tends to be things like numbers, dates, strings, which are things like words and text, versus unstructured data, which is things like images, audio, video, and others.
That being said, data is everywhere.It is all around us all the time, and especially in this technological world we live in, it is literally in everything we do.But the challenge especially for people in data who are working with data, the challenge is to collect it, to organize and analyze it so that you can then use that data.

8. Understanding KPIs and Metrics

Defines metrics and KPIs, explains how every KPI is a metric but not vice versa, and teaches how to choose actionable KPIs aligned with business goals.

What's going on everybody?Welcome back to another video.Today we're going to be taking a look at KPIs and metrics.
Now, if you've worked in the data world, you've probably heard these terms before because they are very popular to throw around and use.but you may not know exactly what they mean.So, in this lesson, we're going to be diving into KPIs and metrics.So, with that being said, let's jump over to my screen.So, let's dive into KPIs and metrics.And let's start off with metrics.So, what exactly is a metric?A metric is something that, by the way, people throw out all the time and they typically get metrics and KPIs confused.And so, we will be really good going through this.I'm going to talk about metrics first and then how metrics relate to KPIs.So a metric is any measurement that provides information using data.So if you're taking data and you're tracking that data and you're measuring that data, that is a metric.
It can be anything.For example, let's say we have a website and we sell things on this website.It's like an e-commerce platform.A metric that we might have is website visits.How many visits per month do we actually have?And let's say this month we had 15,000 monthly visitors.We also could look at sales numbers.So, we sold 500 units of whatever product we're selling.So, these are core metrics.Now, if you look over on this right hand side, we have this dashboard.This is something that a lot of companies will have.It'll be something to track their metrics or at least visualize their metrics.It could be on revenue or margins or all these different things.This is something that when you're working with data, people want to know.They want to be able to measure and track specific data.Now let's see how this compares to a KPI.
KPI stands for key performance indicator and this is a specific metric that directly measures progress towards a goal.So every single KPI is going to be a metric but not every metric is going to be a KPI.For example, let's look over on this image on the right hand side.We start with all of our data and then we take that data and we say what metrics do we want to look at within this data?Then we determine what metrics do we actually want to track.Which metrics align with our goals.So for example, in our website that we have, we have 15,000 monthly visitors.But let's say our target KPI is going to be those monthly visitors, but our goal is 20,000.And so we have a metric that we're tracking.And now we're saying we want this to be a goal that we achieve.
And it's also measurable.For our sales numbers, we have 500 units sold.One of our sales KPI could be, okay, this month we're selling 500, but next month we want to increase our sales by 2% each month going forward.So that could also be a KPI.You may be asking, how do you choose a good KPI?And this is a very good question because I've worked with a lot of different data teams and they just sometimes randomly choose KPIs.They're like, this seems like a good one to achieve or get better at.That may be true, but it may not actually progress you towards the goal that you're wanting.And so when you're trying to choose a good KPI, let's say you're tracking these metrics, you're saying I want to progress towards a goal.How do we choose what KPIs we want?The first thing you have to ask is what is your goal?
Maybe for our website it was we want to increase sales.That's our number one thing.Then we have to identify which metric actually best tracks our progress towards that goal.On a website there are a ton of different data points that you can do.For example, you can see how long a user is actually on your website.You can see how many times one user gets onto your platform every day.Maybe they get on three or four or five times a day.Those are metrics, but that may not be what your goal actually is to sell your products.And then lastly, you have to say, is this metric actionable?Maybe you can't make people sign onto your website 3, four, five times a day if that's what you're wanting to do.That may not be an actionable metric to actually track, but something like the daily users is because maybe you could send out a daily email or you can do some type of marketing to get more people on your
platform.These are things that you have control over and that are actionable.So, really quickly, let's just break down key performance indicators versus business metrics.A KPI is going to provide a direct line of action to a business goal.Whereas business metrics don't necessarily contribute directly towards a goal.KPIs are measured actively as a benchmark to a goal.Whereas business metrics can be measured, but they aren't typically checked and monitored.For example, at a previous company I was working with, we had lots of metrics that we kept kind of tabs on, but we only put the key performance indicators or the most important ones into dashboards or maybe intoreports that we would then provide to our users.Next, KPIs are a set of standards that are vital to the business.Whereas metrics may or may not be vital to the business.Again, could be anything versus KPIs are like the core things that you want to track and get better at.
And then lastly, this is something I mentioned before.All KPIs are business metrics, but not all business metrics are KPIs.You specify exactly what metrics you want to be KPIs to help move your business or grow your business, however you want to do that.So, in a nutshell, a metric helps us understand what's happening in our data.And KPIs show us whether we're reaching our goals using our data.I hope that this was helpful.This was not something that I knew when I first started uh working in data.It's something I kind of figured out along the way.But if you are just getting into data, or maybe you already are and you don't know what this is, now you know.And now you can go into business meetings and you can go into conversations being a little bit more knowledgeable.

9. Data Types Explained

Covers core data types including strings, numbers, and date/time, with examples of how each type enables different analysis like aggregation and averaging.

What's going on everybody?Welcome back to another video.Today we're going to be taking a look at data types.
If you've worked with data at all, you know that data types are very important.And if you haven't, you're in the right place cuz we're going to talk a lot about what data types are and how they are used.So with that being said, let's jump onto my screen and take a look.So let's dive into it.Let's take a look at what data types are.Now data types, really quickly before we jump into the definition, data types are something that if you work with any data in any way, data types do pertain to you.These are things that you need to know.These are things that eventually will either help you or hinder you on whatever you're trying to get done.So a data type is an attribute associated with a piece of data that tells a computer system how to interpret its value.
Every single programming language, every database has similar but slightly different data types.I've worked with all types of programming languages and lots of different databases and they all act somewhat similarly, but they can be different at times.So knowing the core concepts that we're going to cover in this lesson can be really helpful to kind of traverse the different types of data types in different systems.To get started, there are a ton of different data types.I mean, there's probably 50, 60, 70 different data types.I'm just throwing out random numbers, but they all fall under certain categories.They're usually either strings, which are things like free text, numbers, like 1 2 3 or date and time.So, January 1st of 2024 at 6 p.m.These are kind of the core fundamental data types.But under each of these are a lot of other data types as well.
Now within string you could have something like a name.John Smith, Emma Johnson.This is very simple data that you can categorize and you can use.Next it could be an address.123 Main Street, New York, New York.This is something that can determine a location.Then we have something like product categories, electronics, furniture, etc.These product categories are all strings, but then can be used later on in the data process for things like aggregation.Maybe you want to see how many customers are buying electronics at your store versus furniture at your store.You have to collect that data.You do that with string data.Next, we have numerical or numbers.This is probably the most simple data type.It's integers.25 100 - 15.Then we also have decimals.These are both two separate data types.So decimals is like 12.5 99.99.Now within certain systems, especially databases, they'll have something like a big integer for really large numbers.
They'll have something like a small integer.They'll also have just a regular integer.Within decimals, they may have something like a double point system or a decimal data type.So within each of these, they may have even subcategories of data types.Next, we have date time.The dates could be something simple like 1210 of 2024.We have a day, a month, and a year or it could be month day year.There are different formats within dates.Then we have times or timestamps.So times just indicate the time of the day.Then timestamps are both date and time combined.So the timestamps tend to be very specific.Then we have dates which give a general day and then times that just give a specific time.Timestamps can be very useful, but often times when you're working with it in the real world, you'll break out these two data into separate columns.
You have date in one, time in another, and that may allow you to do more advanced things with this data.So understanding what data type your data is is really important because that allows you to work with it and analyze that data in different ways.For example, if we're working with numerical data, we can use that to calculate averages.You can say the average person is spending this much on our website per day.That would be an example of how you can use numerical data.Or with string data types or categorical data, you can group it and count on those occurrences.Or you can do any type of aggregation.sum, max, min, average, median, all these different things.You can see how many people are buying things in our electrical department versus our furniture department.And that is worthwhile data to use.That really is the basics of data types.
Now, if you go into specific things like if you go into SQL or if you go into Python or Excel, I have a lot of lessons specifically for data types in those systems and then it gets a littlebit more complex.And so if you want to really dive into data types in a specific system, go into any of my playlists, whether it's SQL, Excel, uh PowerBI, Tableau, they all have different data types and you can learn a lotmore about data types within that specific tool.

10. File Types and Formats Overview

Introduces file types as containers for data, covering text/CSV, structured files like Excel and database files, semi-structured JSON/XML, unstructured media, and parquet files.

What's going on everybody?Welcome back to another video.Today we're going to be taking a look at file types.
Now, file types or file formats are everywhere.If you've saved any type of file ever to your computer, you had to save that as a specific file type.So, in this lesson, we're going to be diving into exactly what file types and file formats are and how they are used.So, with that being said, let's jump over to my screen and take a look.All right, so let's take a look at what file types are.File types refer to the format in which data is stored in a file.And you're going to see even in the next slide, there are so many different file types out there.There are a lot.And we're going to get into specific file types in this video that you can see a lot of the different types of files that are very commonly used.Each file type is designed for a specific purpose and it depends on what kind of data it's holding and how it's going to be used or shared.
You really can think of these like a container, whether it's a bowl or a plate or it's a vase.Each one of these containers is designed to hold different things.And that's kind of like what a file type is used for.Now, if you go right now, you look at your file explorer if you're using a Windows machine.If you go to your view and you look at the details, the view is right next to the sort button up there, you can see the different type of file type.And with all this is my actual, you know, file explorer right now.If you go look in my downloads, we have a lot of different stuff.I have MP4 files.I have different file folders that holds different files.I have PGs, I have CSVs, I have PDFs, I have all sorts of stuff.To the right of this you can see the size as well.
All these different file types hold the data differently and some take a lot more data than others.So that size is how much data is actually stored within that file.Let's take a look at probably the most simple type of data file or data format that you'll see which is a text file.A text file is super simple and just stores data as plain text often used for unformatted or tabular data.This is data that I would work with all the time as a data analyst.We would work with text files and CSV which stands for commaepparated values.This image on the right hand side is being stored right now as a text file.But if I then went and saved it as a CSV, it would separate these values based off of the commas.So country, salesperson, order amount, quarter, this data would be separated and all the commas going down on each row would be separated into basically columns and rows.
DSV and text files are super common and they can store a lot of data very simply because they're just storing plain text and so it doesn't get super complex and so it's a very popular type of file format.Next we have structured file types.Now these are files that store data in a predefined structure typically rows and columns or in a hierarchal format.One of the most common types is one that I'm sure almost everyone has used.That's an XLSX.That's going to be an Excel file.your typical Excel workbook.And so right here on the right hand side, this is your standard workbook.You're going to have columns and rows and different worksheets and you'll be able to do different things with that data in these Excel files.We also have a DB file and this stands for a database file.So oftent times in the data world, if you're working with a customer or a client, they might give you an entire backup of their database and you can go and use that.
And within that database, they're going to have columns and rows, especially if it's a relational database.They're going to have columns and rows just like an Excel file, but on a much larger scale.It typically can hold a lot more data.And then, of course, you get more complex things within a database file, like database schemas to connect and bring all that data together.Next, we have semistructured file types.Now, these get a little bit more complex.These file types have a loose structure, often used to store complex data relationships.Some common formats for this are JSON and XML files.Now, these can get a lot more complex than just columns and rows because in columns and rows, it's pretty simple.It's pretty straightforward.But something like a JSON file, which we have on the right hand side, you can have data nested within other data, which just means data within data within data.
And so, there can be lots of layers to this data.This is another one that's just really popular and really common within data professionals.And they are really great for storing data that's a little bit too complex for something that's really simple like columns and rows.Next, we have unstructured file types.Now, you saw this within my file explorer.These are files that don't follow a specific format.They don't have columns and rows.They're often just raw data or multimedia data.For example, this video that I'm recording right now, I'm recording onto an MP4 file.This image on the right of this beautiful little hummingbird is apng or there's actually lots of different formats for images, but PNG is probably the most common one.Lastly, we have big data and specialized file types.So, these file types are designed specifically to handle really largecale data efficiently.
One of the most common and one that if you've worked in the data world or you've worked in Azure or maybe even AWS that you might be familiar with, it's something called a parquet file.Paret files are very common, especially if you're working in something like Spark.That's something where I've used it quite a bit or even data bricks where you're bringing in massive amounts of data and you want to do that in a really efficient manner.So, it has all these different properties that they bring in to these paret files that a normal CSV file would never be able to do or handle.Now, what file type you choose can be extremely extremely important.And I've made a lot of mistakes over my years as a data analyst storing data in, you know, one file format versus another.And that has caused issues.And so, and so knowing how data actually is collected and used and stored and analyzed and shared, you have to take all these things into account when you're determining what kind of file type you want.
Now, in the next lesson, we're going to be looking at data collection.And we're going to address this exact thing because if you store data in a specific way and then you want to put it in a database, it may not be possible if you store it incorrectly.And so, there are a lot of things to consider within just data collection.But this has been our lesson on file types.

11. Data Collection Methods and Sources

Begins the data collection lesson, defining data sources and why gathering raw data is the foundation for analysis, trends, and data quality.

What's going on everybody?Welcome back to another video.Today we're going to be talking all about data collection.
Now, data collection is an extremely part of getting data.In fact, I was on a data collection team for over 3 years.I absolutely love data collection and so I'm really excited to talk about this topic.Let's not waste any time.Let's jump on my screen and take a look.Let's take a look at data collection.Now, what exactly is data collection?Just as a definition, data collection is the process of gathering data from different data sources to use in analysis, decision-m and problem solving.A data source means where the data is actually being created.And data is created all around us.It could be in a hospital ehr system.It could be in your bank account.It could be through APIs.It could be through a website or it could be in a CSV file.So why is data collection important?And what I really should say is why is it really important?
One, it ensures that you have raw material or the raw data needed to make informed decisions.You can then use that data to identify trends, patterns, and opportunities within that data.And it also lays the foundation for data quality.This is something that we're going to cover actually in our next lesson when we look at data cleaning.So, if you collect data poorly or if you do not process that data correctly, that can lead to bad data, which can give you incorrect results and then of course you're going to make bad decisions with bad data.Now, data collection does not just happen.It doesn't just magically appear.This is a very calculated and specific process that needs to happen in order for you to get that data.Let's take just a really quick example.You are actually running an online shop.You have a website.
You're selling stuff.On the right, you're selling t-shirts and jackets and other clothes.I'm assuming now you want to track how many customers actually put something into their cart.You might be able to compare how many customers put something into their cart versus how many customers actually bought something.And that could be useful information to you.that data just doesn't appear.A data collection system is set up to collect that data and place it into something like a database so it can be analyzed and used.Now these data collection systems can be something that you manually create and we'll talk about that in a little bit or it could be something that you just pay for.So it could be a system that you say, "Hey, I want you to collect this data."They go and do it for you and you don't have to actually do the work, but there is a data collection system in place.
Now whether it's you or some system you paid for, all this data is going to be processed via a data pipeline.Now this is a system that's going to automate the movement of data from one place to another while often transforming it along the way.Let's take a look at this ETL pipeline.ETL stands for extract, transform and load.And you can see that uh through this process.So on the left hand side we have all these different data sources.It could be different parts of your website or it could be different websites or it could be different locations of the data entirely.We're going to extract that raw data and we're going to put it into a staging area.This staging area is kind of like a temporary hold for your data where then you can work with data professionals like data engineers, database developers, data analysts, data scientists who can then determine how we want to transform that
data.Now transforming data is something we'll cover again in the next lesson when we talk about data cleaning.But transforming the data makes that raw data more usable for whatever you're trying to use it for.After we transform that data, we're going to load that data into something like a data warehouse, a database, maybe it could even be an Excel file.It could be as simple as that.But then from there, we can use that to analyze our data.And that's really what data collection is in a nutshell.Now, I worked on a data collection team for many years, and I was a data analyst, and I would often work at every single step of this process.I would have to go and talk to the client and see exactly what data they had available and sometimes they didn't even have data available and so they said hey we want to collect this new type of data
as part of my job is I would help them understand how to start collecting that data so then we could create these data pipelines to then transfer it into a database to use data collection is not a one-timething either data collection is always happening these ETL pipelines they break or they need new ones or the source data changed on the left hand side of this diagram the source data changed from one part of the websiteto another.And so you need to go back and you need to fix that data pipeline to correctly collect all the data that you're wanting.And so this is a very active process.This typically doesn't just happen one time and then it's done.It typically happens one time, then you adapt it and you keep changing or maybe fixing it over time.What's going on everybody?Welcome back to another video.
Today we're going to be talking all about data cleaning.
Now data cleaning is an essential part of working with any data and so this is a very core fundamental concept that anybody who works with data will need to know.As a data analyst I've cleaned data in almost any way that you can imagine.So I am very excited to talk about this topic.Let's not waste any time.Let's jump on my screen and take a look.All right.So let's take a look at what data cleaning actually is.Data cleaning is the process of identifying and fixing issues aka dirty data in your data to ensure it's accurate, consistent, and complete.Let's take a look at these patient names on the right hand side really quickly.These are all my names, but just in different versions or variations.This is very dirty.So, we have Alex Freeberg, Alexander Freeberg, Alex F, Alexander F, Alex Freeberg with a U, Alejandro Freeberg.
These are all the same person.That's all me.But if you're looking at this in a database, it's going to consider all these people different.And so what we would have to do to clean up this data is we would have to make all of these names consistent and the same.Maybe we do that by saying, okay, all these people have the same date of birth.They're all male.They all have the same social security number.But with all of those things, we could say, yes, these are all the same person.We can make all of these patient names Alex Freeberg with an E.That would really clean up this data a lot.Why do we need to clean data at all?What is the reason that we do this?One is to ensure accuracy because you're going to be giving this data to stakeholders or your boss or a customer and they're going to expect that this data is accurate.
But if you're giving them bad data, then they may make bad decisions with that data and that's going to come back on you.Next, it improves efficiency.When you are working with clean data, it is 10 times easier to analyze and use that data in any way you need rather than it being really messy and really difficult to work with.Lastly, it builds trust and stakeholders and customers and clients, they want to be able to trust that what you're giving them, the data that you're using is actually accurate and complete.And so those stakeholders are really going to trust you if that data is clean and accurate and you can find insights with that data.Now, let's take a look at some other examples of dirty data.And these are not all of the examples, but these are many of them.Here in this data, we have columns and rows like an Excel file.
We have a name, a phone number, an email address, and an address.In each of these, you can see a lot of mistakes.Take for example in the name column.We have things like punctuation marks and abbreviations.These are the same person, just like we looked at in the example with my name.These are all the same person, but each of these records requires a different row of data because it isn't standardized or cleaned.Let's look at phone number.This one shows us missing data.And this is a very common one where you're collecting phone numbers and all of a sudden you just don't have a phone number.So you're missing that data.Now, what are you going to do with that when you're cleaning it?Maybe you need to populate that data.Maybe that is something that you can get from another data source or you know it and you can actually put it in there.
That is a way you can clean that data up.Next, we have mixed numbers and letters.It may look like 831262149, but that one is actually an L.And so this is just a classic case of bad data.They should all be in the same format with the phone number, but they're not.Some have dashes, some have commas, some don't have anything, and some even have letters.That's very, very messy.Next, we have email address.Now, within this one, they're all somewhat different, right?We all have different email addresses, and again, that's just a standardization, making them all the same issue.But we also have something like a non-printable character.Now, there are specific characters within computer systems that you just shouldn't be putting or really can't put in specific data types.So, if this is a string, that may be a character that you shouldn't have or can't have.
That's going to mess up your data.ly in the address section, we have two issues here.We have messy structure and format.So, some are capitalized.So, so some of the data is capitalized versus not capitalized.We also have incomplete data.For example, we have Emily Renzelli Boulevard, but we don't have a number.We don't have a city.We don't have a state.They're just incomplete.And that makes it really difficult to work with that data.Now, here we have something called a data cleaning cycle.And I really like this visualization because it shows that data cleaning is not just a one-time thing.It is something that you have to continuously do.And I have and I have experienced this a lot over my years as a data analyst.Once you clean data isn't necessarily perfectly cleaned.You kind of have to go back and clean it as you go.
And it's never really perfect.it's just really usable.This cycle typically starts at the very top.So we have importing data.This is just bringing in data from other systems, usually through some data collection system like a data pipeline that we talked about in the data collection lesson last time.Next we have merging data sets.This is combining multiple data sources into one data set.Next we have rebuilding missing data.This is where you're handling incomplete data or you're actually filling in that missing data.Next we have standardization and normalization.Standardization is where you're making sure that the data follows a consistent format.So all the date formats are the same.

12. Data Cleaning Fundamentals

Introduces data cleaning concepts, why dirty data causes problems, and the core steps analysts take to prepare data for analysis.

For example, if we go back to this one, we can make sure that the address is all standardized.They all have an address, a city, a state, and maybe a zip code if you need.They all have the same data.Next, we have normalization.This is a little bit different because you're adjusting data to a common scale without distorting the data itself.Next, we have dduplication.And this is where you may have duplicates of data in your columns.For example, maybe we have a 100 columns of Alex Freeberg and we don't need 100 columns.It's all the exact same data.We would want to remove 99 of those to just keep the one that we actually need.Next, we have what they call verification and enrichment.This is really just data quality.You're going through and you're validating your data, making sure that your data is accurate.
Then lastly, you're saving this clean data in the format that you need for your next processes, whether it's analyzing or you're using in some type of product.Now, one thing I want to mention on here is that this cycle is not perfect.In fact, I usually do dduplication earlier on within this cycle, but it really depends on the data itself.Sometimes you're importing, merging, rebuilding, and then going back and getting more data and then importing, merging, and rebuilding.So, this isn't a perfect cycle.This isn't exactly what you should do every time, but these are often the steps that I am taking when I'm cleaning data.Now, data cleaning is very specific to different tools, and I have a lot of different videos on how to exactly clean data with full projects on data cleaning in SQL and Tableau and PowerBI and Python and Excel.
And so, if you want to learn hands-on how to actually clean data, go check out those videos cuz they are fantastic to learn how to actually clean data.Today, we are going to be starting our MySQL tutorial series.
Now, the entire MySQL series will be broken up in three smaller series.We'll have our beginner, our intermediate, and our advanced.This lesson is the very first lesson in the beginner series where we're going to walk through all of the beginner or the basics of MySQL.Today, we're going to be setting everything up.So, we'll be installing MySQL and then creating our database that we'll use to actually learn MySQL.Now, before we get started, I wanted to let you know that I created three full MySQL courses over on analystbuilder.com.I built a crash course for MySQL for people who are going to be interviewing or taking technical interviews.I also created a full MySQL course that's going to cover everything from the basics all the way to the intermediate level.And then lastly, I created an advanced course that's going to teach you a lot of the more advanced things that an analyst would typically use.
Those courses are going to go really in-depth and they're going to have a lot of practice questions along the way and we'll also have full guided projects in there as well.I'll have links in the description to all of those courses if you want to check those out.Now, without further ado, let's jump on my screen and install my SQL and create our database.All right, so let's get started by downloading MySQL.We're going to come right over here to dev.mmysql.com/downs/installer.
And I will have that link in the description so you don't have to write all that out, but you should be seeing this page right here.Now, we have to select an operating system.I'm using a Windows machine.And if you aren't, if you're using Linux or Mac or something else, it should populate it for you.But if it doesn't, just select this dropown and select your operating system.Next, we have two different downloads.We can install the MySQL installer community or MySQL installer web community.This one is very small, but then you actually do have to download the installer.It just gets it from the web.This one I'm going to download the actual installer.It's larger, but this is the one I'm going to do.So, I'm going to go ahead and select download.It's going to ask me if I want to log in or create an account, and I don't.
I'm going to say no thanks.Just start my download.I'm going to save this in this desktop folder.Doesn't really matter where you save it.We're going to save that.And it's going to download.It should be done in just a few seconds.I'm going to go ahead and click on it.And it's going to open it up when it's finished.And we should get the interface or the UI for the actual installation for MySQL.So, here is the MySQL installer.And first thing we need to do is choose a setup type.Now, we're going to keep the developer default unless you really know what you're doing.And you can select the server only, the client only, full, which is literally everything MySQL has to offer, or custom.So, we're going to keep this developer default, just installing the things that we kind of need.
So, let's go ahead and select next.And for whatever reason on my computer, it's saying this path already exists.You probably won't get that, but I'm just going to go ahead and select next.And then I'll select yes.It keeps doing that.I can't explain why, but it keeps doing that for me even though I've deleted it from my computer completely.U but it just remembers it somewhere in its memory.Now the next thing we need is to check requirements.Now I just have this one.It says I need to download this uh Visual Studio.I'm not going to do that, but on your screen you may have multiple multiple requirements.Typically you're looking at something like this Microsoft Visual C++ redistributable package.What you need to do is download this.All you have to do is click download.Once you download and install that on your computer and then we go back, all of those should be gone.
That's the one that I see the most when I'm actually working with these requirements.I had to install it myself when I got this new laptop.So, go ahead and install that if you need to.But if yours looks like mine, we don't need this Visual Studio for what we're going to do.We're going to go ahead and select next.It is giving us a prompt that we haven't satisfied all the requirements, but that's okay.We're going to go ahead and select yes as well.Now we're ready to install all of these things.These are all things that MySQL wants you to install.The most important are the server and the workbench, but it does not hurt to have all these other things as well.Some of these connectors are also important.So, we're going to go ahead and execute.This will take just a few minutes.
I'll skip ahead uh when they're all done, but this should take just a few minutes and then we'll continue on installing my SQL.So, everything just completed and now we're going to select next.And now we need to actually configure our product.Now really the only one that we actually need to configure is the server.The router says we need to configure it and the samples and examples say we need to configure it as well, but really it's just the server.Let's go ahead and select next.Now we're not going to change anything for this type and networking unless you know what you're doing with the port, the X protocol port.Uh we're not going to change any of this.We'll go ahead and select next.Next thing we need to do is select an authentication method.I'm going to be using a password.I'm not going to be using the legacy authentication method.
So, I'm just going to go ahead and create a password.Now, for you, and I keep getting this error, and I can't explain why right here for you, you should be creating a password at the bottom.It's remembering my password somehow, and I I really can't explain it, but I'm going to create my password or check my password.Uh, this is one that I already created uh before I deleted it off my computer, but it's still there.Um, so it's saying my password is still good, but if you need to, you should be entering a password and then confirming your password and saving it.And then you should also be checking it as well.And then we're going to configure this as a MySQL server as a Windows service.I'm going to keep that checked.Uh, and we're going to start the MySQL server at system startup.
I like that automatically being there.I don't want to mess with that.So, I'm going to keep it as it has it.We're going to go ahead and select next.And the last thing we do is just need to execute this.And then everything we put in there is going to actually go.So, let's run this and execute it.And that just finished.So, let's go ahead and select finish.Now, it says configuration complete for the server, but we also need to configure these other two.Let's take a look at these really quickly.We're not going to do anything on this.It even says we really don't need to do this.We just need to click finish and configuration not needed.Next, we'll do samples and examples.And we can input our password.And all this is really going to do is put in some sample databases for us in our database, which if you want, you definitely can do that.
Uh, I just connected.That worked.

13. Data Cleaning Techniques in Practice

Walks through practical data cleaning techniques for handling messy, inconsistent, and incomplete data before analysis.

I'm going to hit next and execute.And it's basically just going to put in a database or two, some sample ones for you to look at.And the configuration is complete.You don't have to do that one, but we'll see that in just a second.We're going to select next.And now the installation is completely done.and we can start my SQL workbench after setup and start my SQL shell after setup.Now, I'm not going to do the shell, so I'm going to actually uncheck that and we're going to select finish.Now, my SQL just popped up for us, and this is exactly what you should be seeing.Now, there's a lot of things in my SQL to learn and know how to do.We're not going to be taking a look at all of that stuff today, but in future lessons, we'll walk through a lot of these different things that kind of correlate with different lessons or things that we're working on
in my SQL.The first thing that we're going to click on is right over here.This is our local instance.This is local to just our machine.It's not a connection to, you know, some other database on the cloud or anything like that.It's just our local instance.We're going to go ahead and click on this.So, this is what you should be seeing right here.This is where we're going to actually write all of our SQL code.And I'll show you all this in just a second.But this is where we can actually create our database.And our database is going to go right over here on this lefth hand side.This silica one is actually a sample database.It has a bunch of tables and views store procedures functions has all these things in here if you want to go ahead and mess around with that.
What we're about to do is create our own database that we're going to be using throughout this entire series both beginner, intermediate, and advanced.We'll use a lot of this and sometimes we'll import some other ones for different use cases, but this will serve for most of what we're trying to do throughout this entire series.Now, what I'm going to do is I'm going to go ahead and I'm going to say open a SQL script file in a new query tab.And right here, it opened up to a folder that I already created, this mysql beginner series folder.Within it, we have this right here, the parks and recreate_b.Now, in order to get this, you just have to go to the GitHub and download this file.That's all you have to do.We're then going to open this file.So, let's click on it.
We're going to say open.And what you're now seeing is basically the query editor.This is where you can write your code.Now, we're not importing a database.We're actually creating it by running code.Now, because this is the first lesson in the beginner series, I'm going to assume that you don't know a ton about MySQL.Really, all this is doing is creating the database name and then we're inserting a few tables into that database and then we're inserting data into those tables.So, this is all of our data that will go into these tables that we create.We only have one, two, three different tables that we're going to be using.So, all you have to do to run this is click this lightning button right up here.We're going to go ahead and execute this.If we come down to the bottom and we pull this up, this is our output.
This says six rows affected.And we have a bunch of other things like create table, create table, insert, insert, create table, insert into.These things are all working perfectly.So now if we go ahead and click refresh in our schemas with this refresh button right here, this parks and recreation table is populated.If we go under the tables, we see all of these things.So, now that we've actually created our database and our tables, that's really all we were trying to do in this lesson.But I just want to open up a table really quickly, show you what it looks like, show you how we can run code, and then in the next lesson, we'll start actually learning how to query this data.So, let's go up to employee demographics.We're going to rightclick and select rows limit 1000.This is going to open up a new window right up here and it's going to say select everything from this database dot this table employee demographics and it ends with a semicolon.
Now right down here we have this output window.This is the actual data that sits in our table.We have columns right here.So employee ID, first name, last name, age, gender, and birth date.And then here are all of our employees on each row.So these are all separate rows.We have Leslie Nope, Tom Havford, and it goes on and on.So this is all of our data.The most important things to know when we're actually working with this, and I'm going to zoom in, is if we hover over this query right here, and we run it, we can select this execute, which is this lightningbolt with this I, we're going to execute this, and it's going to run this because we're highlighted over it.Now, if we have two queries, let's say this one right here, but let's change it to employee salary.
We'll do underscore salary.Let's say we want to query this table.So now if we highlight over this and we go up and select the lightning bolt with the I, now we're looking at a different table.But if we select, even if we're hovering over this, if we select this button, we're going to execute everything in this editor window.So let's run this.And now you can see at the bottom we have two outputs, the employee demographics and the employee salary.So this button is going to run everything in this editor window.Whereas if we select this lightning bolt with the I, we're doing everything that's just under where we have the cursor, where we have it highlighted.The very last thing that I want to mention is that right over here, you may have this up and you probably don't want that.We're not going to do any SQL editions in this series.
You can get rid of that by clicking this button right here.So, starting in the next lesson, we'll have everything ready to go and we will start learning the basics of my SQL.I hope you're able to follow along, get everything set up how we have it on this screen.I am super excited about this series.I just I love SQL.So, I'm really, really, really excited to get started on this with you guys.I will see you guys in the next lesson.
Hello everybody.In this lesson, we're going to be learning about the select statement in MySQL.The select statement is used to work with columns and specify what columns you want to see in your output.The first thing that we need to do is open up a tab or an editor window.So, let's come right up here to the left-hand side and we're going to create a new tab.And I'm going to zoom in just a little.Now, what we need to do is we need to select the actual table that we're going to be querying off of.If you remember from the very first lesson when we set everything up, we came over here and we rightclicked and did select rows limit 1000.We're not going to do that.We're going to actually write it out.So, what we need to do to select that table, the employee demographics table, is we need to select everything.
That's what this star means.The star means everything.All tables, all rows.Now, we do have a limit on here.We have a limit to 1,000 rows.So, if we had a table that had 50,000 rows, this limiter would be an issue.It would still limit it to 1,000 rows.We would have to change that to 2,000, 5,000, probably all the way up to 50,000 if we wanted to view everything.If we had, say, a million rows, we would need to come up here and say, don't limit, and it would give us a million rows.The reason they do this is mostly to keep the processing time low.If you have a million rows, it's going to take a long time for the output to actually appear.So, let's come right back here.The next thing that we need to do is we need to say select everything.
And now we need to say where we're selecting it from.So, we're going to come right down here and we're going to say from.And now we need to specify what table.And we're going to say employee demographics.And at the end, we need a semicolon.Now, why do we need a semicolon?This is going to tell my SQL that this is the end of this query.So, if we write another one down here, which we will in just a second, it'll be able to distinguish between the two queries.We're going to go ahead and we're going to run this and we'll just use this execute right here instead of this one.And there we have our entire table.So, we were able to get our table.Now, there is one thing that is potentially wrong depending on what you're using it for.But what we didn't do is we did not specify the actual database before it.
We only specified the table.And this works perfectly fine because if you look over here on this left-h hand side, we have parks and recreation.It's in black.It's bold.That means that we're hitting off of this database.What's going to happen though if we come down here to the CIS database and we double click on it?Now this database is highlighted.So now when we're selecting this table, we're trying to select this table from the CIS database.Let's go ahead and try this.If you notice, we have no output.Let's come right down here and pull this up.

14. Excel Basics and Interface Tour

Starts the Excel series with an overview of the Excel interface, workbooks, worksheets, and basic navigation for data analysts.

It's going to say employee cis.mp employee demographics doesn't exist.So it's assuming that we're highlighting this CIS database.That means we're trying to pull from that database.Now we can still have this highlighted and still select the correct database by saying parks_and_recreation
and let me spell that right dot.So now we're selecting everything from parks and recreation employee demographics.If we run this, we do get the correct output.That's just something to consider, especially when you're working with a lot of databases and a lot of tables.It's usually best practice to actually put the database in front of the table name.Although throughout this lesson, we probably won't be doing that every time since we're only going to be using this parks and recreation database.Let's go ahead and double click this so we have this highlighted again.And let's click all of this.Let's copy all of this.We're going to come down just a little bit right here.Now, so far we've only selected everything, but we don't have to do that.We can actually just select one column if we would like to.For example, if we got rid of that star, we say first name.
We're selecting the first name column from this table.If we highlight this query and we hit the execute button with the I.Now, we are only going to return in our output all of the first names.And we can add a lot more.Let's actually look at all these.We can separate multiple columns with a comma.So we can do first name, last name, and then we could do birth date.So now we have three separate columns.Let's go ahead and run this.And now we have first name, last name, and birth date in our output.Now the way we just wrote it is all on one line.And that's perfectly acceptable because my SQL is going to read it the exact same as if we did it in a different format as long as it's still in this order.But sometimes you'll see it like this where it's select first name, last name, comma, birth date all on different rows.
Now, there's a lot of different use cases for this or reasons for this, but it typically can be easier to read.Also, if you're doing any type of functions or calculations in the select statement, it's easier to separate those out on its individual row.Now, again, we won't always be doing this, but it does help sometimes if you're doing that.It just makes it easier to visualize.For example, if we added the age.So, let's add age in here.Let's run this.Let's say we were doing a calculation where we wanted to add, you know, 10 years to their age.So, we'll say age and we'll actually create a new row for this or new column.We'll do age + 10.So, now we can easily see that we're doing plus 10 here.And this is another thing that you can do in the select statement, things like calculations.
So, if we go up here and we run this, we'll now have an age column, but we'll also have an age + 10 column where it just adds 10 to the age.And we can at least visualize and really easily see this when we're doing these calculations.Now, something really important to know about any type of calculations, any math within my SQL is that it follows the rules of PEMDOS.Now, PEMDOSS is written like this.It's PMDES.Now, what I just did right here with this pound or this hashtag is actually create a comment.So, this code isn't going to actually run, but it's just for note-taking or seeing things in your actual editor window.I'll come back to comments in just a second, but just wanted to explain what that was.Now, what PEMDOS is is the order of operations for arithmetic or math within my SQL.
This stands for parentheses, exponent, multiplication, division, addition, and subtraction.So this is the order that these calculations are going to run in the execution engine that my SQL has.So if I do age + 10, and we'll put that all in parenthesis, and then we come over here and we add* 10.So we're doing plus 10 here and then a time 10 here.What's going to actually happen is it's going to say age + 10.So 44 + 10= 54.Then we're multiplying time 10.The parenthesis executes first because it comes first in this order.Parenthesis.Multiplication comes next because it's this one.And then anything else after that if we did, you know, plus 10 could run this.And you'll notice that it still follows the logic.10 was just added at the very end to all of these outputs.Now let's go right back up here.
Let's select everything again from this table.Let's pull up this table.so we can see it a little better.And let's go down because the last thing that I want to show you is something called distinct.Now, this is really, really useful and you use this a lot in my SQL.What distinct is going to do is it's going to select only the unique values within a column.Let's go ahead and copy this employee demographics.Bring it right down here.Let's say select and let's do first name.So now we're just selecting the first name.Let's come right down here.There we go.So now we're selecting just the first name from this column.Now these are all unique values.So if we come right here and we say distinct, nothing should happen to this table cuz these are all unique values.Let's go ahead and run this.
As you can see, the output looks exactly the same.But what if we were do something like gender?So let's come here.Let's do gender.Let's run this.Keeps going down.I don't know why it's doing that.Um but now we have male and female.Now these are not all unique.We have female, female, female, and female.And the rest are males.So there's only two unique values here.So if we come right here and we say distinct gender, now there should only be two in the output, male and female.Let's go ahead and run this.So now we get male and female in our output.Now this works perfectly in one column but what happens if we have two columns.So let's do first name, gender.Let's go and run this.Now the combination of first name and gender are no longer unique.Now Leslie and female are being grouped together and it's taking the distinct between both of these columns.
So when we're only working with gender, it's only looking at this one column for both male and female.it reduces it down to the only two unique values.But because we add the first name, all of these values are unique.So therefore, the name plus the gender combination is always going to be unique.The very last thing that I want to show you in this lesson doesn't actually pertain to the select statement, but I want to save this code.Let's say we wanted to update this or upload this into our GitHub or save this and send it to somebody.We can do that.We can save it by clicking this save button right here.I'm going to go ahead and click this.And now we're in our MySQL beginner series folder.I'm just going to save this.And I can save this as anything I want.
So I'm going to say two dot select statement tutorial.So now when I save this, you'll notice that the name gets changed up here to two select statement tutorial.Let's exit out of this.I'm going to open up and now I'm going to come here to the select statement tutorial.I'm going to open it.And now I have our code again exactly as we had it written before.I just wanted to show that to you in case you wanted to save your code as you go throughout this series because that's usually what I do when I'm working with this stuff or learning these things.Like to save my code as I go along.So with that being said, that is the end of the select statement.In the next lesson, we're going to be learning about the where statement where we can actually filter our data.
Hello everybody.In this lesson, we're going to be taking a look at the wear clause.The wear clause is used to help filter our records or our rows of data, whereas the select statement is used to help filter or select our actual columns.So, when we're using the wear clause, we're only going to return the rows that fulfill a specific condition.Let's take a look at exactly how this works.Let's say we come right up here.We're going to say where.And let's go down with that one.Let's say where.

15. Excel Data Entry and Formatting

Covers entering, formatting, and organizing data in Excel, including cell formatting and working with rows and columns.

And now we need to specify what column we're about to create this condition for.So we're going to say first name.So we're saying where the first name we'll say is equal to and let's do quotes.And let's say Leslie.So we're saying the first name has to be equal to this value right here, which is Leslie for Leslie.Nope.If we run this, there's only going to be one row that's returned because Leslie is the only Leslie in this entire table.Now, we just used an equal sign, and that's actually called a comparison operator.And there's a few other comparison operators that you can use.Let's take a look at some of these other ones.Let's pull this down right down here.And let's actually highlight the select from, and we're going to run it with this one right here.It's going to only select everything from the whole table.
So, we didn't select that wear clause.Let's go right down here and let's look at this salary field.So, I'm going to say where the salary and I'm going to do a different comparison operator called greater than.So, when the salary is greater than 50,000.Now, one thing I want to note before we actually run this is that right down here we have Tom Havford who makes exactly 50,000.And I think there's one more, Jerry Gurgich, which also makes exactly 50,000.If we run this, you'll notice that both Tom and Jerry are not in this output.But in the salary field, everything is greater than 50,000.The reason for that is that Tom and Jerry made exactly 50,000.What we're saying right here is where the salary is only greater than.If we want to include Tom and Jerry, we have to say greater than or equal to.
And now we'll select 50,000 or above.Whereas right here, before when we were doing just this, it was greater than 50.It didn't include the 50,000.Let's go ahead and include it and run this.And now you'll notice that Tom and Jerry were both included because they had exactly 50,000 and we said greater than or equal to.Now we can do the exact same thing but with less than.So we have less than 50,000.And now we only have two people who make less than 50,000.That's April and Andy.And if we say less than or equal to, and we run that, now we include both Tom and Jerry who make exactly 50,000.So it's less than or equal to $50,000.Now what we're going to do is head on over to a different table.We're going to do the demographics table.Make sure I spell that right.
And let's add our semicolon.Let's run this.And what we want to look at is the gender really quick.So we're going to say where the gender is equal to, we'll do in quotes female.And if we run this, we get all the genders that are equal to female.But we do have something called the not equal to.And it looks like this.It's an exclamation point and an equal sign.This is going to say where the gender is not equal to female.So if we run this, you'll notice that the gender is all male.Now, now so far we've worked with things like integers, which are numbers.We've worked with characters or strings like names.But there's a different type of data type as well in here.We have a date column for these birth dates.Now, in the wear clause, we can also filter on birth dates.
Let's come over here and we'll say birth date.Let's say it's greater than and within quotes we'll say 1985-01-01.
This is kind of the standard default date format within my SQL which is year, month and day.If we go ahead and run this, we can also take all the people who are greater than or born greater than 1985.So all of these dates are greater than 1985.Now the next thing that I want to take a look at is logical operators in the wear clause.So logical operators are things like and or and not.Now these are called and let's add this logical operators.So logical operators allow us to have different logic.And let's take a look at how this works exactly.Let's copy this down because we already have this one written out.We're saying where the birth date is greater than 1985.We can also say where the gender is equal to male.So we can say and the gender is equal and then we'll say male.
So we're adding a different complexity or an additional conditional statement within our wear clause.Let's go ahead and run this.So now we're only selecting birth dates that are greater than 1985 and where the gender is equal to male.Only the rows that fulfill both of those are returned.Now the and says both this and this have to be true.But we could change this and we could say or.What this means is is either this one has to be true or this one has to be true in order for it to be returned.So let's go ahead and run this.You'll notice that Jerry Girkitch was born much before 1985.But since he has a male gender, he is in our output.And we could also use the not operator by saying or not gender equal to male.So now what this is saying is the birthday could be greater than 1985 or it could not be equal to male which is female.
So if we look at Leslie nope she was born before 1985 but because she is female she is in the output.Now like we talked about in the last lesson there is something called PEMDOS and that actually applies to these logical operators as well.So, if we run this entire table, let's go ahead and run this.If we're looking at this entire table, let's say we want to get someone very, very specific.Let's say we're going to do uh where the first underscore name is equal to Leslie and their age has to be equal to 44.That's extremely specific.And we can actually just do it like this.We don't need quotes um for integers.We could just do the number if we'd like to.This is very specific.This is only one person.But if we put this in parentheses, we can add an or over here.
We can say or the age is greater than.Let's just do 55.Let's go ahead and run this and then we'll take a look at it.So within these parentheses, we have an and operator.What that means is both this condition has to be met and this condition has to be met.And that's only one person.That's Leslie note.But then outside of these parenthesis, we have another conditional statement or the age is greater than 55.So what we're saying within these parenthesis is that this is an isolated conditional statement.Within these parenthesis, if this is true, then in our output, it'll be returned.But then we have an or condition which says or someone with the age of greater than 55 can also be in the output.So these parentheses can be really helpful when you're actually using it in the wear clause with these and, ors, and nots.
Now, I want to take a look at just one more thing.And let's bring this down here.And let's get rid of this entire thing.Now, the last thing that we're going to take a look at is a like statement.Now, the like statement is super unique because we can look for specific patterns.We're not necessarily looking for an exact match.Like here if we said where first name is equal to Jerry.If we're looking for Jerry it has to be exactly Jerry.But if we take this out say J and then we run it we get no output.It has to be an exact match.But here's where the like statement comes in because we can actually say like jer and we can add two special sequences or special characters within our like statement.So those special characters are the percent sign and the underscore.
The percent sign means anything and the underscore means a specific value.Let's see how that actually works.So what we're going to do is we're going to say like jer percent sign.That's the first one in this like statement.What this says is the first name is like starting with jer but then has anything after it.Doesn't matter what it is.As long as it has jer at the very beginning it will be returned.Let's go ahead and run this.Now the only person who starts with jer is Jerry.But what if I took the j out of here?Now it's saying it starts with eer and that's not anybody.What we can do is we can add another percent at the beginning.This is going to say anything comes before anything comes after.All we're looking for is e rer somewhere in their name.
Let's go ahead and run this.There still is only one person and that's Jerry.Now let's come up here and let's get rid of this and let's say we're looking for everyone's name who starts with a.

16. Essential Excel Formulas

Introduces foundational Excel formulas used constantly by data analysts for calculations and text manipulation.

We can do that really easily by saying a percent sign.All that says is it starts with a.We don't have a percent sign before it, which would say this string just has to have an a somewhere in it.If we have it like this, this means an a has to come at the beginning.Let's go and run this.In our output, we have April and an Andy.Now, let's take a look at the underscore.If we get rid of this percent sign and we do two underscores one, two, this is going to say it starts with an A and then it has two characters after it.No more, no less.So if we run this, an is going to be the only person who's returned cuz she has an A and then two characters after it.Now if we want Andy, we can specify that by doing another underscore.
That's 1 2 3.And now Andy is the only one in our output.Now there was also April in there, but she had more than three characters.But we can actually get her in our output by doing a percent sign.So we can combine both the underscore and the percent sign.And this is going to say it starts with an a has 1 2 3 characters and then it can have anything after that.So it just has to have at least an A and have one two three characters after it.So let's run it.Now you can see April comes into here because she does have a the P, R, and I are the three next characters, but then we have a percent sign that allows that L to be in the output aswell.Now, we don't just have to do this with strings or text like April and Andy.
We could also do this with birth dates.For example, Andy's birth date is 1989.We could say where the birth date is like.Let's say we want to look at everyone who is 1989 or born in 1989.Let's go and run this.And Andy is the only person born in 1989.But again, we looked at the year at the very beginning.So that is how the like statement works.It looks for a specific sequence within that column that you can search for.So it doesn't have to be an exact match as long as it has that specified sequence that you've put in there anywhere within that cell or that column.So that is everything that we're going to look at for the wear clause.In the next lesson, we're going to take a look at the group by and the order by within my SQL.
Hello everybody.In this lesson, we're going to be taking a look at group by and order by in my SQL.Now, when you use the group by clause in MySQL, it's going to group together rows that have the same values in the specified column or columns that you're actually grouping on.Once you group those rows together, you can run something called an aggregate function on those rows.Let's see how this actually works.Let's go ahead and copy this right here.We'll bring that down.And let me go back up one.Let's go ahead and write gender right here.Now, we want to group on this gender column.And we're going to say group by gender.Let's go ahead and run this.We'll see what we get.And so, we have male and female.Now, we could get the exact same output by saying select distinct gender from this table.
What is group by doing that the gender actually isn't doing?Well, it's actually rolling up all of these values into these rows.So later when we run aggregate functions like average, min, max, we'll do it based off of these rows and all those rows are rolled up into these two rows.And we'll see that in a little bit.Now, what if I was to come up here and in this demographics, we have a first name.What would happen if I'm selecting the first name, but I'm grouping by the gender?Let's go ahead and run this.If we come right down here, we pull this up.You can see that the select list is not in group by clause and contains non-aggregated columns.What this means is that when you are selecting a column, if it's not an aggregated column like say average of something, if we're not using the aggregate functions in the select statement, it has to be in the group
by.These have to match.So this gender has to match this group by if we're not performing an aggregate function on it.Let's go ahead and run this.And now it works properly.Now let's go back up.Let's run this query because I want to select everything again.But let's say we wanted to take a look at the average ages for gender.So what we're going to do is we're selecting gender.We're also grouping by gender.But what we're going to do is add a comma and we'll say the average.That's avg.That stands for average.And then we're going to put in here age.So now this right here is an aggregate function.This does not need to go in the group by.We're just grouping on the gender and then we're performing this aggregate function or kind of a calculation based off of those grouped rows for gender.
So let's go ahead and run this and take a look at the output.So what this is telling me is that for the males, all of the male rows that were grouped, the average age is 41, let's say three, and for female, the average age is 38.5.So, super quickly, you can tell that the average age of females is lower than the average age of males.Now, we'll take a look at aggregate functions more in just a little bit.Let's actually go to a different table.Let's come right down here.We're going to go to the salary table and just select everything for now.Let's go ahead and run this.Now, what we're going to actually be grouping on is this occupation right here.Now, there's a lot of unique values.It's um not as distinct as the gender which only had two values.You'll notice we do have a few that are the same.
We have ones like office manager.So when we come up here say occupation.And of course we need to group by the occupation as well.Now let's run this.And you'll notice that office manager only has one row.Let's say we also want to group on the salary.Let's say salary.Now we can group on multiple.So we're going to say salary like this.So we're grouping on the occupation as well as the salary.Now let's run this.You'll notice that we have two rows for office manager.Now this is because this salary and this salary for those two employees are different.We have 50,000 and 60,000.For this I just wanted to demonstrate that if these had both been 50,000 there would only be one row.Office manager 50,000.But because this is a unique value different than 50,000, they have their own individual rows which we would then perform our aggregate calculations on.
Let's go and get rid of that because we will not be using that anymore.I just wanted to demonstrate it really quickly.So before we were looking at gender and average age and we're also grouping on the gender.We can perform other aggregate functions as well.Let's take a look at some of those.We could look at the max age as well.The max is going to show us the highest value within each of those groupings.So we have a male and female.The max age for those for the male is 61 and the highest age for the female is 46.We can do the exact same thing except we can say min or the exact opposite thing.We can say the minimum age.So this is going to be the lowest for both the male and the female.Go and run this.Now we have female and male and the minimum age is 29 and 34.
And there is one last one that I want to show you which is count.We're going to do count.Now count is going to count the actual rows within this age column.So if we run this, you'll see that we have four females for count and we have seven males.It's just telling us a count of how many values is in this column when we're actually grouping on the gender.So that's how we can use group by to actually roll up and group all of these similar values within a column or columns and perform our aggregate functions on them.Now let's come down here and what we're going to take a look at is order by.So we're going to say order by.Now let's actually pull in this demographics table right here.We're just going to say select everything and run this really quickly after we add a semicolon.
So order by order by is going to actually sort the result set in either ascending or descending order.Let's take a look at how this works.At the very end, we could say order by and we could order by the first underscore name.

17. Excel Conditional Logic Functions

Explains IF statements and conditional functions in Excel, showing how to build logic into spreadsheets.

So, we're going to take this column and we're going to order all of our rows based off of this one column.Let's go ahead and run this.So, it's going to do it based off ascending order, which means smallest to largest.Now, this is a text column or a character column.So, we do it A to Z.So, Andy and April all the way down to Tom.Now, by default, this is in ASC order, ascending order.And if we run this, it's going to be the exact same output.But we can change this to do it the opposite, highest to lowest or Z to A by doing descending.So now if we run this, you'll see that goes Tom all the way down to Andy.Now let's take a look at ordering on something like gender and age because we can do both at the same time.
So let's order by the gender first.Let's go ahead and run this.And you'll see that all the females are grouped together and then all the males are grouped together because that's just the order in which it is.But we can do an additional column.We can also do it based off of the age.Let's go ahead and run this.So now within the female since that came first in our order by, we're ordering by the gender and then we're also ordering by the age after we've ordered by the gender.So now it's 29 all the way up to 46.Then 34 for males all the way up to 61.Now we can change this just for the age.Let's say we want to do age descending.So gender will stay the same in ascending order, but now age will be in descending order.Let's go ahead and run this.
Now female and male stayed the same, but now it starts at the highest down to the lowest.Now this is something that I would absolutely do in real life except sometimes you can make mistakes and sometimes you do the wrong column first.Let's do age and then we'll do gender.Now, if we run this, the gender is not going to be used at all.And this is because there are no unique values that are going to be on the same row.So, notice all these values are completely unique.So, the gender never is actually used to order anything on because if there were things like 34, 34, 34, 34, these would be ordered based off of the gender.But since there's no unique fields, this is really pretty useless.That's why the order of the order by or the columns that you place in the order by are actually quite important.
Now, the last thing that I want to show you, and I'll just go back to gender and age, is that you don't actually have to use the column names.We can use the column positions.Now, I will preface this by saying I don't recommend doing this, but I sometimes do it in shorthand for just a quick query.um if I know the column position and I don't want to write out the whole name.So sometimes I do it although it's not best practice but let's take a look at it.So gender is the 1 2 3 4 5th column.So I'm going to replace this with five and age is the 1 2 3 4 column.So these are the positions of the fields but not the names of them.If we run it, we're going to get the exact same output because these represent these columns appropriately.
But again, I just don't recommend it.It's kind of a slippery slope that I've fallen down myself uh many times.And when you get to more advanced SQL and you're creating things like store procedures and triggers and all these things, this can actually cause a lot of issues.If you were to add any columns or remove any columns, then you'd be ordering by the wrong column because let's say this last name got removed.We didn't want it for some reason.Then the gender is 1 2 3 4.Now we're ordering on the wrong column and that would be a big mistake.So just by best practice, it is better to do gender, age, but I just wanted to show you that in case you want to be like me and kind of go down the wrong path.Uh so that is everything we're going to take a look at with group by and order by.
In the next lesson, we're going to be taking a look at having versus where.
Hello everybody.In this lesson, we're going to take a look at the difference between having and where.Now, in the last lesson, we looked at group by and order by.The most obvious thing to do would be to come right here and say where, and we're going to say this column, which is actually named this.We'll say where the average age, let's say, is greater than 40, which would only be the males.So, let's go ahead and run this.And as you can see, we're not getting any output.Let's bring this up and take a look at the error.It says invalid use of the group by function.What's actually happening is something to do with this group by gender right here.When we're selecting gender and then we're performing an aggregate function, this occurs only after the group by actually groups those rows together.
So when we're trying to filter based off of this column right here of average age, it really hasn't been created yet because this group by hasn't happened.That's where the having clause comes into play.So let's go ahead and what we're going to do is we're going to get rid of this.We're going to come right down here and instead of where we're going to say having.Now having was specifically created for this exact example.It comes right after group by.And after group by we can filter based off of these aggregate functions.So now if we run this, we're going to get an output that only has where the average age is greater than 40.Now let's take a look at just one more example.And I'm going to show you how you can use both in one query.So instead of demographics, let's look at the salary table.
And let's run it.Now in this salary table, we have this occupation.And remember, we have this office manager that happens twice.And this is going to be our main example.So we're going to say occupation.And then we'll say the average salary.Now we'll need to come down here and we'll say group by.Now we're going to say occupation.So this should look pretty similar because right here we have our office manager and one of the office managers made 50, one of the office managers made 60.So the average is 55,000.Now I can use the where by saying where.Then I'll say occupation like and let's see people who are managers.So I'll say percent manager percent and close that quote.So they're like a manager.And then I want to see where a manager makes more than let's say 75,000.So I won't actually say where.
I'm going to say having an average salary.And I need to add a space there.Having an average salary greater than let's say 75,000.And let's run this.So now I filtered at the row level right here in the wear clause.But then down here I filtered at the aggregate function level.This having is only going to work for aggregated functions after the group by actually runs.So that is the difference between the having clause and the wear clause.The wear clause you're most likely going to use a lot more.But if you do want to filter on those aggregated function columns, you have to use the having clause.I hope that that was really helpful.And in the next lesson, we're looking at our very last lesson in our beginner series.We're going to look at limit and aliasing.
1:38:33 - 1:39:23
Hello everybody.In this lesson, we're going to be taking a look at limit and aliasing.Limit is just going to specify how many rows you want in your output.If we take this table for example, if we come right here and we say limit, let's do three.If we run this, it's only going to take the top three that we have.Let's go and run this.As you can see, we have employee 1, three, and four, Leslie, Tom, and April.Now, this seems super straightforward, really, really easy, but it can be combined with order by to actually be really powerful.For example, let's say we wanted to take the three oldest employees.All we'd have to do is come right under here.We say order by, and we'll order by the age in descending order.So we're going to order on age descending and then it's going to take the top three.
So if we run this and very quickly we have the top three oldest people in this table.Now there is one additional parameter that we can use in limit and all we have to do to access it is have a comma here.Now what this is going to do and I'll put a one here.What this is going to do is it's now going to say we're going to start at position three and then we're going to go one row after it.Now, I actually want to take one of these people.So, let's start at position two and select the next one after it, which should be Leslie.Nope.So, we're going to start at position two, and we're going to select the one right after it.So, we're going to start at position two, and then one means we're taking the next one row.
Let's go ahead and run this.And as you can see, we got Leslie nope in our output.Now, let's come right down here.We are going to now look at aliasing.Now, aliasing is just a way to change the name of the column for the most part.And it can also be used in joins, but we're going to take a look at joins or aliasing joins in the intermediate series.In a previous lesson, we looked at a group by that looked like this.We selected gender, then we said from I believe it was employee demographics.

18. Excel Lookup Functions

Covers lookup functions in Excel for searching and retrieving values across tables and ranges.

Then we said group by gender.And we also had the average and I think it was age.There we go.And we'll add our semicolon.Let's go ahead and run this.In our output, we have gender as our gender column, the same as the column name.But then average age is average age.And so if we want to actually do something like a having where we say having the average age, let's say greater than 40 like we had it.we have to actually use this aggregate function in our having clause and we don't want to always have to do that.We can actually change the name of this column and subsequently use it throughout our query with that alias name.So I'm going to say as and that's the keyword to actually change it.We'll say as and we'll do average age.So now we've changed this name to average age and we can come down here to having and say having the average age greater than 40.
And when we run this it works perfectly.And you'll notice that the name of the column was actually changed.Now this as isn't actually 100% needed.It's kind of implied.Even if we get rid of it, it's implied there's like this as in there somewhere.Um but we don't have to have it.If we took it out and ran it like this, it would still work exactly the same.So that is how we can use limit and aliasing in SQL.And congratulations, this is the end of the beginner series in my SQL.In the intermediate series, we're going to take a look at things like joins, unions, case statements, subqueries, and window functions.
Hello everybody.In this lesson, we're going to be taking a look at joins.Joins allow you to combine two tables or more together if they have a common column.That doesn't mean the column name has to be the exact same, but at least the data within it are similar that you can use.There are several joins that we're going to look at today like inner joins, outer joins, and self joins.These are the two tables that we'll be working with the most throughout this lesson.We have the employee demographics table as well as the employee salary table.Now, within the employee demographics table, we do have this employee ID column.And if we look at the employee salary, we also have the employee ID column.So, in this instance, the column name is actually the exact same.And of course, the data inside of it is also very similar.
So let's start by writing out an inner join.This is probably one of the most common joins, one of the most simple joins as well.An inner join is going to return rows that are the same in both columns from both tables.So let's see how we can actually write out this join.Let's come right down here and let's copy this.This will be the first table that we start with.And then we'll join the salary table onto this demographics table.So what we need to do is we need to come right here and we need to say join.Now by default join represents an inner join although we can write inner join here to make it more explicit explicitly writing out inner join.Then we're going to come up here and we're going to say employee salary.So we're selecting everything from the employee demographics and we're doing an injoin on the employee salary.
Now we have to tell my SQL exactly what columns we're supposed to be joining on.I'm going to hit enter and I'm going to hit tab.Now, you don't have to hit tab.It just looks more codelike and it's easier to read.And that's how I've done it for other programming languages as well.So, that's how I'm going to show you how to do it.What we need to do is say on.Now, this keyword is going to allow us to say we're joining the demographics table to the salary table based on these two columns.So, from the demographics table, we're doing the employee ID is equal to and then in the salary table, it's also the employee ID.Let's do employee now and you spell it right.Employee ID.Now, if we try to run this and let's do this, we're going to get an error.
And let's bring this up.It's going to say column employee ID on the in clause is ambiguous.Now, what does it mean ambiguous?That means that it doesn't know what table this employee ID is from.Is it from the employee demographics table?Is it from the employee salary table?We don't know because it's ambiguous.Now what we can do is we can specify it by saying employee demographics dot employee ID and then employee salary do employee ID.Now if we run this we're going to get the output that we're looking for.And let's take a look at this real quick.Let me bring this up.So we're pulling everything from the employee demographics that's right here all the way through the birth date.Then we're pulling the employee salary table.That's the employee ID all the way.Let's scroll over through the department ID.So, we're basically pulling in all of the rows or all the columns from both tables, but we're not pulling in all of the rows.
Remember, an interjoin is only going to bring over the rows that have the same values in both columns that we're tying on.So, in this employee ID, we're missing number two.Are we missing any other ones?No, we're only missing number two.Let's go back up and I'm going to run both of these tables and we're going to take a look.So, let's run this.So, you'll notice in the employee salary table, we have a number two right here and that's Ron Swanson.But in the employee demographics table, we don't have that.I believe that Ron Swanson did this that Leslie Nope would not know when his birth date was because he didn't want to bring that information.I think that makes the most sense.Although Ron was not willing to give a comment on that.Now, if we run this again, you'll notice that two is not in there.
Since two is not in the employee demographics table, the employee ID 2 is not going to be populated or brought over into this output from the employee salary table.Now, really quickly, this is honestly uh giving me some anxiety because this is so incredibly long.Something that I mentioned in the beginner's series is that you can use something called aliasing when using joins and it's really helpful.This is what I mean.So right here we have employee demographics.We're going to call this DEM.You can also do as DEM.You can do as SAL.These are just short names for demographics and short name for salary.And we can replace these and say DEM.mp employee ID and SA.mployee ID.Oh, that looks so much better.Now, we're going to run this and it'll be the exact same output, but now we're using these aliases, which just makes it so much easier to read.
Now, one last thing that I want to show you while we're just looking at the inner join is selecting the actual columns.Let's say we wanted to select the employee ID and we wanted to select age and then we wanted to select their occupation.If we try to run this, we're going to get an error and it's going to be almost the exact same error that we got before, which is column employee ID in field list is ambiguous.So in our field list, which is right up here in the select statement, we have this employee ID.It does not know which employee ID to pull from, whether it's the demographics or the salary.So we have to tell it which one to pull from.So let's pull it from the demographics by saying DM.PMP employee ID.Now when we run this, we're able to get information from both tables in our output without having all of the information.
And if there are columns that are similar in both tables, we have to denote that by using this alias or the table name.All right, so that is inner joins.Now, let's move down here.I'm going to copy this and we're going to come right down here and we're going to look at outer joins next.And let's put that right here.Now for outer joins we have a left join and we have a right join or a left outer and a right outer join.A left join is going to take everything from the left table even if there's no match in the join and then it will only return the matches from the right table.The exact opposite is true for a right join.Let's see how this actually works.Let's start by changing this to a left join or a left outer join.They're both the same and you can use them uh similarly.
I'm just going to say left join and we're joining it on the exact same things and I'm going to take everything because I think that'll be easier to visualize and I'm going to run this.Now you may notice that this looks exactly the same and that's for a very good reason.It's because in the left table which is the employee demographics table the from statement that's our left table and then the join where we're actually joining on that's our right table.So this is our right table.So since we're doing a left, it's taking everything from the employee demographics.Now remember, the employee demographics didn't have Ron Swanson.It had no information.So everything in the right table had a match.Let's change this to a right join.And what this is going to do, and I want to make it all cap, make it all the same.
What this is going to do is it's going to take everything from the employee salary table, but if there is not a match in the employee demographics, it just will have nulls.Let's go ahead and run this.So now it looks a little bit different.Now we're taking everything from the employee salary.So we're taking Ron Swanson, but if there is not a match, it will still populate that row, but it'll have all nulls in it.Then any of the information that is overlapping or the same, it will bring over.

19. Excel Pivot Tables

Teaches how to build and use pivot tables to summarize and analyze large datasets quickly in Excel.

So employee ID is matched to employee ID 1.Then we'll bring all that information over from the left table.And that's essentially what a left and a right join is.With a left table, you're taking everything from the left table and then matches from the right table.If you do a right join, you're taking everything from the right table, but only matches on the left table.And again, it populates it with nulls.Now, let's go down and look at our last type of join that we're going to look at.And this is a self, let me spell that right, a self join.Now what is a self join?It is a join where you tie the table to itself.Now why would you want to do this?Let's take a look at a very serious use case.Let's do select everything.Let's do this from uh employee salary and let's run this.
Now, let's say it's December 1st and the employee and Rex department decided to do a secret Santa and they wanted to assign based off of their employee ID the person who they're going to have as a secret Santa.We can help orchestrate this very easily using my SQL.Well, very easily is subjective, I guess, but let's take a look at how we can do this.So, just like any other join, the first thing we're going to do is select everything from employee salary and then say join.And then we're going to say employee salary again.So we're tying it to itself.Now when we come down here and let me do this.When we come down here and we say on, we have to specify which table we're pulling from.Are we pulling from the left table which is like the first table we're pulling from?
Are we pulling from when we're joining on the right table?We need to be able to distinguish these two tables because they are the same.So, I'm going to say EMP1 and I'm going to say EMP2 just to say this is employee table one and employee table 2.So, we're going to tie them based off the employee ID because we know those will be the exact same because we're pulling from the same table.So, we'll do emp1 employee.And just so you know, if it populates like this, you can hit tab and it'll auto uh finish that for you.and emporid.
Now, if we run this, let's do this.The output that we're going to get is literally just a one forone match.It's all the columns and all the rows because they all match exactly.But now what we're going to do is we're going to assign an employee ID to the next employee ID and that will be their secret Santa.So, just keep it really simple.The next highest person with an employee ID, that is their secret Santa.So let's do an employee ID + one is equal to employee 2 employee ID.So we're adding one over here and we're saying that's equal to this employee ID over here.Let's run this.So now you can see Leslie Nope is now going to be assigned to Ron Swanson who has an ID of two.Ron Swanson is going to be assigned to Tom Havford which I'm sure he's really happy about.
and so on and so forth.Now, let's bring this down here.And what we're going to do is try to simplify this and simplify this output a little bit because this is a little bit chaotic down here.So, we're going to specify what columns we want in our output.What we're going to want is the employee ID, first name, last name, and then employee ID, first name, last name of the person who they got for Secret Santa.So, we're going to start with emp1.mp employee employee id and we can call this we'll just say as emp Santa then we'll do a comma and we'll come down now I need to spell employee right so we haveour employee ID and now we need our first name and last name now remember Leslie nope is going to be the secret Santa for Ron Swanson I don't know if I made that clear but that's I guess how
it works so now we need to do uh emp1 one dot and we'll do first_ame and we'll do as we do as first_ame Santa.We can do a comma.We'll do the exact same thing except for the last name.So last_ame
last name Santa.Now all we have to do is do a copy all this bring it down here and change this to two.They're pulling from the second table.And it'll look just like this.And get rid of this comma.And this is done.Let's run it.And let's bring this up.So we have employee Santa, first name Santa, Leslie, last name Santa.Nope.Then employee Santa.And we actually need to change these names.That is one thing we need to do.We'll just change it to employee name, first name, employee, and last name employee.And now when we run this, we have our Santa.And then we just have the employee who this person is going to be the Santa for.Now, this is kind of a silly way to look at it, but in essence, this is exactly how a self join works.
Now the very very very last thing I promise you the last thing that I want to show you is how we can join multiple tables together.So we're going to say joining multiple you spell that right multiple tables together.Now not just one table together to another table.I'm talking about one table to another table to another table.So let's go all the way back up.We're going to take this right here and bring it all the way down.And what we're now going to do is we're going to tie in this table right here, the parks department.Let's actually look at this table and let's select everything real quick and let's run this.Now, let's go down here and we're going to say select everything.We'll do this from park departments and let's run this.Now, this is something called a reference table.This is not a table that most likely you'll ever add a bunch of information to.
It's there to reference that we have these department names.Tables like the salary table or employee demographics table are going to change pretty often as people get raises or as they get older with their age.Those are going to be updated fairly often.Whereas this parks department table is just there for reference.Now, if we look down here in the columns, we have a department ID.Then we have a department name.So, we have the ID and the name of that ID.If we run our join and we scroll all the way to the right, you'll notice we have a DPT ID.This stands for department ID that's in the salary table.So, what we want to do is join this department ID to the department ID from the parks and wreck.So, what we can do is we're going to say inner join.And now we're going to join.
Let's scroll down just a hair.There we go.Now, we're going to take this and do it off this.So, we're going to call this PD for short and we're going to say we're joining it on.Now, we cannot join this parks department to the employee demographics table.Why is that?Well, the employee demographics table only has employee ID all the way through birth date.There's no common column that we can tie to this parks department.The only table that has a common column is this department ID in this salary table.So what we need to do is actually take S.So we'll say SA dot and then we're going to say DP and we'll say department ID is equal to the PD dot and we need to take the department ID.Now notice these are not the exact same name.They are a little bit different but they have the same values.
One thing I forgot to mention is that in this parks department there's no repeating.That's why it's a reference.Whereas in the salary, the department ID repeats several times because multiple people are in the same department.So this reference table also usually does not have duplicates.Uh just one other thing to note, but we have now tied it successfully.Let's try to run this.And if we come down here, go all the way to the right.We now have the department ID 11111 and the department ID and department name.Parks and recreation, healthcare, public works, finance, public works, and parks and recreation.So this worked perfectly.So this is how you can tie multiple tables together.If you have common columns between them, even though employee demographics has no column that's related to the parks department table, we can still tie them together based through this employee salary because employee demographics can tie to employee salary.
Employee salary can tie to the parks department.And that really is the majority of what you need to know in order to use joins.Well, now in the next lesson, we're going to be taking a look at something called a union.
Hello everybody.In this lesson, we're going to be taking a look at unions in MySQL.A union allows you to combine rows together, not like columns like we were doing before with joins where one column is next to the other.A union allows you to combine the rows of data from separate tables or from the same table.It's up to you.But you do that by taking one select statement and using a union to combine it with another select statement.Let's see how this actually looks.So what we're going to do is right after this select statement, we're going to come here and say union.Then we're going to go right below the union and we're going to do another select statement.So we're going to copy this, place it right here.But instead of the demographics table, just for example, we'll do the salary table.

20. Excel Charts and Visualization

Shows how to create charts and graphs in Excel to visualize data and communicate insights effectively.

Now, if we look at the demographics table, let's say we want to take age and gender.And let's go and take a look really quickly at the salary table.And let's say we want to take first name and last name.So, we'll do first_ame and last_ame.Now, let's go ahead and run this and see what it looks like.And let's pull this up.So, as you can see, we have age and gender.That's from the very first select statement.And that's also the column names.But then we have all of the data for the age and gender.And then below, if we move this over a little bit, we have the last name and first name from the employee salary table.It's just down here.Now, what I just demonstrated is that this doesn't always work for everything.You can't just combine random data together because this is bad data.
We shouldn't have age and gender mixed with first name and last name.Really, when you're using this, you need to keep the data the same.So, for us, we should take the first I'll actually just copy this.The first and last name from the employee demographics as well.And let's run this.And now we have all the names from all of the tables.Now, you may be thinking, where did all the other data go?Before we had a lot of rows, but now we only have a unique row for each one.Well, by default, this is actually a union distinct.And if you remember, distinct is only going to take unique values.So when we're doing this, union is going to remove all the duplicates.And the first name and last name from salary overlaps a lot with the employee demographics table.So when we ran this, the only one that's actually somewhat unique to one table is that in the employee salary table, we have Ron Swanson, whereas we don't have that in the employee demographics.
Now, if we wanted to show all of them without the distinct, there is something called a union all.If we run this now, we're going to get all of the results without removing any of the duplicates.So, if we scroll down, we're going to have duplicates in here, but we're just showing all of the results from this table and from this table.Now that we know how to actually use a union, let's look at a use case.So, let's go right down here and let's copy this.Why not?and let's put it right down here.Now, let's say in the employee demographics, we wanted to take the first name and last name where the age is greater than 50.And let's run this.So, there's only one person, but let's label them.Let's add a label.We're going to say, comma, old.So, this person is old.
And if we run this, it says first name, last name, and old.And we can even call this as label.And if we run this, the label is old.So Jerry Giritch, he's the only old person in this demographics table.Now, why are we doing this?Well, the parks department is trying to cut their budget a little bit.They want to identify older employees that they can push out.And they also want to identify high paid employees who they can reduce their pay or push them out to save money.So, we just identified someone who's older who are going to want to try to push out.But let's in the same output find people who are also highly paid.So now we can come down here.We can say union and let's do this like this.I need to spell this right.All right.Union and let's take this.
We're not going to be using this exact same query, but we actually need to pull from the salary table.So the employee salary.So we also want the first name and last name.But let's say where their salary is greater than let's say 70,000 cuz that's a lot of money.If you're making more than 70 uh for sure the parks department is going to try to get rid of you.But for the label we're going to change it to a highly paid employee.Now let's go ahead and run this.So now we have Leslie Nope and Chris Trager.They're both labeled as highly paid employees.Now 50 I think is just a little too low.Um if I'm being completely honest, I think we need to change this and we should do a union and then add another select statement.Let's bring this down.I think the 50 is too low.
Let's change it to 40.And let's add one more thing.Let's say and the gender is equal to male.And then we'll go down here and say where the gender is equal to female because we want to separate this out.So we want to know who's the old man.Oh, that's actually old lady.This is the female one.And for up here where it's male, we'll say old man.So we have three different select statements using two separate unions.We're selecting the first name and the last name in all of them, keeping the data consistent.And then in our third column, we're labeling it either old man, old lady, or highly paid employee.Let's go ahead and run this.And let's look at our output.Now, you may notice something really quickly that Chris Trager and Leslie Nope are an old man and an old lady.
And Leslie Nope and Chris Trager are both highly paid employees.So, these people meet multiple criteria.Yeah.So, let's actually order by and then we'll do first_ame, last name because we want to order by these to see.So, let's run.And now we can easily see that Chris Trager is both of these.Donna is just an old lady.Jerry's just an old man.And Leslie is both an old lady and a highly paid employee.So, now we can send this to whoever we need to send it to to make sure that these people get looked at first so that our job is still secure.The job market is tough these days.You got to do what you got to do.So that is how we use union.And let's just take one more look at it.There we go.So this is how we can use unions.
It's kind of a real use case.I've done something very similar to this in my real job, but you know, this is just an example of how you can have multiple select statements all combined or combining the rows using a union.In the next lesson, we're going to be taking a look at case statements.
2:07:01 - 2:07:55
Hello everybody.In this lesson, we're going to be taking a look at string functions.Now, string functions are built-in functions within MySQL that will help us use strings and work with strings differently.Now, we're going to look at a ton of different ones.They all have different use cases, but I'll try to walk through some of those as we go along.But we'll look at a lot of different string functions in this lesson.We'll start off with one that's really simple.This one is called length.So, if we select and then we say length and let's say we put in and I don't know why it's popping up like that.Let's say we put in something like sky or skyfall or really anything.If we run this, it's going to give us the length of how long this string is.So, if I come down here and we say select everything from employee demographics and let's add a semicolon here.
Let's run this one right down.Now, what we can do is we can look at how long each person's name is.What we can do is just take the first name, but then we'll also do the length of the first underscore name.So if we run this now, we get Leslie, Tom, Jerry, Donna, and it gives us the length of their name.If we wanted to, we could even order by this.So we could do order by, and we could just do two for now.And we can order by the length from the shortest name all the way to the longest name.Now, one use case that I've used length for in my actual job was when I was working with phone numbers.I wanted to make sure that they were exactly 10 characters long.Otherwise, something went wrong somewhere in the data cleaning process.
So, I would go and look at the length and I would make sure they're all 10.And if any were above 10, I would go and specifically look at those and try to clean those and fix those up.Now, let's go on to the next one.And these next ones are pretty simple ones.At least I think they're fairly simple.We're going to look at upper first.And it's doing the same thing as the other one.We'll do upper.And let's say we're going to do sky.

21. Cleaning Data in Excel

Demonstrates how to clean and prepare raw data within Excel using built-in tools and formulas.

If we select upper sky, it's going to give us an all uppercase.Or we can copy this and we can do lower.So now let me add semicolons otherwise it's going to drive me crazy.Uh let's try this lower.Now it's going to do all lower even if I make it all capital.So if I say all capital sky, it's going to make it all lower.So if we come back up, let's copy this and instead of doing the length now we'll do upper.Let's go ahead and select this.So we have Leslie and then we have the upper first name.So upper allcase Leslie.Now this is actually really good.This is really helpful especially with standardization is what I found a great use case for it because sometimes it'll be all capital tom and sometimes I'll put it in as T lowercase OM.
uh and just making them all uppercase or all lowercase can help correct those really simple standardization issues within a single column.The next one that we're going to look at is trim.Now there's multiple trims.We have trim, left trim, and right trim.Trim is basically going to take the white space on the front or the end and get rid of it, which is really really helpful.So what we're going to do is we're going to come right here and say select and we'll start off with trim.And let me add a semicolon every time.So then we'll do trim.And for our actual string, we'll do something a little bit odd.We'll do some spaces.And then we'll do sky.And then we'll add some spaces.Let's run this and add our semicolon.That's going to be the end of me in this lesson.
I was just adding semicolons.Now it fixes it completely.Now, what if we don't add sky at all?We'll just keep it like this.Well, you can see that there's spaces before and there's spaces after.But that's what trim does.trims gets rid of the leading and the trailing white spaces.Now, if we come up here and we just do the left trim, it's only going to remove from the left hand side.So, we're only getting rid of the left-hand side white spaces.This right hand side, as you can see, is really long.It's still there.And if we do RT trim, we go ahead and run this one.It gets rid of the white space on this side, but it doesn't get rid of the left space on this side.Now, let's keep going.We have a lot to cover still.We're going to move on to what I think is probably my most favorite string function if I'm allowed to have a favorite string function and that's substring.
But I'm going to kind of work us into substring a little bit by looking at two smaller functions which is left and right.So let's select everything and we'll do that from the employee demographics again.Let's add our semicolon.Now I'm going to run this.Now I want to get the first name and I'm going to do left of the first underscore name just like this.Now when you're using this is actually going to be an error.Let's see if I highlight over this if it'll tell me what the error is.It says the parenthesis is not a valid position.They're expecting something else.And basically what they're telling us is that this is not how it should be written.We're looking for a different value.That different value is actually a number.We're going to do comma and let's do four.That's what it was looking for.
It didn't want this at the end.It needed this comma four.And what we're actually specifying is how many characters from the left hand side do we want to select.So we're selecting the first name and we're going from the left four characters.Let's go ahead and run this.And so we have Leslie, Tom, April all the way down.You can see that there's only four characters in each one.So, someone like Chris, the S is no longer going to be there because we're only looking at the first four characters.Now, we can do the exact same thing.And let's actually copy this uh down here.So, we'll come we'll go like this.Try to make this a little more professional and we'll do right.So, now we'll do right.If we do the right four, it's going to go from the right hand side of the string and go left four.
So, we're looking at the far four for most right characters.Now, this can be useful in certain instances, but if I'm being honest, I don't use these that much.For the most part, I'm pretty addicted to using substrings.I love substrings.I think they're fantastic.And let's look at substrings like this.So, a substring is going to allow us to do a few different things.Let's do first_ame.The second thing that we put within this function is the position that we want to start at.So let's say we want to start at the third position.And then we specify how many characters we want to go.So with this we specified four, but let's just do two.So now we're going to the third position and we're going over to the right two characters.Let's go ahead and run this.So with Leslie we get SL.
So we go 1 2 and three.We start at the third position and then we take two characters, the S and the L.I have found this one to be extremely extremely useful.Let's take this for example.Let's do comma.Let's do birth date.And let's run this.I'm keeping everything in here.Although it might be a bit much, but let's say we have this birthday.And this middle column is the month.And we're running some, you know, query.We want to find the month that everyone is born.So we can do that very easily using substring and we wouldn't have been able to do this very easily using left or right.So now we're going to take this birth date and we're going to use the substring and we want to select these middle characters.So what we need to do since it's all standardized we do 1 2 3 4 5 6.
We start at position six and we want to select one and two.Let's go ahead and run this.And now we've pulled out all of the months.So we can say as birth_mon month and now we could save that put it into a temp table add it as a new column in our table whatever we want to do.Uh but now we have this information that we desperately desperately wanted to know.So that is left right and substring.Again substring is it's fantastic.Now let's keep going.The next thing that we're going to take a look at is replace.Now replace will replace specific characters with a different character that you want.So, let's actually copy all this right here because I don't want to keep writing this out.And we'll say select everything.Now, what we're going to do is we're going to take the first underscore name and then we're going to say replace.
And then we'll also do the first underscore name, but we can specify what we want to replace and then what we want to replace it with.So, we have two more parameters that we need to put in this function.So let's say A and let's replace it with a Z.Let's just see what that does.Let's go ahead and run this.And so now when we see the letter A and we are specifying a lowercase A like mark that is replaced with a Z.So that's really all replace does.It specifies what you want to replace and then what you're going to replace it with.Now let's take a look at the next one and we're going to take a look at a function called locate.So, if I say select and let's do locate.I'm going to give it a string.I'll say Alexander.
That's my name.And I'm going to specify what I'm looking for.So, let's close this parenthesis.The string that we're actually looking for comes first.So, what we're going to do is I'm looking for the letter X in my name.So, we'll do X and Alexander.Let's go ahead and run this.

22. Excel Analysis Project Walkthrough

Puts Excel skills together in a hands-on project, from raw data to cleaned dataset and final insights.

And it tells us that it is in position four.So, we have one, two, three, and four.That's where our position is.That's where it locates that sequence that we're looking for.Now, if we pull this down here, place this right here, and we'll change this locate.Now, let's say we're still looking at the first name, but we want to locate people that have an a like this in their name.Let's go ahead and run this.And we get zeros for everybody except for an andy.So, this might be something where we put it into a CTE or a temp table.Then we can filter down based off of these results to where it only equals one.Now the last one that we're going to take a look at and let's go right here.We're going to do first name last underscore name.Now this one is super super useful because what we can do is have a concatenation of multiple columns.
So let's go down right here.So we have first name and last name.But if we come down and we say concat, we can then combine these columns into one single column.So we'll do concat.It'll do first underscore name and then comma last underscore name.And if we run this, it's going to be Leslie and nope combined into Leslie nope.Now this doesn't look perfect, right?We don't want it to look like that.All we have to do is come in here and we could do a little space.So we'll add a space in there.And if we run that now we have Leslie and nope.And we could call this as full_name.And this is something that I've done a million times in my real job where there's multiple columns.We want to create one column out of it or take two columns and create one column.
Happens all the time.So this concat is really really helpful to combine those columns really quickly.So that is all we're going to take a look at in this string functions lesson.In my full course you can find in the description below.I also have lessons on numeric functions, date and time functions, converting different data types, all in the functions module.
Hello everybody.In this lesson, we're going to be taking a look at case statements in MySQL.A case statement allows you to add logic in your select statement.Sort of like an if else statement in almost all other programming languages or even things like Excel.Let's see how this actually works.So let's bring this down and let's take this employee demographics table and let's take the first name and let's take the last name and let's add a case statement.How we need to do this is we have to say case.So that's going to signify that we're starting a case statement.And then I'm going to go over here and say tab.So this is where our logic comes into play.So I'm going to say when the age let's say is less than or equal to 30 then so I'm saying if the age is less than or equal to 30 then what's going to happen?
We'll just keep it really simple for now.We'll just say that this person is young.And then if we want to end the case statement, we'll come down here and say end.So this is a complete case statement.Let's go ahead and run it.And let's take a look at the output.So we have the first name, we have the last name, and then we have this case statement right here.And if their age is less than or equal to 30, they're young.Let's actually add the age right here just so we can visually see that as well.So we have the age.So this person is the only person who's under or equal to the age of 30.That's April.So, she has a label of young.The great thing about case statements is you can add multiple when statements.So, we can come down here and say when.
And then we can do something like when age and maybe we'll say between.So, I don't know if in previous lessons we've looked at between, but between just says between this number and this number.So, we'll say between 31 and 50.If they're between 31 and 50, well, good night.uh that person is old.So, we're going to have it just like this.We're going to run it.And now we have a lot of people who are old.These are all people between the ages of 31 and 50.But we still have more people outside of the age of 50 or older than 50.So, we could do when the age and now we can say greater than or equal to 50.and we're gonna say then and then we're gonna say on death's door.Uh because good night if you're over 50, my parents are gonna love me for this one.
So let's go ahead and run this.And then if we look at this, we have on death store right there.Now this is huge.This is massive.So let's actually name this and we'll just say as at the end of end, so right after end, we'll say as age uh bracket and let's run this.And this looks a lot better.So now we have this age bracket just signifying kind of where people are at.And most people are quite old.Poor Jerry.Uh you know, can't catch a break that guy.Now let's go down and let's take a look at a different table.So let's select everything.We'll do from employee salary.Now that we have our employee salary table, here is the scenario that we are given.The Pawne Council sent out a memo of their bonus and pay increase for end of year and we need to follow it and determine people's end ofear salary or the salary going into the new year and if they
got a bonus how much was it.So the first thing we need to do is we need to get the pay increase and bonus and their pay increases look like this.So, if they made less than 50,000, then that equals a 5% raise.Very generous.And if they made greater than 50,000, that equals a 7% raise.Very, very generous.Lastly, if they work in the finance department, that equals a 10% bonus.Just cash that goes into their bank account.Very, very generous, but only the finance department gets it.So, these are the guidelines that the Pawne Council sent out and it is our job to determine and figure out those pay increases as well as the bonuses.So, let's come right down here.We're going to have our salary employee.I actually want to be able to see these.Let me pull this up just a touch.
There we go.So, we want to be able to write this out.So, first thing we should do is just select the columns that we need.First name, last name, probably salary as well.And now what we can do is determine this first one which is if they make less than 50,000 they get a 5% raise.So let's say case and I'll also add uh end in here and we're going to say when their salary is less than 50,000 what's going to happen then we say then salary.So, we're taking their initial salary and we're saying plus then we're going to do salary times 0.05.And if we run this should work.Let's pull this up really quickly.So, April Lgate, she made under 50,000.So, she got a raise and her new salary is 26,250.We could actually call that.We'll say uh as a actually let's do new salary because that's their new salary.
And let's run this.So the new salary is 26,250.Andy Dwire is now making 21,000.Now this calculation you can do it different ways.We could do it exactly like this or we could just do times 1.05.Should be the exact same thing.Uh just however you would like to write it out.it's just you know adding it or multiplying it by this.So let's take this and now we're going to say when it is greater than 50,000 so let's say greater than 50,000 they get a 1.07.So this is the 7% increase.This is a 5% increase.This is a 7% increase.And let's run this and let's put this up here.So now if they made greater so 50,000 that's 75,000 they got a 7% increase.Now unfortunately we did not make the rules the Pawnie Council did and the people who made exactly 50,000 unfortunately were not part of those brackets.
Uh and that just wasn't up to us.We couldn't control that.So unfortunately Tom Havford and Jerry Gurggic just didn't get races this year.And that's not our fault.

23. SQL Introduction and Setup

Begins the SQL series with what SQL is, why it is essential for data analysts, and how to set up a database environment.

Okay.That's not our fault.Now, the next thing that we need to do is determine the bonuses.Now, let's come right back up here really quickly and let's just copy this because what we need to determine is how we know that somebody is in the finance department because if they're in the finance department, that meansthey get a 10% bonus.That's really important.Now, it's not in the employee demographics.We don't have anything about the department.But if we look in the salary and we run this, we do have the department ID.Now, let's open up and let's pull this up right here.We'll look at the parks department.And in the parks department, here we go.The finance is department ID of six.So if we're looking at the salary, there's only one person who's in uh department ID equal to six.So what we can do is another case statement.
We can say comma we'll do case and end and we'll do another one.We're going to say when dep so when the department ID is equal to six, then we're going to give them a bonus.So, we're going to say salary times.10 and we'll call this as bonus.Let's go ahead and run this and let's pull it up.So, he gets a $7,000 bonus this year.That's Ben Wyatt uh because he was part of the finance department that just did uh an exceptional job this year apparently according to the Ponyie Council.So, that is how case statements work.They're really powerful, really useful.I honestly use them quite often and they're just a way to really add some logic and some, you know, labeling or even do calculations like we did right here with the salary.In the next lesson, we're going to be taking a look at sub queries in MySQL.
Hello everybody.In this lesson, we're going to be taking a look at sub queries in MySQL.Now, subquery is basically just a query within another query.We can do this in a few different ways, and I'm going to try to show you a lot of the different variations within this lesson.The first way that we're going to use a subquery is in the wear clause.Then, we'll take a look at the select and the from clause.Also, let's take this demographics table that we have down here.What if we only wanted to select the employees who worked in the actual parks and recck department?Well, we could do that if we had a few joins.We have this salary table and one actually represents that they work for the parks and wreck.If we come over here and we open this up, we can see that parks and wreck is the department ID of one.
So, we do have that option.We could just join these two tables together.But sometimes we don't want to do that and we'll use a subquery.Let's see how it works in the wear clause.So, let's go ahead and get rid of this.So what we're going to do is we're going to say select everything from employee demographics where and now we want to pull because this is the salary table.We want to pull employee IDs where the department ID is equal to one.But remember we're querying off of this table.So let's actually pull this up.This is what we're working with.So we want to say where the employee ID that's referencing this column in the demographics table is in what we're going to do is we're going to do a parentheses here and we can even come down and puta parenthesis down here.
So what we're going to do now is write our query which is our sub query and this is our outer query.So now we're going to write an entirely other query within this.So, we'll say select.And now we're going to say employee id.And let's just bring this over.I usually have it something like this.And I'm going to try to bring this down a little bit.So, select everything.And then we'll do from and then instead of employee demographics, we'll do employee salary.And let's just format this a little better.So, select the employee ID from employee salary.And remember we wanted to do where the department ID is equal to one.Now let's bring this back up.And this is what the query is going to look like.Now just by itself, let's run this subquery or this inner query.When we run this, it's going to create this list of just employee IDs where the department ID is equal to one.
So when we say where the employee ID from the employee demographics table is in, it's going to try to match those employee IDs to this list of employee IDs.So just remember 1 2 3 4 5 6 and 12.Let's go ahead and run this entire query.Now we have 1 3 4 5 6 12.If you remember from previous lessons, the two is Ron Swanson and he's only in the salary table.So since we're doing just the employee demographics table, he's not in here.So what we're doing is we're selecting everything from the employee demographics where the employee ID in this table matches or is in the select employee ID from the salary table where the department ID is equal to one.In essence, this is what a subquery is.It's a query within a query.Now, what would happen if we have the employee ID, but we also wanted to say the department ID because we just wanted to view this.
Let's go ahead and try to run this.We are going to get no output and we're going to get an error that says operand should contain one column.The operand referring to this entire thing right here cuz this is an operator.So, this is our operand and we're returning two columns in here which is saying we cannot do.We have to only have one.So now if we run this, it works perfectly well.And let's bring that down.Now we can also use the subquery in a select statement.So let's take a look at that.Next, let's go down here and let's say we want to do select everything from employee salary.And let me spell that right.Let's say we want to look at all the salaries just like how we have it now.But in a column next to it, we also want to compare it to the average salary for everyone.
So we'll be able to see, you know, whether somebody's salary is above average or below average.So what we would try to do potentially is do something like uh first name salary and average salary.And we try to run this.And of course, we're going to get an error.It's going to basically tell us that we need to group by if we're doing this.So, let's go back down and let's actually add that group by.And we'll say group by first name and salary.And we'll look at this output.And this is not looking good at all.It's just looking at the average salary for each unique row, which is Leslie 75,000.So, the average is 75,000.This is not what we're looking for.This is not what we want.Here's what we really do want.we want to just take the average salary of this entire column regardless of group by or anything else.
So let's get rid of this and let's see how we can do that.So let's come right down here.We're going to say select select the average salary and then we're going to say from add our parenthesis because this is our subquery from the employee salary table just like that.Now if we run this we should get the exact output we're looking for.So the average salary is 57,250 and we have our salary right here.So we can compare really quickly just like that.Now we can also use a subquery in the from statement.So let's go down here and let's say select everything from employee_demographics.Let's have it autocomplete for me.So we have the employee demographics table.Now let's create a group by based off the gender column and add some aggregated functions and I'm going to show you how you can use this as a subquery.
So let's go up here say gender and then we'll let's go ahead and add our group by.So we'll say group by gender as well.Now let's add a few things.We'll do average we'll do average age and then we can do let's just do all of them based off the age.We'll just do age, min of age, and count of age.When I try to write fast, it doesn't always go right.So, we have this.Let's run this.And this is what our output is going to look like.Now, what if we wanted to get the average of the oldest age or the average of the smallest ages or, you know, see what the average count is for males and females?Well, we can't do that given this table.But let's do something right here.Select everything.And then we're going to say from and in our from statement, we're going to have a parenthesis.
We're going to paste our select statement and then close the parenthesis.So, we're going to select everything from this output that is right down here.So if we run just this, we're going to get an error and forgot this was going to happen.But every drive table must have its own alias.So you have to name a table.

24. SQL SELECT and WHERE Queries

Covers writing basic SQL queries with SELECT, FROM, and WHERE clauses to retrieve and filter data.

I forgot it does that.All we have to do to fix this is just name it.So we'll say as and we'll say aggregated table.We'll just call it aggregated table.So let's run this.And we get the exact same output.But here's the neat thing is we can now select we can do gender.And these are actually the column names now.So I can do the average of this column right here.But I can't do it just like this because it's going to give us an error.And I'll show you why in just a second.Says unknown column age in field list.So what it's saying is is we're trying to perform an aggregated function on the aggregation of an age column, but we don't have an age column in our table right here.Let me run this again.We have a column named this exact thing.
So what we actually need to do is do this back tick and back tick.This is the actual name of the column.It's not an aggregation anymore.The back tick on my laptop is right above the tab on the far left hand side.Um right under the escape.That's where mine is.Uh so these back ticks, it's not a quote like this.It's a back tick.So you just need to find that on your keyboard.But now if we run this, it looks like we encountered another error.Says in aggregated query without group by.That's right.Now we need a group by.So now we need a group by gender.Sometimes you got to figure this out on the fly and it should work.There we go.So now we can perform aggregations on this table.Now, this doesn't actually work perfect because we're still grouping by the female male.
But let's get rid of this for a second.And we'll get rid of this group by entirely.And if we run this, we're now looking at the averages of this column right here, max age.Now, when you're doing something like this, it's actually really smart to rename these.We'll say as average age.We'll say as max age.And it makes it so much easier.you don't have to do these back ticks anymore.Um, and as min age and so on and so forth and I would probably format this better and stuff like that.Well, we don't have to go through everything, right?I'm just kind of giving you an example.But then when we're using this table, these columns are actually named this.So I don't have to do these back ticks anymore.I can just take this whole thing.Oops.Get rid of that back tick.
Now I can just take this column because this is the column name.So let's go ahead and run this and it's still going to work perfectly.So this one's pretty cool because you're basically creating this kind of like a temp table.Um you're just creating your own little output.Then you can query off of it and you can do you know more advanced calculations this way.It's actually really useful.But there are better ways to do something like this uh like a CTE or a temp table that we'll look at in the advanced series.But this is at least how you can do it and you can actually try it out using subqueries.So that is all we're going to look at today for sub queries.In the next lesson, we're going to take a look at window functions.
Hello everybody.In this lesson, we're going to be taking a look at window functions.Now, window functions are really powerful and are somewhat like a group by, except they don't roll everything up into one row when grouping.Window functions allow us to look at a partition or a group, but they each keep their own unique rows in the output.We're also going to look at things like row numbers, rank, and dense rank at the end of this lesson.So, before we jump into writing a window function and seeing how the syntax works, let's actually write out a group by, and then we'll compare the two when we actually do write the window function.Let's say we want to take this demographics table and we want to take this gender and compare it to the actual salaries.So what we actually need to do is we need to say join and we're going to join on the employee salary.
Let's go like this.Get rid of all of this and we'll do salary and we're going to say on and let's do dm and sal for the aliases.We'll say dm.mp employee id is equal to sal employee id.Now we're going to come up here and we're going to say gender comma and we want to look at the average salary.And we need to get rid of this right here and we need to come down to the bottom and say group by gender.Now let's go ahead and run this query.See if it works.And it did.So we have our gender and we have our average salary from our salary table.And we can rename this as average and we'll do average salary.Just like that.So this is how group by works.It rolls everything up into one row.Now let's try doing something pretty similar except we're going to use a window function.
Let's come right down here and let's paste this and let's start writing out our window function.Now we don't have to use the group by.We're going to go ahead and get rid of that.And right here for gender, we can keep that the exact same.All we're really going to change is this part right here.We're going to say average salary.And that is part of creating a window function.Typically with a straightforward window function, all we have to put is over with a closed parenthesis.This is going to say we're looking at the average salary over and normally in here you'll specify something and we'll get to that in a little bit, but we're just going to look at an average salary over everything.So let's go ahead and run this output.So this is going to look a little bit different, right?
So the male and female all have their own individual rows, which is not the same as group by.And this average salary is looking at the average salary of everybody.We're not breaking it out by the gender like we did up here.Here we rolled it up.Now we're looking at the average salary for the entire column.Now what we can do is actually partition by.Now partition by is going to separate it out kind of like grouping it.So let's say partition partition by and we'll say gender.So just like when we did the group by, the group by rolled everything up into one row.This is not going to roll everything up, but it is going to perform this calculation based off of the different genders, the unique values in this column.Let's go ahead and run this.And if you'll notice, the female is 53,750, the male 57,428.
Now, let's go and compare these.I'm going to run this and this query.Let's run this.So if we look at our group by, it's the exact same numbers except we have it on their own individual rows.Now, why would we want this?Well, let's say we want additional information.So let's just look at this one for now.So in this one, let's say we wanted to add additional things like the first name.So we'll do demirst_ame.We can do last or dem.last_ame.So, we can add other information and it doesn't affect this column at all because we're using a window function.If we try to add these exact things, and I'm going to go up here and do it.If we try to add these exact things to this, let's see if um yeah, that works.And then we also have to group by this.
If we run this query now, it's going to be completely different because we're using a group by.We're grouping by the first name, the last name, and the gender.We're breaking everything out based off of the unique values in these columns.Whereas down here, it's completely independent of what's going on in these other columns.All we're doing is we're doing a window function just based off of that column.So, I think that's pretty amazing.And there's a lot of additional functionality that we can do with these window functions.And we're going to take a look at a lot of those things in just a little bit.Let's try another example really quickly.Let's literally just copy this, paste it down here.And all we're going to do is we're going to change this to sum.So now instead of the average salary, we're looking at the sum of salaries and we're still partitioning by the gender.
Let's go ahead and run this and let's pull this up.So, all the men together make $42,000.

25. SQL Aggregations and GROUP BY

Teaches aggregate functions like SUM, COUNT, and AVG along with GROUP BY and HAVING for summarizing data.

All the females make $215,000.Now, what we're about to do is something called a rolling total.If you've never heard of a rolling total, a rolling total is super cool and can be done within my SQL.A rolling total is going to start at a specific value and add on values from subsequent rows based off of your partition.So, all we have to do is add an order by.And we're going to order by let's say the employee ID.Let's go ahead and take a look at this.And it looks like the employee ID is ambiguous.I had a feeling.So, I just need to say uh dem employee ID.Let's try this one.So, now we have something called a rolling total.I'm going to actually name it as rolling_total because this is super cool.that window functions can do this and this is something that a lot of people in like finance do.
I did it myself when I worked in healthcare and it partitions based off the female and you can't see the employee ID but there's an employee ID that we're kind of ordering on in the background.Now what it's doing is it's starting with Leslie nope and she made 75,000 then the next person April she made 25,000 which equals 100.And just to actually see this better, I'm going to add salary.And so Leslie Nome had 75,000.Then we're adding this 25,000 to the 75 and we get 100.Then we're adding the 60,000 to 160,000.Then we're adding 55,000 to 215,000.So we're adding every single time we're adding this salary to the already existing total all the way up to our grand total, which was 215,000.The exact same thing happens with the males.So, we start with 50,000, then we add 50, then we add 90, then we add 70, all the way up to 42,000.
Now, you can do this in a lot of different configurations on a lot of different columns, but in essence, this is exactly what a rolling total is.That's how it works.And we were able to partition based off of this column.We don't have to use partition by.We could do this completely regardless of the partition, but I thought it was interesting to at least break it out by female versus male.So, now that we know how to use a window function, let's look at some special things that you can really only do with window functions or window like functions.So, we're going to bring this down and what we're going to do is get rid of this entire thing and we're going to look at something called row number and we're going to look at rank and then we'lllook at dense rank.So let's look at row number.
And this is just like an aggregate function like we're doing the average age or average salary or something like that.This is what we're doing.We're doing a row number.Now we're going to do this over and we'll just do everything for right now.So let's go ahead and run this and just see what it looks like.Let's bring it up.And what we're doing is we're saying, okay, we have first name, last name, gender, salary.That's all great.But then we get to row number.and we're doing a row number based off of everything.It doesn't matter what it is.So, we're starting at one, which is the very first row, and we go all the way down to the bottom, just like an employee ID.So, let's actually add that.Let's do dm employee id just like this.So, we have this 1 2 3 4 5 6 7 8 9 10 11.
Now, if you remember on this table, we are missing Ron Swanson.So, it kind of skips that, but it's basically like an employee ID.We're kind of giving it its own unique value.And these row numbers are not going to repeat itself if you do it like this.Now, they can repeat themselves if we do a partition.And let's do a partition on the gender again because we know how to do that one.We'll do partition by, let me spell that right, partition by the gender.Now, we're going to add a row number based off the gender, but again, it's broken out or partitioned by gender.Let's look at this.Now it goes for the females 1 2 3 4.Then for the males it restarts 1 2 3 4 5 6 7.Now this is just in a random order based off how the you know data was stored in the table itself.
Now what if we wanted to kind of rank these based off of the highest salary first down to the lowest salary?You nailed it.We just add an order by.So we'll order by salary.And if we want to do it from highest to lowest, giving the highest salary, the number one, and the lowest salary, you know, later down, we'll do descending.And let's run this.And you'll see that for female, we're still partitioning by gender.For female, the highest salary is one.Next is two, three, and then four.Then for males, the highest salary is one, all the way down to seven.So that's what row number does.just gives a row number based off of whatever you're partitioning by or ordering by in your window function.Now, let's go over here and add a comma.And we're going to add and let's go down just a hair.
Let's add rank.So, I want to do rank and we'll do our parenthesis.Now, rank is going to give it more of an official rank.And let's see how this works.So, we'll do rank and we'll do over partition by salary descended.The exact same thing.And while we're here, I'm going to rename these.I'm going to say as as row_num and we'll call this one uh rank num.So let's go ahead and run this.And it looks very very very similar except for one small thing.This right here.So when we're using the row number, whatever we are partitioning by, it's not going to have duplicate rows within that partition.It just won't.So even if there's 50,000 right here, it's just going to automatically assign it based off of something that it's running in the background, whether it's the order of how the data is stored in the table or some other
order by that you are using on the table.Now rank is a little bit different because rank is going to take it just like it did the ronum except when it encounters a duplicate based off of the order by which is the salary, it's going to assignit the same number.So this is five and five.What's unique about rank is that the next number is not going to be the next number numerically.It's going to be the next number positionally.So this is 1 2 3 4 five.This is kind of like a six.And then it goes to seven.So it skips number six.Now there's another one.Let's copy this rank.There's another type of rank called dense rank.And we'll do dense rank.So, we'll do dense rank.And let's run this.And let's pull this up.There we go.Now, dense rank is ever so slightly different than rank in the fact that when it gets down to duplicates, it's still going to duplicate them.
So, it's going to have a five and a five, but it's going to give the next number numerically, not positionally.That is the only real difference between rank and dense rank.And again, row number is just not going to have duplicates.It's going to give it its own unique within that partition.So, I know I just threw a lot at you, but that's row number, rank, and dense rank in a nutshell.And you can review this, mess around with it, all of these things, because, you know, these are actually really, really useful.So, that's all we're going to take a look at in this window functions lesson.I hope all of that made sense.I hope you kind of got an understanding of how it can work and how powerful these window functions can be.And this is actually the last lesson in the intermediate MySQL series.
Thank you guys so much for watching.I really appreciate it.If you like this video, be sure to like and subscribe and I'll see you in the next video.
Hello everybody and welcome to the first lesson in the advanced MySQL tutorial series.Today we are going to be looking at CTE.Now CTE stand for common table expression.They're going to allow you to define a subquery block that you can then reference within the main query.Now, that may not make perfect sense, but we've looked at subqueries in the past or in previous lessons in the intermediate series.So, you kind of understand that it's kind of like a query within a query, except we're going to name this subquery block, and it'll be a little bit more standardized, a little bit better formatted than actually using asubquery.Let's take a look at the basics of writing a CTE.Let's pull this down really quickly.And all we're going to do is we want to create this as a CTE.So we'll say with and that is our keyword to define our CTE.
So we're going to say with name our CTE and we'll just call it CTE and we'll do underscore example.

26. SQL Joins Between Tables

Explains how to combine data from multiple tables using INNER, LEFT, RIGHT, and FULL joins.

And then we're going to say as.So this is how we define it.And now we need to actually put it in parenthesis.Now you can do this in several different ways.I'm going to do it kind of like this just to really emphasize that this is within the CTE.Now, CTE are unique because you can only use the CTE immediately after you create it.So, if we come right down here and we come right below it, we'll say select everything and we're going to say from CTE example.So, we'll say from CTE example.And let's bring this back up.Now, if we run this, we're going to get the exact same output.Now, this should seem pretty familiar, almost like we're using a subquery.And within our subquery, we have this right here.We're kind of building our own little table.And then we can query off of it down below.
So, we can come down here and let's actually change the names in here.We're going to say average cell.And we'll change all of these real quick just because don't uh I don't like having to actually put the, you know, uh the tick marks.I don't like doing that.So here we're going to say max, then we'll say min, and then we'll say count.And let's go ahead and run this again.And so now we have these different names.And when we come right here, we can say select, and then we'll just do something really simple.Let's do the average of average cell.So the average salary and let's run this.And so this is the average between both the males and the females.Kind of the purpose of these CTE is to be able to perform more advanced calculations.Something that you can't easily do or can't do at all within just one query.
Another reason to use a CTE is just the readability.You can absolutely write this using a subquery.And let's do that really quickly.And it's just going to be a little bit tougher to read and look at.So let's come right up here.We're going to say from and we'll do right here.We'll say select everything.We'll do select average cell from here.And we're going to need to name this.So we'll say um do example subquery.We'll get rid of this.And then we just need to get rid of this.And we can run this query.And we get the exact same output.Now, if I formatted this exactly the same, just like this, and the names down there.If we look at this, the syntax is just a little bit more difficult to read.We're selecting the average of average sal from, and then we have our subquery right here, and then we're naming it at the bottom.
If we scroll up and compare this, this one just looks a lot better.Now, when you're writing in my SQL, sometimes it doesn't matter if it looks pretty or not, as long as it gets the job done.That is true, especially if you're just going to be using it yourself.But in a more professional environment, when you're using this in your actual job, they're going to be people who've been using this for 10, 20 years, and they're going to expect you to write it well.They don't want it to be really messy.They aren't most likely going to want it to be written like this.I've been using it for quite a long time and I much prefer CTE over subqueries just visually and it makes it a lot quicker to actually read through.So that is just one of the reasons although you get the exact same output.
Now there is some additional functionality within CTE as well.Now one thing that I mentioned just a second ago is that when you build a CTE you can only use it immediately after.You can't use it right below it.So, let's go ahead and let's copy this query and we're going to bring it right here.If we try to run this and let's do this.We're going to get an error and let's pull this up.It says table parks andrec.ct example doesn't exist.So, we're looking for a table called CTE example in our database, but it's not there.Now, the reason this happens is because you're creating a CTE.You're not creating a permanent object like a temp table, which we'll look at in the next lesson.And you're not creating a real table and you're not creating a view.You're really not creating anything.
It's just a common table expression to create this table right here.This basically almost like a temporary table almost, but then you're just using it to query off of it.You're not saving it.You're not storing it in memory.You're not really doing anything with it.It's just like writing a regular query.So this is why you can only write it immediately after creating the CTE.You can't write it down below and reuse it because it's just like calling a query that you wrote before.It just isn't going to work.Now the next thing that I want to take a look at and let's copy this down here.Next thing I want to take a look at is that you can actually create multiple CTE within just one.And so if we wanted to do a more complex query or joining more complex queries together, we can do that all within one CTE.
So let's come right here.Let's get rid of all of this.And we're going to say uh from the demographics table, we're going to say where birth date and let's just do as larger than 1985-1.So we have one query and we'll take just a few columns from this table.So we'll take let's say the employer or employee ID.We'll take the gender and the birth underscore date.So this is one query and we're filtering just based off of this birth date.Now when we create this, this is the CTE example, but we can have a comma here.We can come down below and then we can say ct example 2 and I need to combine that.So two and then we can say as and then we have another query.So then right here we could say select everything.We'll change that in a second from employee say salary and in the salary we'll just do a simple one.
We'll do where salary is greater than 50,000.And we'll actually just take the employee id and the salary.Now if I come right down here, I can say select everything from CTE example which is and let me scroll up so we can see everything.That's our original.Our CT example is this first query right here.Then we're creating our second one right here.And we can join basically on these two common table expressions.So now we can say join and then we'll do CTE example 2.I need to change that X and then we'll say on then we're just going to do TT example employee ID is equal to TTample2 employee ID and not an equal sign but a dot.There we go.Now, if we run this, it should work and we can pull this down and look at our output.Now, this is just an example.
This isn't a real use case because, of course, we could just join these two tables together normally, but you can imagine you have a much more complex query or you're doing a lot of functionality within this table andyou just want a certain subsection of this table and you're wanting to combine those.This is how you can do that with a CTE.So now we have all of our information right here.And that can be extremely extremely helpful.Now, one last thing that I want to show you.We're going to go all the way back up really quickly right here.Let's run this one one more time and let's actually take everything and let's run this.So here we have our gender, average salary, max salary, men's salary, and count salary.The last thing that I want to show you, and this is more of something that's just somewhat helpful, you don't have to actually do it in your main query, is before we went in here and we changed all
the column names by doing an alias by saying as and then saying the average salary.And the as is just implied here.But we're changing this via an alias.We don't have to do this.In fact, we could come right here and we could do a parenthesis.We could call it gender.We'd call it average salary, max salary, miners salary, and let's do countd salary.So now, if we were to run this, let's change this up.We'll do capital on this one.If we wanted to run it like this, when we run this, it'll change all of those names to what we have it right here.So this will be the default.This will overwrite the column names that you have in your actual CTE expression or the query that you have within your CTE.So, that is all we're going to take a look at in this lesson on CTE.
These are very, very helpful, definitely help with more complex queries, and they're just really easy to read and understand, which is why I personally use them a lot.In the next lesson, we're going to be taking a look at temp tables, and we'll also compare temp tables to CTE, and we'll take a look at the difference.
Hello everybody.In this lesson, we're going to be taking a look at temporary tables.Now, temporary tables are tables that are only visible to the session that they're created in.So, if I create a temp table right now and I exit out of my SQL and I come back in, it's not going to be there anymore.And we'll look at that in just a little bit.Now, temporary tables can be used for a lot of things, but how I've mostly used them, especially as a data analyst, is for storing intermediate results for complex queries, somewhat like a CTE, but also for using it tomanipulate data before I insert it into a more permanent table.

27. Advanced SQL Query Techniques

Covers advanced SQL concepts such as subqueries, CTEs, and window functions for more complex analysis.

So, let's take a look at how we can create a temp table.There's two ways that you can do it.I'll show you the first way, which I don't think is as popular, and then I'll show you the second way, which is how I typically use it the most.Now, the first way to create a temp table is to create a temporary table.I need to sound it out like that.It's the only way I can spell.So, we're going to do temp table.So, this is our name.Now, if we just took this out and we created a table, this would create a table in our parks and recreation database.But we don't want that.We want to create a temporary table that just lives inside of our memory or the memory within our computer.Now, we're going to create this temporary table much like we would a regular table.
And we're going to need to name the columns as well as the data types.So, let's do first name.And our data type can be varchar.Let's say 50.And we'll do a comma.Then we'll do last name.We're going to keep this really simple.We'll do varchchar 50 again.And then for our last one, we'll do favorite movie.And for this one, it needs to be longer.So we'll do varchchar let's say 100.Now let's get rid of this and let's actually run this after we do our semicolon.Let's actually run this and nothing's going to happen.Let's click refresh.Nothing's going to happen.At least you can't see it happening.Let's pull this up.And you can see that create temporary table says zero row is affected, but it was created.Now in order to actually see it, we can do select everything.
And we'll do this from our temp table.And we'll add a semicolon.And then we run this.And we have this empty table right here.Now, what's really great about these temp tables is then you can insert data into it.And it basically is like a real table except it just lives in memory and they go away after a while.But you can reuse this temp table over and over and over again.Now, let's insert some data into here and then we'll take a look at this again.So, let's come right down here.Let's insert data.We'll do insert into and we want to insert that into the temp table.And we're just going to say values.Now, we just say values.I'll use myself for this one.We'll do uh Alex Freeberg.And what's my favorite movie?Give me a comma.That'll be Lord of uh I think it's like that.
Lord of the Rings, the Two Towers.Uh it's probably my favorite movie of all time.Now, let's go ahead and insert this data.And let's pull this down here.And let's run it all the way down here after we add our semicolon.And when we run this, you'll notice that now we have data in here.So now we can use this table much like any real table.So that's the first way to create a temp table.Not my personal favorite way, although there have been some use cases where I've done it like that.I'm going to show you the way that I typically do it.And for this, let's select everything from the employee salary table.Let's run this.Now, let's say I just wanted a subsection of this data to sit in this temp table where the salary is greater than let's say 50,000.
I could easily easily do this.I'm going to say create temporary table and let's do this one as salary over 50k.Now, one thing about naming either temp tables or CTEs or sub queries or any of these things where you need to name something, I try to typically name it something that actually makes sense.So, the salary over 50k is something I would actually name it in my real work.I wouldn't normally name it something like tempt table.The reason for that is because when you're in a work environment and you have lots of temp tables, you're creating really advanced store procedures, really advanced queries, you have hundreds or even thousands of tables and different databases, itgets really complex.So naming conventions are actually pretty important or they become more important uh the more you get entrenched in this stuff.So just something to think about.
Now we're creating this temp table.Now, we don't have to really insert data into it more than we're just going to select data from an already existing table.So, I'm going to say select everything from I'm going to say employee salary and we're just going to say where the salary is greater than 50,000.Now, I want uh Tom and Jerry, I want them to be included as well.So, I'll actually say greater than or equal to.So now we're creating a temporary table based off of an already existing table and we're just selecting data into this temporary table.So when we run this now we can select the salary over 50k and let's run this and it works perfectly.Now the great thing about tempt tables is they last as long as you are within that session.Meaning if I copy this query, let's go to a new window and let's paste this in here and let's zoom in a little bit and let's run this.
It still works even in a new window.But if I'm to exit out and come back in, then it is no longer going to be working.Now, let's exit out of this.Let's come back in and we'll see if these temp tables still work.Let's go ahead and exit out.Oh jeez, I'm embarrassed.All right, let's go to my SQL.Let's come over here to the local instance.So now it pulls right back up.Zoom in once again on both these and let's try to pull up our salary over 50k temporary table.Let's run this.And we're not getting an output.Let's go back.It's going to say error code.The table salary over 50k does not exist.So it only lasted as long as we were within this session.So that is how we create our temp tables and that's how we use our temp tables.
Now in the last lesson we had looked at CTE.CTE and tempt tables both have their own use cases within my SQL.For temp tables this is usually for the more advanced things.So I'm usually using these in store procedures when I'm really manipulating data and I'm doing a lot more complex queries overall and oftent times I'll use multiple temp tables and I'm joining them together and I'm just doing alot of more advanced stuff.With CTE, it's typically more simple things because you can't make as advanced CTE or as complex CTE.So with those, I'm usually keeping it to just one level of transformation.I have my base CTE or my base subquery or query, however you want to call that, and I'm changing it or doing one level of advanced thing on top of that query.That's what a CT is really great for.
Temp tables, you can just get a lot more advanced with it.They also last within the session.And if I'm using it multiple times throughout something like a store procedure, then it makes so much sense to use a temporary table.So this has been our lesson on temporary tables.In the next lesson, we're going to be taking a look at string functions.
Hello everybody.In this lesson, we're going to be taking a look at stored procedures.Store procedures are a way to save your SQL code that you can reuse over and over again.When you save it, you can call that stored procedure, and it's going to execute all the code that you wrote within your store procedure.It's really helpful for storing complex queries, simplifying repetitive code, and just enhancing performance overall.So, let's take a look at how we can create a stored procedure.Now, we're going to start by just creating a really simple query.We'll make it a little bit more advanced as we go along and take a look at the different things within store procedures that you can do.Now, let's change this query.Let's say where the salary is greater than let's do 50,000.Let's actually do greater than or equal to 50,000.
We want to include Tom uh and Jerry as well.So, let's go ahead and run this.Now, what we want to do is save this really complex code within a store procedure.Let's come right down here and we can create a super super super simple store procedure by just saying create procedure and pasting that.Now we just have to name it.So we have create procedure and we'll call this large salaries and then we do a closed parenthesis.Now this is as simple as it can possibly be.It does not get any simpler than this.So let's go ahead and run this.And if we go down, we pull this up, you can see that it says create procedure, zero rows affected.

28. SQL Hands-On Project

Applies SQL skills in a full project, querying and analyzing a real dataset end to end.

So it looks like it worked.And if we come over here to this refresh button, you should see now that under store procedures, it drops down and we have our large salaries.That's exactly what should have happened.We wanted to save that into our parks and recreation.Now, if you wanted to be careful, you could say use parks recreation.This is not a bad idea, but you don't have to.But you can specify what database within your actual editor window.Sometimes that is helpful.But now we've created it.Now let's see how we can call it.All we have to do is say call.We're going to copy this entire thing including the parenthesis.And let's end it with that's right, a semicolon.Let's go ahead and run this.And as you can see, it worked because we got the exact output.So we actually called this store procedure and this code ran.
So it's just a select statement.So it worked perfectly.Now you can also come over here to large salaries and there's this little tiny little button here that looks like a lightning bolt.And if you click it, it's going to open up a different window and we'll say call parks and recreation.large salaries.So you can do it that way as well, but uh we're not going to be doing it that way.Now what we've written right here is not best practice by any means.And I'm going to copy this down here because there's a lot of different things that you need to take into account when you're creating a store procedure.For example, this right here is most likely not what you're going to be putting into a store procedure.This is super super simple.Typically, you'll be having multiple queries.And let's see what happens if I try to put another query in here.
And let's get rid of this.So, we're going to select everything where the salary is greater than 50,000.Then we'll select everything where it's greater than 10,000 which is everybody.Let's call this large salaries 2.So we have two different statements in here and we want them all to be under this large salaries too.Let's select everything and let's run this and we're getting an output which is already not a good sign but we created the store procedure and then we selected everything.So what's actually happening here?Pull this back down.What's happening is is this is creating the store procedure and this is just some other you know random query.But that's not what we want.What we want is everything or both of these queries within one store procedure.The best practice is to use something called a delimiter.Now this right here is a delimiter.
The semicolon.So the semicolon separates our queries from one another.It tells my SQL hey you know this is a different query.Don't be mixing these and cause errors.You know, that's essentially what a delimiter does.Now, we can change the delimiter by coming up here and saying delimiter, and we can change it to almost anything we want.Now, in my actual job, I've seen it done many different ways.I've seen these forward slashes.I've also seen dollar signs.This is probably the one that I've seen the most when I worked with data engineers, data scientists, database developers.You This one I see a lot.And then you'll come into the code and you'll say begin.And let's go over here and let's tab all of this.And then we'll say end.Now when we end, we're going to end it with this dollar sign.
So here's what's happening.We're changing the delimiter right here to dollar sign.We're creating our store procedure and within it, we are keeping all of this.So all of this code is going to go into this one stored procedure.Then at the end, we are saying this is the end right here of this stored procedure.These semicolons no longer are the delimiter that's telling us when it is the end of the store procedure.That's what the delimiter does.Now, it is best practice at the end to change it back, right?Uh let me spell it right because if you don't, then you're going to have to start using uh these dollar signs for everything.And how do you spell delimiter?Oh man, there we go.Now, we've changed it back to a semicolon afterwards.So, then we can go and write other queries and it'll um act appropriately.
Uh, let's go down.So, this is getting closer to best practice.Let's go ahead and run this entire thing.And if we pull this up, we're not getting an output.That's a good sign.If we pull this up, it's saying we already created number two.Change that to three.My apologies.Let's go down here.Now, we've created the store procedure three.Now, let's go over here.We're going to rightclick on this.We're going to say alter stored procedure.And now you can see that we have both of these queries within this stored procedure.Let's get rid of this.And we're going to go and call this.So let's copy this large salaries three.Bring this all the way down.And let's say call that store procedure.If we run it, you'll notice we get two outputs.We have six and seven.This result six is where it's greater than 50,000 or 50,000 uh or greater.
This one is where it's greater than 10,000 which is essentially the entire table.Now, so far we've done everything just by writing it all out.And that's fantastic.But you can also come over here to store procedures.You can rightclick and say create stored procedure.Now let's actually copy this.We're just going to create the exact same thing.We'll create store procedure.And we can just paste this in here.And let's go ahead and do that.There we go.And sure, we'll call it new procedure.Why not?And if we say apply, you'll notice that it generates this script right here.And we can apply it and we can create it.We will in just a second, but let's take a look at it.So, we're going to use parks and recreation.That's what I was mentioning before.We're then going to say drop procedure if exists.
Now, this is something that I was going to show you later, but I'll just show it to you now.Sometimes it is really beneficial to write something like this before you create it in case you've already created a store procedure with that name that you're wanting to replace.So it's checking if it's there and if that new procedure is already there, it's just going to drop it.Then it comes down and let me see if I can zoom in on this.And then it's going to create our delimter which it uses dollar signs.So my SQL is even, you know, validating what I was saying earlier.We're going to use parks and recreation again.And now again we have to use instead of a semicolon we're using dollar signs.Then we're creating the procedure which is new procedure we're saying begin and then it's even changing the delimter back.
So basically everything that I said this is kind of doing it for you automatically.Now when I click apply it went ahead and executed that SQL statement and our new one is ready.So, we can go ahead and alter that store procedure, and it looks exactly the same as this one out here, which was uh large salaries number three.So, it looks exactly the same.Now, let's go ahead and get rid of this.Get rid of this, and let's go down below.The next thing I want to take a look at is something called a parameter.Now, before I actually get into this, I'm going to copy all this down here because I don't want to rewrite all of it, uh, if I'm being honest.So let's paste this in here.Now parameters are variables that are passed as an input into a store procedure in the allow the store procedure to accept an input value and place it into your code.
Let's take a look at what that actually means.Now before I do anything, I'm just going to change this to uh number four so I don't forget.So let's get rid of all of this.We're going to keep it somewhat simple because we're looking at something new.

29. Tableau Introduction and Setup

Starts the Tableau series with an introduction to the tool, connecting data sources, and the Tableau interface.

Now, when I say we're passing through a parameter, I'm talking about when we're calling it.So, let's say we've already created this one.I'm not going to, you know, run this yet, but let's say we've created it.Let's say I want to pass in an employee ID.I want to pass in a specific person and I want to retrieve their salary.I know their employee IDs.I just want it to pull up their salary for us.So, what we're going to do is we'll get rid of this.And when we're calling it, put this down.When we're calling it, I'm going to pass through a value like one.That's Leslie.Nope.And then I want the salary to be the output.So I'm going to select the salary.So we're selecting salary from the employee salary.But how do we know that this one is the person we're looking for?
Well, when we're actually creating this parameter, we create it right in here.That's what tells the store procedure to accept an input value when we're calling it down below.We're going to call this employee ID.Now, after we call it, after we name our parameter, we need to then give it a data type.So, I'll call this an integer.So, we're telling the store procedure, when somebody calls this store procedure, they have to pass through an integer.It can't be a string or it can't be a date.It has to be an integer.Now what we're going to go do is right down here we'll say where the employee ID that's from this column in the actual table we'll say is equal to the employee ID which is our parameter right here.Now you may be thinking that's really confusing.They're named the exact same thing.
Can I change it?The answer is yes.I actually encourage it.So there are some naming conventions that are out there that I think are helpful ones that I personally use.Um, but remember this is just kind of a variable parameter name.You can kind of call it whatever you want.So if I wanted to say Huggy Muffin, I could.Uh, and this could be Huggy Muffin.So let's try it with Huggy Muffin.I just came up with that off the top of my head, so don't judge me.Um, but we're going to create the store procedure.And then when we call it later, we want it to return the salary where the employee ID right here is equal to whatever was passed through that parameter, that input parameter.We're going to keep it as one.So it should return 75,000.Let's go ahead.We're going to create this.
And now let's go right down here and we're going to run it.And we can see that that is the salary and it worked perfectly.Now like I was saying, that is not what I would actually name it.Uh there are some naming conventions like underscore param at the end.So you kind of want to keep it at least I recommend you try to keep it similar to what you're actually looking for.And you can either end it in underscore param or there's another way that you can do it which is come right over here and do p underscore.And these are just ways that you can tell the code or you can just be able to visually see the difference in the code.So this is just what I recommend.Then you put it right down here.you say where the employee ID is equal to P employee ID saying this is the parameter that's being passed through and put into our actual query.
So that is all we're going to take a look at in this lesson.In the next lesson, we're going to be taking a look at triggers and events.
Hello everybody.In this lesson, we're going to be taking a look at triggers and events.A trigger is a block of code that executes automatically when an event takes place on a specific table.For example, let's take a look at these two tables.Now, when a new employee is hired, they're put into this table with their salary information and everything, but sometimes people forget or don't add their information like uh you know who right here.Uh they're not put into this demographics table.And we want to change that because we want to have everybody in here.So when somebody is put into this salary table, we want it to automatically update with the employee ID, first name, and last name into this table right here for the employee ID, first name, and last name.So we're going to write a trigger when data is updated into the salary, it's going to also update the employee demographics for us.
Now, let's go right down here and we're going to take a look at how we can do that.Now, if you watched the last lesson on store procedures, we'll do a lot of the same writing style or same formatting for triggers and events.So, we're going to start with is the delimter.We're just going to do that right off the bat before we get into anything.And we're going to change that to the double dollar sign.Now, the delimiter again in case we have multiple lines of code, which we're going to have.If we have multiple lines of code when we're creating this trigger, this delimter is going to help us have multiple queries within our create trigger statement.So this is really important.We'll just start out by doing that.Now let's create our trigger.And we do need to name this.So we'll say employee_insert.
And we'll just call it like that.Did I spell that right?Yeah.Employee insert.So we have our create trigger.We've named it.Now we need to specify what event needs to take place in order for this to be triggered.So we're going to say after an insert and I need to spell insert right after an insert on and we'll do the employee salary table.So after we insert onto the employee salary table down below we're going to write what's actually going to happen.Now we're writing after because we're doing it where when new information is put on the salary table it's automatically updated into the demographics table.But you could also do before which means if data is deleted from the employee salary table something could happen but we're not doing any deleting or any updating we're doing insertion.So we're going to say after an insert on now the next part that we need to write is for each row.
Now this for each row means that the trigger is going to get activated for each row that is inserted.So, if we had an insert statement that inserted four different people who were just hired, that means this trigger is going to be activated four times.Now, some SQL databases like Microsoft SQL Server have things like batch triggers or table level triggers that'll only trigger once for all four of them.And in my opinion, those are really, really nice.Uh, I've used those.I like them.The way that my SQL has it right here is not the most optimal way to do it, unfortunately.but we don't have access to the batch level or the table level triggers at this time.So this is really just the setup for what we're about to write.So after it's inserted on the employee salary table for each row, what is going to happen?
We're going to go down here and we're going to say begin and we'll have end.Now the code that we're going to write here is what's going to happen after this event takes place.So what we're going to do is we want to take from this table.Let's bring this back up real quick.When we insert a new person, we want to take the employee ID, the first name, and the last name and automatically put it into the demographics table.So, we want to say insert and let me do tab insert into we're going to insert into the employee demographics table.And we're not taking everything.So, let's actually specify what columns we're doing.We're doing employee id first name and then the last underscore name.Now we need to specify what the values are.Now from the employee salary table we're taking employee ID, first name and last name.
But we don't want to take all of them, right?We don't want to take every single employee ID, every single first name, every single last name.We only want to take the new values that were just inserted.Well, lucky for us, there is something that we have for this.So, let's do values, new parenthesy.We have something called new.Now, new is going to say we're only taking the new rows that were inserted.There's also an old like this where it takes rows that were deleted or updated, but of course, for us, we're going to be using new.So, we'll say new employee ID, new_ame, and then new.ast_ame.last underscore name and we'll close that.Then we'll come down here and we'll do our delimiter and we'll change this as well.We'll say delimiter back to a semicolon.Now, we're getting this error because we need this right here.
So, let's recap what we've created, then we'll actually create it and try it out.So, we're creating our trigger called employee insert.After a row is inserted into the employee salary table, for each row, here's what's going to happen.We are going to insert into the employee demographics table the employee ID, the first name, and the last name.Those are the columns that we're going to insert into.Then we're taking the values new.ID, new name, and new.ast name.Now, MySQL understands that when we say new, we're talking about the event that takes place.So, this is the data that's being inserted.It just knows that.

30. Building Tableau Visualizations

Teaches how to create charts, maps, and other visualizations in Tableau to explore and present data.

So, let's go ahead and create it.We're going to run this.And it should work.Let's pull this up.Says create trigger.So, that worked.Now, the thing about triggers, uh, that's unfortunate, it does doesn't have its own little section under here, right?But it does have under the employee salary.Let's go right here.And then under the triggers.So, we can find it, which is great.So, we have this employee insert.If we rightclick, we can't really do anything with it.That's the unfortunate thing.We can't alter it.We can't change it.We can't drop it.We can't do anything.Um, that's the unfortunate part.But let's actually test it.So now we're going to say insert into and we're going to insert into this employee salary.That's how we're going to trigger it.So insert into the employee salary.And then we'll do employee ID.
These are all the columns.The first underscore name, last underscore name, occupation.Uh, bear with me for a second.Then we have salary and then department ID.So this is what we're inserting into.Now we have to do our values.Now this should be shorter hopefully.We'll do 13.We'll call him uh Jean Ralph.There we go.Last name is Sapperstein.Just like that.And not actually just like that.That's not spelled right.So we have Sapperstein.His occupation is entertainment 720 CEO.How much is he making?Uh let's say a million.Is that a million?A million.He's making a million dollars.And he's really not part of any uh department.So we're just going to have null.So what we're about to do is we're only inserting on the employee salary table, but we're putting all the values that we need into the appropriate places.
Let's add a semicolon.Let's go ahead and run this.Make sure it worked.And it says insert into and then one row affected.Now let's come back up.Let's look at our salary table first and get rid of this.If we pull this up, you can see Jean Ralph Sapperstein.He was added.Let's go over to the demographics is the moment of truth.Let's see if it worked.And as you can see, it worked perfectly.We have Jean Ralph Sapperstein.Now, they do need to come back and fill in this information, but it's already in here kind of queuing them up saying, "Hey, we need this person's age, gender, birth date, all that other information."So, that is how we can create a trigger based off of a specific table and then when it happens, it just automatically does it for us.We don't have to really think about it.
We just know that we've created a trigger and we can actually go and insert data on that table and that trigger is going to work.it's going to do what it's supposed to do.And that's really, really helpful in the real world when you're working with a ton of tables.A ton of things need to be automatically done and you don't want to have to manually do this.So, having these triggers can save you a ton of time.Now, let's scroll down and we're going to take a look at events.Now, event is kind of similar to a trigger.A trigger happens when an event takes place, whereas an event takes place when it's scheduled.So, this is more of a scheduled automator rather than a trigger that happens when an event takes place.These can be fantastic for a lot of things like when you're importing data.
You can pull data from a specific file path on a schedule.You can build reports that are exported to a file on a schedule.You can do it daily, weekly, monthly, yearly, really whatever you'd like.It's just super helpful for automation in general.Now, let's say the Pawne Council comes up with some new legislation.They need to save some money, especially in the parks and recck department.We're just spending too much or they're spending too much.And what they want to do is retire people who are over the age of 60 immediately and give them lifetime pay.So what we want to do is create an event that checks it, let's say every month or every day.And then if they're over a specific age, we are then going to delete them from the table and they will be retired.This is a fake example, so you know, go with it.
So, what we're going to do is come right down here.We'll select everything from employee demographics and let's run this and let's pull this up.So, let's say if they are over the age of 60, which unfortunately is Jerry Gurgage, like I don't make the rules, but if they're over the age of 60, they are going to be automatically retired.So, let's come right over here.We're going to say create event and we'll call this the delete and delete retirees.Now before when we were creating the trigger, we were saying based off of a specific event, but here we're going to schedule it.We're going to say on schedule and then we're going to say every and we could do one month.Maybe we'll look every single month.But here we'll do let's do every 30 seconds.every 30 second.Now, we're going to go down.
We'll say do.And this is going to say here's what needs to happen every 30 seconds.So, we'll say begin and end.Now, what's going to happen every 30 seconds is we're just going to start with a select statement.And I'll just copy this.Actually, we'll start with a select statement, but then we'll update it to a delete statement.But we'll come right here.We'll say where the age is greater than or equal to 60.So, if we just run this query right here, that's only one person.That's Jerry Gurgg.Now, if we want to write this correctly, we'll do the delimiter.We'll have the dollar signs.We'll have the dollar sign right down here as well.And we'll say delimiter back to a semicolon.Now, every 30 seconds, we don't want to select people who are that age.We want to delete.So, let's go right here.
We're going to change this because now we know it should be deleting the right person.and we're going to go ahead and create this event.Let's go ahead and run this.And let's make sure it was created properly.It looks like create event zero is affected.This should be working.Let's go back up to the demographics table and let's run this.And let's pull this down and pull this up.And as you can see, unfortunately, Jerry Gurgich is no more.Um, you know, he's just too old.and the Pony Council, they recognized that.And so it wasn't my rule.That was unfortunately Ponyie Council's rule.Now, really quickly, if that did not work, let's say you couldn't create your event at all.Let's go down here.I'm going to show variables and we'll run it just like this.Um, I'm going to show you how you may need to fix this.
So, we can say where variables is like, and then we'll say, uh, event.do it just like this.So, I have a ventuler where the value is on.

31. Creating Tableau Dashboards

Shows how to combine multiple visualizations into interactive dashboards and share them with others.

If yours is off, which sometimes that can happen, you're just going to update this to on.Now, another issue could have happened, and I just want to explore this for just one second.You may not have permissions to delete things.If you do not come right up here, let's try to figure this out together.It's actually edit preferences, and I want to say it's right here into the SQL editor at the very bottom.Yep.So, save updates rejects updates and deletes with no restrictions.This needs to be unchecked.So, go to preferences, go to the SQL editor down at the bottom, uncclick this if that didn't work.Now, if everything worked perfectly, you don't need to change a thing.But if it didn't, I just wanted to work through, you know, some uh troubleshooting that you may just have to Google or chat GBT or something to try to figure out.
So, that is how we can create an event in my SQL to run on a schedule.Now, typically you wouldn't do it on every 30 seconds.you would do something like every 1 month or every 1 year or you know a longer time frame but you get the picture of what we're trying to do.So that is how we create triggers and events and this is also the end of the advanced my SQL series.If you made it this far absolutely fantastic work in the next two lessons those are going to be our projects that we're going to work on for this series.We'll have a data cleaning project and we'll have an exploratory data analysis project.Both of those are going to include a ton of things that we've looked at in this series and even some new things that we didn't look at in the actual lessons themselves.
So, thank you guys for watching.I hope you enjoyed this entire series.If you did, be sure to leave a like and a subscribe below.I will see you in those projects.
Hello everybody and welcome to the very first project in the MySQL series.Today we're going to be focusing on data cleaning.Now if you don't know what data cleaning is, it's basically where you get it in a more usable format.So you fix a lot of the issues in the raw data that when you start creating visualizations or start using it in your products that the data is actually useful and there aren't a lot of issues with it.So that's really what data cleaning is.Now, what we're about to do is create a database.We're going to import a data set.This is a real data set.And what we're going to do is we're going to clean the data.So, I'm going to show you and walk you through all the steps in order to clean the data.The data set that we're going to be working with will be in the GitHub.
So, you can just go and download that.I'll have a link somewhere in the description.But, let's get started.First thing we're going to do is create a new database.So, we'll go right over here to create a new schema.And we're just going to call this one.We'll do this is world layoffs.So, if you can't tell already, uh, we're going to do world layoffs.Uh, that's the data set that we're going to be doing.We'll just click apply.And that creates our world layoffs right here.Now, we're going to go into here.There are no tables.We're going to right click on tables and go to table data import wizard.Now, we haven't done this yet uh in this series.We haven't imported any data, but that's what we're doing here.We're going to show you how to import data.So, we'll go ahead and click browse.
And as you can see right here, we have this layoffs data set.Let's open this up and we're going to click next and we're going to create a new table.There's no existing table in this database.You can drop it if it exists uh if you'd like to.It doesn't matter.This is new.We're going to go ahead and select next.Now, right here is where you configure import settings.Now, MySQL is going to automatically assign a data type based off of the data in these columns.So, we'll take a look at the data later.Now, there is one thing that you can take a look at real quick.We have this date column.Now, in here, it assigned it as a text.That's because the format.We are going to import this as the raw data.We're not going to try to change anything in the import settings.
We're just going to assume this is how the data was in the table.So, we're not going to change anything.Although, this may be something that you would want to change to something like a date time and go and fix that.But, we're going to import this as the raw data.Let's go ahead and select next.We're going to import it.We just select next.Now, this could take a little bit.Uh, so while this is importing, I'm just going to skip ahead.This should take just a few minutes to import.All right, this just finished.Let's select next.And we imported 2,361 records.Let's go ahead and select finish.We can get rid of this.And let's refresh this.Perfect.We have our layoffs table.So, we'll select everything.And I'm going to go and double click on the world layoffs because I don't want to write out the whole thing every time.
So we're going to say from layoffs and let's see what we get.So let's take a look at the data that we're going to be working with in this data cleaning project.So this data set is layoffs from around the world starting I think 2021.And we'll take a look at that in this date column later.But it has the company.So it has the company that did the layoffs.It has the location of where they are, what industry they are part of, how many they laid off, the percentage that they laid off.So the percentage of their company, the date, the stage, which refers to the stage that the company is in, whether it's a series B, post IPO, uh they don't know.Then there's the country, and then we have funds raised millions.So we have a lot of information here.And in the next project, we're going to be doing exploratory data analysis.
So we're cleaning all of this data and then in the next lesson, we're going to actually dive into it and try to find trends and patterns and all these other things.So what we are going to do is we're going to go through multiple steps.Step number one is we are going to try to remove duplicates if there are any.That is the first thing I typically do especially if I know this data shouldn't have any duplicates or it'd be you know repetitive or unnecessary to have duplicates.The second thing is going to be to standardize the data.That just means that if there are issues with the data with spellings or things like that, we just want to standardize it to where it's all the same as it should be.Number three is we'll look at the null values or blank values.And there's a lot of null values in here.
There's even a blank value right here.And we're going to see if we can populate that if we can.And there are times where you should, there are times where you shouldn't.I'll kind of walk through that as well.And lastly, we want to remove any columns and rows that aren't necessary.And there's a few different ways to do that.Uh, this one is a little bit, you know, um, let me write this actually real quick.Remove any columns.So, I'm just going to say there are instances where you can do this.There are instances where you shouldn't do this.When you're working with massive data sets and you have a column that's, you know, completely irrelevant, completely blank, you don't have any ETL process that is required for it.Um, you can get rid of it.it can save you time when you're querying your data.
Now, with that being said, uh and we'll talk about this later, in the real workplace, oftent times you have processes that automatically import data from different data sources.If you remove a column from the raw data set, that's a big big problem.So, what we're going to do is something I would actually do in my real work, which is I would create some type of staging or raw data set.Let's say this one's our raw one.And we could have even called this layoffs raw.We're going to create another one.We're going to create a table.So, we'll say create table.And let's call this one layoffs_staging.And we literally just want to copy all of the data from the raw table into the staging table.So, we can do that really quickly by just saying like layoffs.And if we run this and we refresh, you'll see we have the staging database.
And let's copy this.

32. PowerBI Introduction and Basics

Introduces PowerBI as an alternative BI tool, covering the interface, data import, and basic report building.

Here we go.We'll do layoffs_staging.
And so now we have all of the columns.And all we have to do is insert the data.So we're just going to say insert.Then we're going to say layoffs staging right here.And we'll select everything from layoffs.And let's run this.And if we select the table, we now have all the data over.So super super easy.And now we have these two different tables.Now again, why do we do this is because we're about to change the staging database a lot.If we make some type of mistake, we want to have the raw data available.This does happen.This is something that you do in the real workplace because you're not going to work on the raw data.It just you shouldn't do it.It's not best practice.So I'm going to show you what I would actually do in my, you know, like a real job.
So, that's what we're going to do now.We're only going to be working off the staging database, and we can copy this and make different databases for different things.Um, as long as we have our raw data, we can really do anything we want going forward.Uh, and that's what we're going to do.So, the number one thing we're going to look at is to make sure that we are removing duplicates.We want to make sure we don't have any duplicate data in here, and if so, we're going to get rid of it.Now, really quickly, if you did my Microsoft SQL Server project, we did something very similar, but we had an extra column over here that gave the unique row ID, which made it really easy to remove the duplicates.Here, there is no identifying factor that's going to be easy for that.
So, I'm just going to tell you up front, removing these duplicates is not going to be easy, but we'll walk through it every step of the way.So, what we can do is try and do something like a row number and we'll match it against all of these columns and then we'll see if there are any duplicates.Now, I'm just we're starting off strong.Okay, we're jumping into kind of some of the more advanced things.It does get actually easier as we go, but this is the actual order that I follow.So, uh I'm going to keep it.So, let's try to identify duplicates.So, let's copy this.Let's pull this down.Do underscore staging.There we go.Now, what we can do is we can do row number and we'll do that partition by basically we could do every single one of these columns.
That's kind of what we're doing.So, what we can do is we can say everything.Then we can do a comma and we'll say row number and be just like this.And we're going to do this over and we want to partition by all of these columns essentially.We could just do a few for now to see if we get any hits and then we can look at that.But they're going to be multiple companies that have layoffs in the same location and industry.Although their total laid off would probably be different.The date would probably be different.So if we do something like uh company, let's do industry.We will do total_laid off, percentage laid off.And then let's do date.Now I'm doing date with the back ticks because date is a keyword in my SQL.So if we do it like this, it just really makes it easy.
So we're going to partition by all of these things.So let's do partition by and let's bring this down real quick.So I'm just going to say over partition by and we're going to call this as row_num.Now let's try running this.Let's see if it works really quickly.It's important.And over here you can see that we have our row number.Now these mostly are unique and these all look unique.I'm not going to scroll through all of them, but we want to be able to filter on this.So we can filter where the row number is greater than two.If it has two or above, that means there's duplicates.That means there's an issue.So let's go ahead and we're going to take this.We'll put it into either a uh subquery or a CTE.I'll create a CTE for this uh because it's really easy.
So we'll say four or not four, we'll say width and then we'll do uh duplicate_ct as then we'll just do our parenthesis.We'll paste this in here and get rid of that right there.And now we're going to say select everything from this duplicate CTE.Then we'll say where row num is greater than one.Let's run this and add a semicolon.Let's run this.And you can see that these ones have duplicates.So these are our duplicates actually.And we want to get rid of these exact rows.Now just to confirm that these are uh the duplicates, let's look at this one.I've never heard of this company.Um but we'll take it really quick and let's select we'll say where company is equal to.We'll call this ODA.So, let's run this.And it looks like these No, no, no, no.These aren't duplicates.
That's a good thing we checked.Okay, because it looks like um these aren't the exact same.Although they're very, very close, these technically are not duplicates.So, I'm glad we checked this.We need to do this partition by over every single column.That's what I'm realizing.So, we'll do company, location.I'm glad I'm genuinely glad we're, you know, it's good to make mistakes um and figure things out as you go.It really is important.So, company, location, industry, total laid off, percentage laid off, date, then we'll do stage, and then we'll do country, and then funds raised millions.So, we're changing the CTE to partition over everything.So, now let's run this.Okay, ODA is not in there.That's the only one we checked.Um, but let's look at Casper.I know this.These are the um Aren't these the mattress people?Didn't know they had layoffs.
Poor guys.Um, all right.Let's take a look.It looks like this row and this row are duplicates.These are our duplicates.So, we are going to want to remove only one of those.We don't want to remove all of those.So, um, just looking at this one example, it looks like this, uh, query is working well.So here's our duplicates.Now we need to identify these exact rows.We don't want to delete both of them.When we looked at Casper, there's the real one that we want to keep.Then there's a duplicate that we want to remove.We don't want to remove both.That would be bad.Now in my SQL, it's a little bit trickier to remove things than it is in something like Microsoft SQL Server, Postgrace SQL.Um they have different ways that they can delete rows.For example, in Microsoft SQL Server, we could literally identify these row numbers in the CTE and delete them from it and it would delete it from the actual table.
We can't do that in my SQL.And I'll show you uh let's actually copy this.We'll go like this and we'll say uh let's say we want to delete these.We'll say delete from we're deleting this from where the row number is uh greater than one.What am I writing right here?Delete.There we go.So delete from this duplicate CTE where the row number is greater than one.That's all these duplicates.We want to remove them.Let's try to do this.Let's run it.Let's go down.If we look at the bottom, it says the target table duplicate CTE of the delete is not updatable.

33. PowerBI Data Modeling

Covers relationships, data models, and DAX measures for building robust PowerBI reports.

So you cannot update a CTE.A delete statement is like an update statement.Um essentially.So what we are going to do is we're going to do something a little bit different because this is how I would love to do it.That makes it super super easy to remove duplicates.But that is not always the way that things happen in the real world.I think what we should do is take this right here and let's run this.We should take this right here and put this into let's say a staging two database and then we can delete it because we can filter on these row nums and we can delete those which are equal to two.So it's essentially like you know creating some type of table and then uh just deleting the actual column.So we're that's exactly what we're going to do.So it's essentially just creating another table that has this extra row then deleting it where that row is equal to two.
So you know somewhat fairly straightforward but um let's try it and let's see what happens.So we're going to come down here and do is create our table.Uh let's try doing that with here.Let's uh let's copy to clipboard a create statement.Let's see if this works.Perfect.That's exactly what I wanted.Now, all we're going to do is say we're creating the table layoff staging 2.Now, this is a create table statement and we're naming the columns and then we're also assigning the data type.So, we have all these things, but we want one more.Let's do a comma and we want to add row_num.And I need to underscore num.And that should be an integer data type.So, we just keep it just like this.Let's go ahead and copy this and let's run it.See if it worked.Bring this up.
Looks like it worked properly.Uh, and let's say let's go back up.I want to rewrite things that I don't have to.Let's run this.So, now we have this empty table.So, we want to insert this information right here.So, we're going to insert into.So, we'll insert into and then we'll do this right here.So, insert into staging two.Now, let's try to run this.See if it works.And let's run it.And let's select that table.And now we have it.So, let's pull this back up and I'll walk through what we just did because I know I'm going quick, but we have so much to cover um in this lesson.So we just inserted basically a copy of all these columns but in this new table we added one more the row num.So now we can filter and we can say where I need to spell that right where row num is equal to two or we should should say greater than one because some might have multiple duplicates.
And there you go.Here are our duplicates.Now we're going to delete these.So all we have to do is come right back down.Where'd I go?Copy this.Come right back down here and we're just going to say delete from.We just did a select statement.I always recommend doing that to identify what you're deleting.Then you change it to delete.And now if we run this go.And I'm actually going to keep this.Um let me see.There we go.And let's run it again.And now they're gone.And if we say um just the whole table.This looks wonderful.Now, this row num is going to be a column at the end that we probably don't need anymore, right?It's a redundant column.It adds up extra space in memory and storage and all these other things and processing times.We're just going to get rid of it.
Uh that'll be at the very end, I'm sure.So, it looks like we are good to go.That's how we remove duplicates.Now, um there are different ways to do it when you have different columns.Like if you have a unique column over here, makes it so much easier.So, so so so much easier.But we didn't have that.So we had to kind of do a workaround.Uh welcome to the real world.Now let's look at standardizing data.So standardizing data is finding issues in your data and then fixing it.So I'm already noticing right here.It looks like we have a space at the beginning.Uh we could easily just do a trim on this column.Um and let's I'm I don't even think I was um I did this when I wrote out all the the scripts for this.Let's just do from this table.
Why am I writing it all out again?We actually want to select the company and then the or actually we'll just do distinct company.Distinct company.Let's run this.And if we do a trim around this, let's run this again.And that looks better.So, if we do uh company company, comma, and then we'll just do the trim.I don't want to we don't need to do distinct right now.We'll do the company.This just looks better.So, we're going to update that.Uh it's super easy.Now, if you ran into an issue just a second ago, uh I may need to help you change that.So, if you couldn't update or delete those things earlier, I should have told you this earlier.I apologize.All you need to go is to edit.You just need to go to edit, go to preferences at the very bottom, go to SQL editor, go all the way down to the bottom, and right here we have safe updates on.
If you have this selected, that means you can't update anything.That's a problem.So, what you need to do is select this uh or unselect it like I have it and save it.You may have to even restart your MySQL potentially uh in order for the changes to take effect, but then you should be able to update that.Now, all we're going to do is update this table.and we're going to set.And now we need to come back here and we'll say we're going to set the company equal to trim.Now, if you don't know what trim is or you haven't taken that lesson, trim just takes off the white space off the end.So, it took the white space out of here or off the right hand side as well.So, we're going to update this and let's do a semicolon.A semicolon.
Let's run this.Let's select this again.And it was updated properly.So, we're already off to a great start.Now, the next thing that I want to take a look at is the actual industry.So, let's go back.Let's copy this and let's take a look at the industry.So, we'll do industry and we'll run it.Now, if you look in here, there's a ton of different industries.Um, and there's marketing and marketing.Oh, because I haven't done distinct.Uh, please ignore me.Let's do distinct.And there's a ton of different industries in here.Transportation, healthcare, consumer, uh there's a blank one, which we'll take a look at.Aerospace.There's a lot of really unique ones.Let's actually order this.We'll do order by uh and let's just do one, which is the first column.We're just ordering our own stuff.So, we have null.

34. PowerBI Dashboards and Reports

Demonstrates building complete PowerBI dashboards with visuals, filters, and interactivity.

We have blank.That's a problem.We'll take a look at that later.Uh but this is an issue.Crypto, cryptocurrency, and cryptocurrency.These are all the same thing.These should all be uh on or labeled the exact same thing.The reason we need to change this is because when we start doing uh the exploratory data analysis visualizing it, these would all be their own rows, their own unique thing, which we don't want.We want them all to be grouped together so we can accurately look at the data.Let's take a look at any other ones.Fintech and finance, that could be the same thing.I'm not 100% sure.I'm not a fintech person.Um, I think for now the only one that I'm confident in changing is this one right here, which is cryptocurrency.So, let's go ahead and update that.So, all we have to do and we need to actually let's select really quickly where it's like crypto.
So we'll say uh where industry and we want to select everything where the industry is like and we'll just do crypto.They all start with crypto, right?Yeah.So we'll do crypto just like this and let's run this and let's just take a look.Lot of layoffs in the crypto industry.Good night.All right.Let's find where it's cryptocurrency.Okay.So, even this one, it's crypto.And I know Gemini crypto.Crypto.And then it says cryptocurrency.So, these should be all crypto.You see how 95% of them are crypto.So, we're going to update these other ones.Oh, this one is C R Y PT.Is that how you spell crypto?Jeez, I don't know anything.All right.So, we want to update all of them to be crypto.So, what we're going to do is we're going to say update layoffs industry 2.We want to set the industry equal to crypto just like this where and we can do it a few different ways.
We can say industry.We I think we can do like let's try this real quick.I I some of this stuff I don't have planned out.I'm just kind of going with it as we go.Um which I like better.You know, we kind of we work together on this.We figure these things out together.That's what I like.Um then we'll do like crypto just like this.Exactly like we had it up here.So, if it's like crypto, it should be crypto.Let's try this.Let's see if it ran because it may not have.I can't remember.Yeah, it worked.Okay, so it updated uh three rows and that looks correct.Now, let's go back up and let's run this.And as we scroll down, they are all the exact same.Beautiful, beautiful, beautiful.So if we do uh distinct industry again, let's get rid of this.
If we run this query and we scroll down, crypto is its own thing.Beautiful.And it looks great.We can look at those later on how we can update those.Um but let's keep going.Let's look at our whole table again.And these blanks and these nulls are actually an issue.We do need to deal with them.But I I my instinct is telling me go fix it.Um but my you know tutorial side is saying okay stick with uh the tutorial the order that we agreed on.Um so let's go take a look.So we've looked at company, we've looked at industry.Um let's just real quick look at uh distinct uh location.Now it's good to look at most of these things, right?There could be small tiny issues that you just never saw.Um, and we're just going to order by order by one.
Just do a real quick just a scan to see if we find any issues.
Um, that could be an issue, but that could just be another language if I'm being honest.I don't know.I'm as I'm just scrolling through here because I want to make sure because this is not something I had in my uh pre-written script.This looks pretty good to me.Um, let's do everything.We'll run this and now let's look at country.So we'll do distinct country and let's run this and let's scroll downagain.This is sometimes just what I actually do.All right, we got an issue right here.Super common.Somebody put a period at the end.Some dingus.Uh and we're not going to judge that person.I don't know who it was or who ruined this data set, but um yeah, that's a problem.So, we're going to need to just update that.It looks pretty simple.Um, but I'll just say where country is equal to or let's say like and then I'll say like United States.
There we go.And oops.I'm going to say select everything.So, I just want to see um where it's at.Oh jeez, there's too many.Let me see if I can spot it.I can't spot it.It looks like they're supposed to be United States, not United States dot.That's the issue.Um, we can easily easily fix this.And we can probably Let's do um really quickly, let's do select, oops, select distinct, and then we'll do country, comma, and then we'll do a trim because we want to get rid of that um that one.We'll do country.Now, just doing the trim won't fix it.Let's go to the bottom.So, that doing the trim doesn't fix it.But here's what you can do.It's a little trick of the trade here.We're going to do something called trailing, which means coming at the end.
So, what's trailing?The period from country.Let's try running this.Scroll to the bottom.And it fixed it.So, this is a little um a little advanced little tidbit for the trim here.We can do trailing from the country and we're looking for something that's not a whites space.We're specifying we're looking for a period.So now what we can do is we can say update.We can set the country do update um this table and we'll oops and we'll set what am I doing?What's going on here?We'll set the country equal to and we'll do it just like this.But we're only going to do it for a country, right?Uh so we'll say is equal to trim and we'll say where country is equal to or actually let's say like and let me see if I have this.I don't.Let's let's just say like United States like we had before.
Just like this.So let's go ahead and update this after I put my semicolon in.Let's run this.And let's run this again.

35. Python Programming Basics

Begins the Python series with core syntax, variables, and fundamental programming concepts for data work.

It shouldn't need to fix it anymore.It's just one row.That's perfect.That's exactly what we wanted.Now, one thing that's really important, uh, and this is, you know, this is a longitudinal, it's not the right word at all.Give me a second.I can't I can't speak and write at the same time.So, sometimes I just say, uh, dumb things.Um, uh, if we want to do not longitudinal, but, um, time series, that's the word I'm looking for.If we're trying to do time series um exploratory data analysis, time series visualizations later on, this needs to be changed.Right now it's text and we can look at that by going right.Actually, let's refresh this.We're not looking at staging.We're looking at staging two.If we look at the columns and we come down here to date, it is a text column.That's not good.
If we're trying to do uh time series stuff, we want to change this to a date column.Now, how can we do that?Let's take a look.So, let's do date and let's not actually do it like that.Let's do date backslash.So, we're just going to look at the date.Now, let's change this because we want to format it how we want to format it with it, which is month, day, year.So, how can we do this?Well, there's something that's very, very helpful, works perfectly in this situation, and is exactly what we're going to do.It's called string to date.So we're going to do string underscore there it is right there undersc_2 date.It literally helps us go from a string which is a text that's the data type to a date.So it's perfect.Now all we need to do is pass through two parameters.
We have to pass through the column which is the date column and then what format we want it in.Now if you haven't done date formats before I'm going to kind of walk you through it while we're looking at it.Um in order to format this properly you use a percent sign.This is going to be a formatting for a month.A lowercase M.A capital M is something completely different.I believe it's spelled out.I need to I we can look at that in a second if we want to actually.And then we can do this right here.And then we'll do another one.So we're formatting it in the way that we want it, but also converting it to an actual uh date column.So now we want month and then we want day lowercase day.We'll do a forward slash and then another percent sign and then a capital Y which stands for I believe the four um four number long year.
Uh I have a let's just um let's look at this real quick.So it worked perfect.So we're it's taking in this format that it's in right over here and converting it into the date format.So this is the standard date format that you're going to find in my SQL.Now let's see what happens really quickly just for fun.Uh, let's see if we do capital M.Uh, it looks like that's not going to work at all.Uh, let's do lowercase Y and um just formatted it to 2020.I think it took the first two numbers it looks like.I don't know why it's doing that if I'm being honest.Um, but if we keep it with the capital Y as we should, this looks perfect.This looks exactly like what we're trying to do.So, you can mess around with it.It depends on the how the data is formatted in your original column when it converts it to the string to date.
And there's a lot of different stuff.You should just look up um date formatting in my SQL.Really interesting stuff.So, we're going to update this date column to this, which is our new date column.Let's go ahead and do that.We're going to say update.You guys should be getting used to this by now.That's the whole point is getting used to doing these things.So, we're going to set date equal to and then we're going to put in this right here, the string to date.Go ahead and do this.And let's run it.Make sure it worked.2355 rows.It looked like it did every single one.Uh, but let's go ahead and get rid of this and let's run it.And it looks like it worked perfectly.Now, there were some nles.It looks like and that'll be something we have to look at later when we talk about nulls.
But um overall I believe this looks proper.Now if we refresh this, let's refresh.Let's come down to the date.You'll notice it is still a text.It's date.It's called text, but now it's in the date format.Now that's really important.And maybe I should have done that earlier if I'm being honest.Um tried to convert it to a date column.It wouldn't work.It would give us an error.Um you just have to trust me on that one.But now we can do it where we can change it to a date column.So let's do alter table.Now only do this, never ever do this on your raw table.Only do this on things like a staging table because we're about to completely change the data type of the actual table.So we want to change the layoff staging too.And then we're going to come down here and we're going to say modify column.
And what column are we modifying?It's this date column.There we go.And we want to change it to what data type?A date.And am I spelling this right?Yeah.I just need a semicolon here.Whenever I see an error, I always you got to just look for the semicolons.So, let's go and run this.And let's refresh.See if it worked.And the date was changed to a date, which is perfect.That's all we wanted to do.Uh just to make sure we were doing what uh or we'll set ourselves up later in the future really well.Let's look at our table.All right, this is very good.So, we fixed a few uh just issues with the company.I believe something with the industry or the cryptocurrency.We changed the country.Um I'm just going to go ahead and tell you right now, this one uh we're not going to look at until we look at the um nullles and whatnot in just a second.
So, we're not looking at that one yet.And then uh we have this extra column that we've done.So we've done a lot so far, but the next thing in the process, step one was remove duplicates.Step two was standardization.Step three is working with null and blank values.Now this is going to happen.You're going to have nles and you're going to have uh blank values in here.I it's somewhere um it's just going to happen.And so we need to think about what we're going to do with that information.Whether we want to make them all nulls, make them all blanks, try to populate that data.Let's see what we're going to do.So let's start off with the total laid off.We'll just do uh where total_laidoff is null.So in order to look at the null, we say is null.
Let's try equal to null.It's not going to give it to us.We have to say where it is null.

36. Python Data Structures

Covers lists, dictionaries, loops, and functions in Python as building blocks for data analysis.

So we have these values.These are completely null.Uh there's quite a few of them.But remember this is also useful information.But if they have two nulls, uh that probably is pretty useless to us.Um that's something I think we'll take a look at in a little bit.Actually, we'll say we and we may save this query.Percentage uh laid off is null.So if they're both null like these, these are all I believe fairly useless to us.These might be ones that we remove.So let's actually look at this.Um in step four we look at removing rows and columns.But one thing we should take a look at I remember this industry.Let's do uh industry do distinct.This industry had some missing values and let's take a look at that.Okay.So we have a missing value and we have a null here.
So let's look at this query and let's say where industry is null or do industry is equal to a blank like this.We'll select everything.Let's run this.All right.So it looks like there are a few that are blank.Now, what we can try to do is see if any of these have one that's populated.Let's take Airbnb for example.Let's search for this really quickly.And this is 100% um you know, it's just helpful.It's really really helpful to be able to populate data that is populatable.Is that a word?Um let's try it.So, we'll say uh select everything.I just wanted to do where spell that right where company is equal to and let's do Airbnb.There we go.Let's run this.And it looks like we have this one right here.So, for example, um these whether they have them or not, we're going to try to populate these.
If this Bs or Carvana or Jewel had multiple layoffs, these ones should if these ones aren't blank.If they have one that's not blank, we should be able to populate it.For example, um not the one I was trying to do.If we look at Airbnb, this one has travel.So, we know this is the travel industry.So, we can populate this with travel.Again, we want this data to be uh the same.So, if we're trying to look at, you know, what industries were impacted the most, this row isn't going to be affected or this row won't be in our output because it's blank.We want that to be traveled to represent the data properly.So, we want to update it.So, if this one has travel, we should be able to update this row with this travel right here.So, let's see how we can write this.
And let me give myself some rows right here.All right.Now, what we're going to need to do is try to do a join here.So, let's try running out in a select statement and then we'll just change it to an update if it works.So, we're going to select everything and we're going to do this from staging two.from staging two and we'll call this ST2 and then we'll join on itself because what we're going to do is we're going to check in this table does it have one that is blank and not blank.If so update it with the non-blank one that's essentially uh in layman terms what we're trying to write but writing it out could be a little bit more difficult.Um, so we're going to join on itself and we'll call this let's actually call this table one.T1 and T2 because they're the exact same table.
Uh, and we'll do this on and we're going to say T1 company is equal to T2 company.So the company has to be the same.That's important.And we probably should do the location is the same as well.Now we'll do and T1.loation location is equal to T2.loation.I'm imagining, you know, there's another Airbnb in like South America somewhere that's called Airbnb, but you know, I'm just imagining a scenario, right, where we have to think about different use cases rather than just large companies.So, those other ones, they may have ones that are in different locations.We don't want those um we don't want to change them if they're not the same.So, these are the same.Now what we want to find is we're going to say oops we want to say where then we'll do t1.industryis null and then we want to check that t2.industry is not null.
We'll say and t2.industry
is not null.And let's just run this.Let's see if we get anything.So let's think this through because we got nothing in our output.We're selecting everything.We're joining on the company and the company um and the location where T1 industry is null and T2 industry is not null.Let's just get rid of this for a second.I just want to see if this changes anything.It doesn't.And it's possible actually that instead of doing is null, we could do or and this I'm glad we're walking through this.We can do or is equal to blank.And let's try running this.There we go.Okay, so it looks like there's Jewel, Carvana, and Airbnb.These ones all have industries um where it's null or blank and an industry is not null.So that's really good.Now, if we scroll over, see the industry here.
This is our T1.This is our first table.If we scroll over, I bet we'll see the T2 industry where it's not null.Let's scroll over.And here's our industry.We have travel, transportation, and consumer.So, this worked exactly as we had hoped.I can even um pull this up here just to show kind of show you a little bit easier what that's doing.And we'll do T2.industry.This is kind of like what we're trying to do.So, if it's blank, this one is going to be populated into here if there is one that is not blank.So, that's essentially what we're going to do.Let's write the update statement and we're going to see if it works.This we have to translate this to an update statement.So we'll do update and we're going to update uh this right here.So we'll say update T1 and then we'll do the join right there.
And now we have to do a set statement.So we'll set uh the T1.industry equal to and I'll just copy this T2.industry.I just don't like I don't like writing things out.Um then we say where.So we do this just like that.and let's add a semicolon.Okay, let's confirm.So, we're updating this table T1.We're joining on T2 where the company is the exact same.We're setting T1 industry equal to T2 industry.So, the T1 should be the blank one.So, where the T1 industry is null or blank and T2 industry is not null.Let's go ahead and run this semicolon.See if there were about three updated.Yep.Rematch zero rows affected though.Let's go take a look.We have to let's run this query.Looks like those are still null.Let's run this.Uh, that one is still blank.Now, let me think here.
I'm I'm trying to think of why this didn't work.And I want to walk you through my thought process.It is possible that because these are blanks and not nulls that it's not working.I and I will say that is something I typically do where I set these blanks to nulls first.So let's actually try that and see if that changes anything.I'm just going to update uh this.I'm going to say set the industry equal to null.We'll say where industry is equal to blanks.So, we're just changing it to null where it's blank.

37. Python for Data Analysis

Shows how to use Python to manipulate, analyze, and visualize data in practical workflows.

Let's try this.And let's go back down here to our select statement.So, these are all nulls.Okay.I think I think this is now going to work because now you can see on this side it's going to it there's only one option for it to populate it.Before there were those um blanks which I think was causing the issue.Um, let's get rid of this part because now we have no nulls.And now let's try running this.We're workshopping this on the fly, guys.Uh, let's see.Three rows affected.Heyo.All right.Let's go see if it worked.Um, let's run this query.And we have none.That's perfect.Let's look at Airbnb.All right.All right.Ran into some issues, but we worked through it.We figured out the issue and now it's working properly.And we can even come back up here to select everything.
And it looks like Bailey's is the only one that still has a null.Let's look up Bailey's real quick and we'll say our company is like uh Bailey.Let's run this.Yeah.And there's only one.So there wasn't another row.All these other ones like Carvana and um I can't remember where the other Jewel and Airbnb, those ones had an extra row.They did multiple layoffs.This one only did one layoff.So, we don't have another populated row where it's not null to actually populate the null row.That's really all that happened.Uh that's why that worked that way.So, I'm really happy that worked.Awesome job, guys.Uh I was starting to question myself.Do I even know how to use my SQL?I mean, I was really starting to question my abilities here.um take a look.Uh I think that is all we're going to do for populating null values.
Now, here's why.Things like total laid off, percentage laid off, um funds raised, how are we going to populate that with the data that we have here?I don't believe we can.Now, we might be able to populate Oops.We might be able to populate some of this if we had the um company total like if we had the original total before laid off because then we could do calculations like um oh these companies went completely outof business.That's not good.At 1% that means 100% was laid off.Um but if we had you know the total they had 50 employees and 100% were laid off.We could populate the total laid off.Whoops.Did it again.We could populate the total laid off by saying if this is 50 100% was laid off that's 50 people were laid off.We don't have that data so we can't go and populate it I don't believe funds raised we might be able to scrape some data from the web and populate this but that's a totally different thing um not part
of this project.So I think the data cleaning for the null values and blank values I think that's going to be done.Um, it's possible that the stage could be the same and if you want to go check, you can, but we're going to keep chugging along because we want to remove columns and rows that we need to.Now, if you remember, we were looking at this before.Did I save that uh query?Let's go look.Here we go.Bring this down to the bottom.All right, these rows.Let's let's really take a look at these um and think about if this is going to be help to us.Um what we are trying to do with this data in the near future is we're not just trying to identify a company or a location that had layoffs and maybe we are maybe that maybe we are trying to
do that but these have no layoffs and no percentage laid off.So in my opinion I don't know if these laid off any at all.Um I believe that we can get rid of these.Now deleting data is a very interesting thing to do.You have to be confident.Am I 100% confident?No, not really.But I'm confident enough to know that what we're about to look at in the next one, we're going to be using these total laid off a lot, percentage laid off a lot when we're looking at um you know,actually querying the data and doing some exploratory data analysis.So, we're going to use these a lot.I don't think uh these I'm not even sure if these are accurate.I'm not even sure if they actually did have a layoff.It's saying they did, but it doesn't show if they laid off any.
So, um, can we delete this?Yes.Should we delete this?It's iffy.Uh, I'm not 100% if I'm being completely honest.And there's a lot of rows like that.This is This could be like 100 or so.Really not.I mean, I could run a query and run it, but I don't want to.I don't It's not a big deal.The point being, I don't think we need this information.So, we're going to get rid of it if nothing else just to show that you can do it.So, now we'll say uh delete.And then we'll do from here.There we go.So now we're going to delete these rows.Let's try to select them again.And they are gone.So we deleted the ones where the total laid off was blank and the percentage laid off was blank.We just I can't trust that data.
I really can't.Um and let's go back down.Come right here.Semicolon.So I sometimes I have to walk myself through these things.Um all right.this row num.I mean, come on.We don't need that anymore.Let's get rid of it.Um, so what we can do now, it's a little bit different syntax.We want to drop a column from this table.So, we have to do the alter table again.So, we're going to alter table layoff staging two.And then we're going to say drop column and row_num.If we run this then we run the table again should be gone and it is.So this is it.This is our finalized clean data.Now in the next project we're going to be doing exploratory data analysis on this cleaned data.We're going to finding trends and patterns and running complex queries.It's going to be phenomenal.
I'm super excited about it and I love this data cleaning one.Um I made some mistakes.I'll be the first one to admit.But cleaning data is not always a straightforward thing.Um, you know, you have to you kind of mess around with it, figure it out.Uh, and and you know, that's what we did.Uh, whoa, took a while.So, just to recap, we removed duplicates, we standardized the data, we looked at the null values or blank values, and we removed any columns or rows.So, we did a lot.Um, and if you go back and you actually scroll through here and look at some of this code that we wrote, uh, it's not super beginner stuff.So, if you're following along with these things and you are getting this project, this is a fantastic project to put on your portfolio.

38. Pandas Fundamentals

Introduces the Pandas library, DataFrames, and essential operations for working with tabular data in Python.

I myself would put this project on my portfolio because it's a very, very relevant thing.So, I hope this was helpful.I'm just going to keep scrolling while I talk, but I hope this was helpful.I hope you learned something.We did a we did a lot of different things that we didn't even do in the lessons, which I like doing because you can't cover every single aspect of my SQL in lessons, right?Sometimes you just got to get in there, get into the nitty-gritty, clean some data, and you'll find uh or discover new things, try new things.Um, and now we're getting to the bottom.And awesome work, awesome, awesome, awesome work.Uh, this is an A1 project.I think this should be in everyone's uh portfolio.If I don't see it in your portfolio and you know you send it to me, I'm going to say it's the garbage portfolio.
So, this is a good one.So, with that being said, thank you guys so much for watching.I If you made it all the way to the end, you're still listening to me.Awesome work.Really awesome work.For real.I you know, you're just following along with the tutorial.That's what it feels like.But by the end of this, I I just know you're learning a ton and you're you're trying new things and you're really pushing yourself beyond just simple tutorials.So trust me when I say this is not easy.Not everyone was able to make it to the end.So great work getting here.So I will uh see you guys in the next project when we actually explore this data.We'll walk through a lot of different ways to do that.So thank you again for watching.If you like this, be sure to like and subscribe below.
I put out tons of content about all this stuff and I absolutely love it.It is definitely one of my passions in life.So go ahead and do that and I will see you in the next video.
Hello everybody.In this project, we're going to be focusing on exploratory data analysis.Now in the first project we worked with this exact data set and we cleaned up the entire thing and that was a really good project and it set us up to explore the data and with all that cleandata we'll be able to look at our data much better and find better insights while we are using it.Now normally when you start the EDA process or the exploratory data analysis process you have some idea of what you're looking for sometimes not always and sometimes when you're exploring the data you also find issues with the datathat you then have to clean.So even though I did a data cleaning video and then an exploratory data analysis video and they're kind of separate projects, sometimes those coincide together where you're exploring it and cleaning it at the same time.
Now what we're going to be doing here with this data set, we're just going to be kind of exploring it.I don't have any agenda.I don't have any, you know, one thing that I want to look at.I just kind of want to look at everything and we'll kind of discover and go uh about things as we are learning and looking at this data set.We will however start off really simple with kind of the basics, work a little bit more towards the tougher stuff and then at the end we'll have some more advanced things that I think will be really fun.So with that being said, let's start off with kind of more easier things.We'll kind of just ease our way into exploring this data set.Let's pull this down and let's copy this right down here.Now we're going to be working with this total laid off and percentage laid off or most likely this total laid off quite a bit.
The percentage laid off isn't super helpful because we don't know how large the company is.We don't have another column here that says here's how many total employees they had.And then okay, they had a percentage laid off.You know, we won't work as much with this one, but we'll work quite a bit with this total laid off.Let's look real quick.We could look at something like the max uh total.And I need to use a parenthesis max total laid off.And let's look at this.So on one day there was somebody out there who had the max total laid off of 12,000 people.That's a lot of people to lay off in one, you know, one go.That's a lot.Let's also take a look at the max and I think it was percentage laid off.Let's run this.And it looks like one.
Now one represents 100.That means 100% of the company was laid off.Um, and that's, you know, that's not great.Uh, that just means an entire company went under essentially.We can actually take a look at that because I'm interested to see, you know, if there's any companies I recognize or can see, um, where, let me come right down here where the percentage laid off is equal toone.Let's go ahead and look at this and let's take a look.So, we have this ahead.I'm just going to go through here and see if I recognize any of these.Uh, some in the crypto space.BlockFi.I feel like I recognize that one.I don't know.Uh, let's keep going.Deliveroo.It's not good.They left like let go of 120 people.Uh, I'm just curious.I mean, I'm I'm just kind of scrolling through here trying to see if I recognize any.
These are companies that like completely went under or or lost all their employees.Volt Bank.Interesting.just interesting to me.We're going to be taking a look at a lot of stuff.Um, but these are companies that completely went under and that's, you know, unfortunate.We can also order by uh total_laid off in that's not how you spell it.In descending, we'll see which company went under had the largest.So, this one had 2000.Construction company had 2400 people they went um under.Doesn't say what stage they were at, but that's in the United States.We can also take a look at and there's another column over here called funds raised in millions.Let's look at that one.So I want to see um these are companies that had a lot of funding or potentially a ton of funding.Uh let's go over.So this is like $2.4 billion I believe.
Like I think this is like a ton of money.Um Quibby I believe I know this company uh in BlockFi.I I thought I had heard of them.I'm pretty sure I know who that is.So, Whibby is one that I'm definitely familiar with.It was like a short form uh media company.Yeah.Yeah.And then there's British Volt, which looks like an electric company that went under.So, you know, some big companies that went under um in 2023, 2020, 2022.So, that's interesting.So, we have a lot of companies here and we're just looking at um that had total laid off.But, let's take a look.Let's let's use group by real quick.I want to look at the company and I also want to look at the sum of the total laid off.And for that we need to use a group by the company and let's just start with this and I'm sure we'll use an order by in a second.
Yeah, let's order by order by let's just do two for now in descending and two stands for one two this is the total it off.So, uh, for the total for this table, and we don't know how far go back it goes.We haven't checked that yet.We'll check that in a second, but for this table, you should recognize a lot of these companies.So, I think it starts in like 2020 until like sometime in 2023, but this is Amazon let go of 1,800 people, Google 12,000.I'm guessing that's at one time because that was the max that we looked at earlier.Uh this is Facebook or Meta, Salesforce, Microsoft, Phillips, Uber, Dell, Cisco, Pelaton.I mean these are a ton of big companies.Arvana, they let go of thousands and thousands and thousands of people.Twitter, that's not surprising, uh given what's the change of things.
Groupon, um ton of ton of people or a ton of companies and that's a lot of people that have been let go.Now, let's really quickly uh before we keep going, I want to look at our date ranges real quick.So, let's select everything.Um, whoops.We'll do from there.And how do we want to do this?Let's do minimum of date.And let me do it like this.Date.And then we'll do uh the max as well because I want to look at the date range that we have here.Let's run this.

39. Cleaning Data with Pandas

Demonstrates handling missing values, duplicates, and data type issues using Pandas.

It looks like it starts in 2020 of 311.So right when like I believe the pandemic started or the uh COVID 19 started.I want to say that's like right when it hit at least us in the United States.Then this is almost exactly three years later.So early 2023.So just in those three years, you know, here's some of what we're looking at.These companies have let go of quite a few people or had layoffs.We could also take this exact thing.Oops.What did I do here?Copy this again.We can also take this exact thing and look at quite a few other things.There was um the industry.So we can look at industry like what industry got hit the most during this time or had the most layoffs.Um all we're looking at right now is total laid off.We can also look at um percentage in a little bit but looks like consumer got hit really hard, retail really hard.
That makes a lot of sense with shops closing down because people couldn't come in for the corona virus.Now we're just making assumptions, right?Um but you know during that time it was mostly COVID that impacted a lot of stuff.Then we have transportation, finance, healthcare, food, real estate.Um, yeah, there's a lot a lot of people.Let's look at the lowest ones.Manufacturing, fintech, aerospace, energy, legal.So, low numbers on those, high numbers on these.So, really, really interesting.Uh, let's go back up.Just want to look at our whole table really quickly.See what we got while we're looking at this stuff.And let's run this.Now we looked at the company, looked at the industry.I would really be interested to look at the country as well.Which countries at least from this data set and we can copy or we can go right here country because I believe that United States had the most.
Holy mackerel, they had by far the most.Uh then India, this is 256,000 people um lost their jobs.We'll look I think we'll look at the dates in a little while like at kind of like time series like how many per year per month per day or whatever we want to look at but goodness gracious uhthat's a lot of people within just three years in the United States India Netherlands Sweden Brazil Germany uh United Kingdom then it goes down and down and down but these are just reported um from this data set thatI I had gotten.So really really interesting.Good night.the United States had much more than than most for sure.Um, let's actually look at that date real quick or we can look at it by year.Um, so we have this date and if we do it like this and we can do by date real quick.
So this is going to do it by individual date.And let's order by let's do one.So this is the most recent date.So it's literally by date that's reported.Um, we don't want that.Let's do it by the year.So, 2020, 2021, 2022, 2023.We can do that fairly easily.We'll use this year function.And we'll group by the year as well.Let's try running this.There we go.It looks like in 2020, 80,000 people.2021 uh 16,000.160,000.in 2022.This looks like the worst year.And then it's only we only have three months of data in 2023.There's 125,000.Holy smokes.So in 2023, it looks like we're ramping up because I'm recording this in 2023, about a month after this data set that we got this data set.There's 125,000 people um around the world, you know, but just in those first three months.
So this is going to be a lot higher than even 2022.That's pretty wild.Um very very interesting one other one one while we're looking at group by um there's there was a column and you can go back and look at it if you'd like but it's called stage and this shows thestage of the company and if we run this and we're all just looking at total but if you look at the um stage of the company this is like the different series that they're in A B C DA I believe is like a series A funding that's like a super super starting oh This is like a seed phase.Then there's series A and then it goes up up up up until usually they go um like they do IPO or they get acquired or something.Now if we go up here and we do two descending I want to see which one had the most.
So this is post IPO.This is the Amazon, the Googles of the world, the large large companies that are post IPO or initial public offering.Then there's unknown.We don't know which that is.Um a lot of you know layoffs from acquisitions CD B all the way down.So, it looks like um most of it's coming from, you know, these ones right here.Really, really interesting.Let's go look at percentages.I'm just going to literally crying to say literally.I'm going to literally copy these.Um and with percentages, I don't think uh let me look at percentage.I don't think the sum is going to be a good indicator.I don't know if this is a good one to even look at because and then we're looking at company right now because percentages refer to a percent of the company, right?So, we don't have hard numbers because we don't know how large these companies are.
So, now that we're actually looking at this, this percentage laid off isn't super relevant.Um, really the one that's kind of more, you know, has better this is a better use for what we're looking at is this total laid off because again, we don't know these sums.We could we could look at like the average, right?Um but again, that just doesn't help us that much.I don't think um I think we're going to really dive into that too much is my uh is my feeling.Now, one thing that I would be really interested in is to kind of look at the progression of layoff, right?Uh you could call this a rolling sum.So, start at the very earliest of layoffs and do a rolling sum until the very end of these layoffs.Um, and let's go to the bottom.This is where it's going to start getting a little tougher.
Um, and there's, you know, we're just doing a little bit of exploratory data analysis.You know, do digging into this a little bit.You can go and dig into this as much as you'd like.You don't have to just do what I'm doing, but I'm just trying to show you some stuff.Now, let's try to do rolling total of layoffs.Um, we could do that on the day, although I feel like that's going to be way too many rows.Let's do it based off the month.So, right here in this month.Now, let's see if we do just the month.Let's do something.I'll show you the month.And that's going to be an issue.And I'll in my head I already know.But let's look at it.We could do something like select um from and let's get this.There we go.So, if we do um we'll do substring.
Let me add a semicolon.Let's do substring.And we want to pull out this month right here.So, we'll go one, two, three, four, five, six.So, start at position six.Um, and this is of course in the date column.We'll start at position six and then we'll take two.Let's just run this really quickly.And there's our month.So, this we can do this as month, right?um or like this.Is that correct?Yeah.So, as month.So, this is our month that we're doing it.Now, if we group on this and we do like something like a sum of total uh laid off, I think that's the column.And then we do a group by on this month.So, it' be like this right here.We'll do group by this.Let's try running this.

40. Python Data Project Walkthrough

Combines Python and Pandas skills in a complete end-to-end data analysis project.

We should be able to do month as well.Let's try this real quick as well because I don't want to have this if I don't have to run it.Perfect.So the months right here don't show us the year.So if we're trying to get a rolling to total of just the month, it's actually would work fine when we actually implement the the rolling total use um you know a window function.But the issue with this is it's just going to show us month.So this is 2020.This is January of 2020, 2021, 2022, 2023, any other years we have it.This is not a great rolling total.What if we did one all the way to I want to say it's seven, six, seven.Let's try this.Now, this is going to give us a much better Let's order this.Order by one.This is just our first column.
So, now uh well, we should do it where it's not.Give me a second.I'm I'm I'm figuring this out as we go.We'll do where uh the month write that where the month is not null.I'm just going to get rid of that one.
And of course, uh that doesn't work because we're looking at the substring.So, let's try doing this.There we go.Um it just wasn't reading in that month that I was trying to use.Let's go down.Now, here's what we're going to do is we want to take it from the very first month and we're grouping everything.So, these are all the layoffs from 2020 of 03.So, that's March of 2020.Then we have April, May, and these are the layoffs.So, this is really good.This is exactly what I was imagining in my head.So, we want this.This is just, you know, 12 months in a year, and we go all the way to the bottom.And I want to do a rolling sum of this.So, let's see how we can do that.And we'll use this logic in a little bit.
Let's copy this and let's do select everything.We'll do right here.Now, what we actually want to do now that I'm thinking about it is we want to take this data and we want to do the rolling sum based off this exact thing.So, we actually need to take uh this.Let's get rid of this.And we'll do it with a CTE.So we'll say width and we'll do rolling_totalthat we'll say as and then we'll put this in here just like that.So with rolling total as now we're going to say select and we'll just do from here.Now what we need to do is we need to select the month.So let's go ahead and select that month and we'll take it just like this.So we'll select the month and we need to do a rolling total.All we have to do for that is the sum of which column we're doing.
Let's actually change this real quick.Um we're going to call this as um total off.I'm just going to keep it simple.So the sum of total off.So now we're doing that, but we want to do it over.And all we need to add into here is an order by.We're not going to partition by anything because in here we already did a group by.So it's, you know, kind of like partitioning it.We just need to say order by and we just need to order by the month, I believe.So let's try that.And let's run it.Let's do that.And we actually need to since we're doing um this, we need this at the end.And we can rename this if we'd like.So we can do this as rolling total all lowercase.Let's try running this and let's see what we get.
Okay.And this looks correct.So, starting in 2020 of 03, we had 9,000 layoffs.Then the next total we added onto here.Now, this visually isn't the best.I would like the month right here as well.So, let me actually add um let me create its own row.Put a comma here.Then right here, I want to keep this total off so we can visually see better.Much better.Okay, so we have the month and as it goes down, we're having more laid off.Now, this is our rolling total.Here's essentially how this works.It starts with 9,628.Then it adds on the next month, which is 26,000, which equals 36,000.Then it adds on the next month, and we get 62.adds on the next month 69, right?It keeps going all the way down.This just shows each month how many were laid off and this shows a monthby-month progression all the way down to the bottom.
So, let's keep let's just, you know, take a look.In 2020 of 03, we had 9,000.By the end of 2020, we had about 81,000 or so.Then, at the beginning, right here all the way down to 2021.By the end of 2021, we only had 96,000.So 2021 was a good year.It looks like um comparatively we had 90 80 well let me see 91,000 people let go and here we only have 96,000 let go.So that's what uh 81 that's only like 15,000 people.That's like nothing um comparatively.Then in 2022 uh things start ramping up dramatically.It looks like we have um 12,000 people, 17,000, 16,000, and they're adding up.It's going from 97 all the way up to good night right before the holidays in 2022 of this past year.I mean, we had uh 247,000 people.So, that's like uh 13ome,000.
My math my math's really bad.It's like 150,000.And then we only have Oh, we have even more here actually.And then we only have the first three months of 2023.So these months right here were really devastating.It's just around the world.Now, we can also break this out potentially by country.So we can see how many per country, but this is just around the world.That's a lot of people losing their jobs all the way up to 383,000.So, in this range, 383,000 from March of 2023 all the way back to March of 2020 lost their jobs.And this is just reported.I'm sure there was uh you know, much more than that, but this is that like tech companies, larger companies that have like series A funding, IPOs, etc.Um, but a lot of small businesses went out of business.Um, so we don't we don't have that information in this data set.
So I think that's what we're going to do next is kind of look at the company maybe because I'm always interested in the company and actually earlier let's not do that one earlier we're looking at the company thesum of totally loft let's um let's bring this down let's run that because that that's what rolling total is by the way rolling totals are great really good for visualizations as well um let's see yeah so I wantto take a look at these companies but I want to see how much they were laying off per year.So, instead of just looking at it as a total, we'll break it out by the year.Now, I'm just going to warn you, this probably going to this most likely will be our last one in the in the lesson.This is going to be probably our hardest one yet.
Um potentially.We'll see.Maybe the other one was earlier.Uh was harder earlier.Now, let's use this kind of as um a starting point.But what we're going to need to do is we want to take the company, but I also want the date.So I need to do a comma then date.So we need our date here and I'm going to do that.I need to group by the date as well.So we'll do date and let's run this.All right.Now this is just doing the, you know, company and the exact date.We don't want to do that.Let's actually do the year.Let's just look at the year.

41. Git and GitHub Essentials

Introduces version control with Git and sharing code on GitHub, essential skills for modern data professionals.

I think that'll be plenty.You could also do the exact same thing as we did above with the substring.Um although I think that's going to get a little messier.um stuff, you know, just a thought.Let's run this.Okay, so now we're looking at just the year.We're grouping by year and let's order by uh let's say the company.And we'll do that in sending.There we go.And let's run this.So now we have it open.Let's see who, you know, you can see people who made multiple layoffs.This is in 2020, they let go of 200.And then in 2023, they let go of 155.This is a company I've never heard of.So this is already looking really good.Now let's say we wanted to use this and what we want to do is we want to rank which years they laid off the most employees.
Now this is just a small uh sample.We'll look at more in just a little bit.We can actually look at um let's just do three uh three descending just like this should be large companies.So, you know, some of these companies like Microsoft, even Amazon right here and Amazon right there, they let go of multiple or thousands of people in different years.So, I want to rank those.I want to say, you know, the highest one uh based off of the laid off should be ranked number one.That's the year that they laid off the most people.So, let's go ahead and try to do that.Thing we need to do is uh do a CTE.We'll start with that.Let me um me add some more things down here so we're good to go.So let's do we'll do with let's do uh company.
So this is going to be the company year_year.We'll do it as and that's what this is going to be.This is our company year.And we can do select everything from company year.It's going to be the exact query that we're looking at.Let's go ahead and run this.Okay.So this is good.Now I do want to change these columns and I can do that right here.We'll do company um let's call this years and then we'll do I can do total laid off again.So total_laid off just the sum right total laid off per year.So let's go ahead and run this now.There we go.We have company years and total laid off.So this looks much better.And what we're going to do is select everything, but we want to partition it uh probably based off this years right here.
And then we want to rank it based off how many they laid off in that year.So we'll get to see who laid off the most people per year.Cuz some companies like Amazon, they let they let off multiple people per year, but was at the highest per year.That's kind of what we're going to look at.Um so we'll do dense_rank and we're going to do that over.Now, we're going to partition by, oops, that's not how you spell partition.Partition by.We want to partition by the years.So, all of the 2021 layoffs will be in the same partition.All the 2022 will be in the same partition.And we'll do years.And we want to also order by the total laid off.Now, we want to do that in descending.So, we'll do total laid off descending.And then we want to um add this dense rank to it.
So, let's try it.Let's run this.Good night.That's a a big one.So, let's take a look.So, in 2021, it looks like um or 2020, it looks like Uber had the highest.Now, we want to take out these nulls.So, let's do um where years, let's say, is not null.And let's run that.There we go.So in 2020 and that's what we're partitioning on first.It looks like this is one two three.These are the top ones.Um and let's order by and let's do the let's order by the rank.Um first let's call this as bring it down.What do we want to call this?We'll call this as ranking.There we go.So order by ranking ascending.There we go.Now we have our ranking.So in 2020, this is the biggest one of layoffs.2021, this was the biggest layoff.
I guess we'll have to take a look in Meta.In 2022, they had the biggest layoff.And Google had the biggest layoff total for 2023.So, this looks correct, but I kind of want to filter on this ranking to be able to only filter maybe the top like five um companies per year.And I think we can do that.Let's actually get rid of this.I think what we should do is we should add this as another CTE and query off of that.So now we'll call this company_year_rank.So now we have the year rank as we'll have our query oops have our query.So now this is our company year rank.So now if we do select everything from company year rank this we run it.Okay.So now we have our rankings.Let's come down.Now we have our rankings but I just want to filter it based off of that ranking.
We'll say uh where ranking is greater than or equal to let's say five.We'll look at the top five rankings.Let's run this.And I said greater than I wanted uh less than.Run that.That's looking good.Okay.So, really quickly, we have in 2020 we had these are the top five people who laid people off.Uber, Booking.com, Groupon, Swiggy, Airbnb.In 2021, the largest layoff was Bite Dance, which I think is Tik Tok, right?Uh Catera, Zillow, uh yeah, these are the top five.So 2021 and or 2022 and 2023 were definitely the largest as well.We have Meta 11,000 people, Amazon, Cisco, Pelaton, and Carvana, as well as Phillips.They tied.That's why we have the dense ranking because some of these will be ties.Then we have Google uh in 2023 all the way down to Dell.These are all ones I know.
Microsoft, Ericson, Amazon, Salesforce, and Dell.So, this is really, really interesting just looking at a year-by-year snapshot, right?These are the total laid off for each company.And we could even go back and change this for like industry or, you know, really whatever we want to change this to.This is just an interesting query in general to look at, you know, per year.here.And we could go back and change for month or lots of stuff we can change in here, but this is really interesting to me.Um, it just looks like a lot of the large tech companies had some took some big L's, took some big hits.Um, let's recap this query really quickly in case, you know, it's tough to follow.But we created this query up here and we're looking at the company by the year and how many people they let off.
Then right over here we said with the company year we changed these columns.This is our CTE.So we created our first CTE.Then we went and we gave it a rank and we wanted to you know filter on that rank.So we did this rank as another CT.We just did a comma had a second CTE and we hit off the first CT the company year which is right here.So we hit off our first CTE to make this second CTE.

42. R Programming for Data Analysts

Covers the R programming language for data analysis, including core syntax and data manipulation.

And then finally we um queried off of the final CTE.Definitely not an easy query to kind of think through and walk through, but I hope you know you're able to follow um because you know that's a a really good query.This is something I've definitely done in my real job when I was working with a lot of healthcare data.This is a lot of stuff that I would do.And so this is a you know pretty good um pretty good query to know how to do.But with that being said uh we are done with this lesson.I hope this wasn't too short.I don't know how long I ran, but um you know, we looked at a lot of different stuff.Let's go back to the top again.We were just exploring the data.We looked at lay it off a lot.Um looked a lot at the company, uh when these dates actually started for these layoffs in this data set.
We looked at the country, the actual year of layoff.Uh then we went to a little bit more difficult things.We looked at it per month.So per month, how many layoffs they had, and then we did a rolling total.This one was a pretty good one using that substring.Um, I love substrings, man.They're awesome or lady.They're awesome.Uh, and then we came down here and we did the one we just did with multiple CTEs in the company.I think it was a a really really good solid project.Um, combine that with that data cleaning project and man, you got a just a really good start with some MySQL projects and this one can be expanded upon.Don't stop where I stopped.Right?Let me go back to the top.Don't stop where I stopped.Right?This data set has so much data in it.
You can do a lot of different things.And even if you want to, you could go and find these companies right over here and you could try to uh get their total uh total company that they had and you could use this column a lot more.That'd be really interesting with some calculations there.So with that being said, that is the end of our exploratory data analysis project.I hope you enjoyed it.I hope you learned something both in the data cleaning project and in this exploratory data analysis project.That's what this is all about and getting the confidence and gaining the experience to create these projects and add those to your portfolios.Speaking of which, if you haven't already, check out my video on how to create a free portfolio website uh using GitHub.Awesome.I highly recommend it.You can add these to your portfolio.
So, with that being said, thank you so much for watching.I really appreciate it.If you like this video, if you learned anything at all, be sure to like and subscribe below.Check out my channel for tons of other videos just like this one and more.I will see you in the next video.
What's going on everybody?Today we are starting our Excel tutorial series.
5:01:53 - 5:02:31
Now, there are so many things that you can do in Excel.So, I don't know how long the 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, it won't just be the more concrete things.Um you know, like pivot tables, charts, VLOOKUPs, 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.
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 higherups um, who don't want to get into SQL or or, you know, aren't super techsavvy in like Python or Tableau.They just want it in in Excel.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, at least on my screen.I'm going to 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 then we have some demographic information.So this is their age group.We have uh the gender, the country, state, uh 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 wasordered.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 valueof 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're 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 erased that.If it doesn't come like that you can click right here.You can click excuse me you can click control shift and then the right arrow and then the down arrow and that 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.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 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 of 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.Uh 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 rightclick.We're going to go go down to expand and collapse, and we're going to collapse the entire field.

43. Databricks Platform Introduction

Introduces Databricks as a popular data platform, covering the workspace, notebooks, and core features.

And so now here are all of our um all of our countries as they were before, but 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 uh things with group by, this is very similar to that.Um, and if you've done the uh 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, what is that?9,23,495.
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.Um 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 we'll type currency.Now it has these two.Z00 zeros 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, be good if I could spell revenue per country.Um, that's fine.That, you know, it's just a placeholder to try 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 min.We can do just about anything we want.Um, but let's keep it the sum right now.Um, 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.Um, 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 uh to smallest.You'd have to go and 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 control-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 uh pretty quickly.So, we want to pull in this profit and this cost.Uh, and so I'm going to pull in this cost next.And then I'm going to pull in this profit.Again, uh, I'm going to change the currency on this.And I'm not going to change the names um right now, but you absolutely can do that.
Now, the revenue is the 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 or store um or distribute all of these products.So, that was 16 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$11 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.Um but we can do a calculated field.Um, and 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.Uh let's go to pivot table analyze.We're going to go over to fields, items, and sets and go to calculated field.Now we can name this anything.Um, and I'm just going to for demo purposes, I'm going to say, um, oops, calculated field demo.Uh, I'm sure yours will be different.Now, um, 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.This is our first tutorial.But, you know, when we look at formulas, it's basically the same thing as writing an 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 uh 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 uh 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.Um you probably wouldn't have this if you were um you know going to submit this to somebody.
Uh 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 now an actual um 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.Uh 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.
Um, but probably not things that you already have included in your pivot table.So, if you add something like the country down here, um, 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.Um, for example, right up here we have uh 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 uh the males are the the profit from the males is 16.487 487 million and the profit from the females is 15.733 million.
So at a super uh 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.Uh we are going to create a pivot table right over here.Let's go back to the sales right here again.control shift right 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.Um, and what we want to do is see, you know, what year were we performing our best?when were we doing our absolute best uh with oops let me go back uh with our sales.

44. Building ETL Pipelines in Databricks

Walks through creating ETL pipelines within Databricks to move and transform large-scale data.

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.So 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 uh 2013 and a huge uptick in 2015.That didn't happen for every single country.Uh did go up uh for most countries, very slightly for some, but we can see on a large scale from um 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 pivot tables is that you can kind of group these things together, show some uh information, data at at kind of a broad larger scale and make it to where anybody who'slooking 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.
What's going on everybody?Today we're going to be looking at formulas in 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 makeanother 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 this series and that is Udemy.You guys already know if you've watched any of my videos that I absolutely love Udemy.
I mean honestly, they were the ones who got me started and were 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 in 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.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've left little notes here and there.Um, and I'm going to try to get through it because there's a lot of them to get through.Um, 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.Um, I'll see the ones that people are liking and I will I will create more videos on these because I know there are so many.I also will save this um Excel in uh on the GitHub so you can go and download it.It'll 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 uh difficult things.Um 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, uh, 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, uh, I am now creating a formula.And we're going to say m a x.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 kind of 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 parentheses, 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 um 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.Um, we can see who the who's making the most money or at least what the highest 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.uh this column was a date range or a date column for whatever reason.So let me get rid of that.Uh 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 Beasley is making the least and 65,000 is Michael Scott who's making uh 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.Um 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.Uh, 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?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.
Um, 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?

45. Building a Portfolio Website

Guides viewers through creating a personal portfolio website to showcase projects to recruiters and hiring managers.

You can have multiple conditions.So, let's open that up real quick.So, ifs.And now we have a logical test value.If uh 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 um different ranges and 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.Uh 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 um customer data or 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?Um, so for this, oops, why' I do that?
I did control Z to undo that if you didn't know how to do that.Uh, so we're going to do equals leen, 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 uh 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 Fenderson 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.Uh 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 uh 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.Um I I might be going a little fast, but uh you know, I'm keeping it I'm keeping it live.I'm keeping us on our feet.Uh so let's keep going.Left and right um are kind of like substrings.If you've taken the the SQL um tutorial series that I've done, uh substrings are where you can choose a certain part of the text string and you can extract data from that.Um and it usually have to reference a certain number.So, a certain amount of characters.That's the exact same thing, except uh uh 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 simple.Uh we'll get a little bit more advanced.So we have uh 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 um and we'll just choose three as an example.And so you can see that it takes the first three characters from every single um 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 and we're just going to extract the Oops, I wanted to make that a range.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 because we want to take the first four characters from the right to give us the entire year.So 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 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.Uh 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 mean 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 general, it's going to have a 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-2-201,which then converts it to a date format.Um, but what you can do, you know, just so you know, you can create it as a text.You can do 11-2-201.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.

46. Excel Text Formulas: Date to Text, Trim, Concatenate

Demonstrates converting dates to text with TEXT, cleaning spaces with TRIM, joining strings with CONCATENATE, and replacing text with SUBSTITUTE.

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 formula that we're going to use.So, let's get rid of that one.Oops.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 altogether.
So this is a day day month year year format and that is what we're going to do.So we're going to dd/mm/y y and close that up.And there you go.And now we will 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.So we're going to do write, we're gonna 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 2 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
and 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 do I 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 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 or they accidentally 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 help space uh or gym space helper it won't take the space in between there because it it kind of understands that the 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 I want to include this.So, concatenating this and this.And let's take a look.So, it says Jim Halbert, 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' I do?I'm gonna say um dot and then at the end I'm going to say at oops comma quotation atgmail.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.Um let's go over to the next one.So we are going to do substitute.Now substitutees 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 uh 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 um 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, we 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 instanceare 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 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?Is that 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 uh 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.

47. Excel SUM, COUNT, and Date Functions

Covers SUM, SUMIF, SUMIFS, COUNT, COUNTIF, and COUNTIFS for conditional calculations, plus DAYS and NETWORKDAYS for date differences.

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 a 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, sum if 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 sum if and then you're going to need to give a range and 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 that 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 in that one.So that is how you do a sum if and sum ifs 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 some ifs.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.But this adds the cells specified by a given set of conditions or criteria.So let's do no paren open parenthesy.We'll 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 uh 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 sum if and the sum ifs.Um 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 countdown here, oops, this countdown 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 count if, oops, I did not spell that right.If we do count if, we're going to give a range and a criteria, exact same as we did before.Uh, 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 sum 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 count ifs 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 let's 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 we want it to be as our criteria one we can say we want it to be greater than we want their ID to be greater than 1005 and let's say we want
them to bemale.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 um 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.Um 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.is gonna we want to choose our end date.So this is our end date.That'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.So network days is extremely similar except it takes out holidays and it takes out weekends.And you can see how many working days has this person uh how many working days or network days 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 network days.And we mean 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.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 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 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 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.and I'll see you in the next video.

48. XLOOKUP Basics and Match Modes

Introduces XLOOKUP as a modern replacement for VLOOKUP, covering lookup/return arrays, multiple return columns, if-not-found, and wildcard match modes.

What's going on everybody?Welcome back to another video.In this Excel tutorial, we'll be looking at XOOKUP.
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 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 cuz I'll walk you through kindof 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 differencebetween 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 going to 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 optional 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 the 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 Fenderson 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 Fenderson.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 this parenthesy.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 Fenderson.So, it's on Toby Fenderson is on row six.So, it's going to find Toby Fenderson.It's going to come over here and it's going to return Toby Flenderson at dundermland corporate.com.That's what it should do.Let's see what it actually does.Let's hit 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 XOOKUP.But just know that if you're using XOOKUP 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 XOOKUP.So let's go right in here and we're going to basically write the exact same thing um as we did before.So let's write XOOKUP.We're going to do Toby Fenderson 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 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.Um, but they have to be right next to each other.So, you 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, 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 zero or or 0 O2 to P10, if I included age 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 u 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 um array that we're looking and we're going to do the email.And you know, as you can see, this says Toby Flender, not Toby Flender.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 Flender 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 uh 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.I'm going to 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 uh 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 wildcard 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.Um it's doing it because it's searching for Beasley but if there's not a wildcard 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 an asterisk right here.And then do another one.And we're going to hit an amperand.So, we're going to have an amperand right here.And what 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 amberand right here.

49. XLOOKUP Search Modes and VLOOKUP Comparison

Covers search order options, horizontal lookups, combining XLOOKUP with SUM, and compares XLOOKUP's flexibility to VLOOKUP's column index limitations.

And now it'll work.And the exact same thing for Kevin Malo right here.Kevin Malone.So, I 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 first and then search order.but it's just kind of easier to show it over here.So, I'm going to do X lookup.I'm going to look up this value.Do a comma.Here's the range.This is our start date that it's going to be looking for.And I want to return the full name.Now, no value in here has 11200.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 what that's what that number one represents, the next larger value.So we have 11200.And if we look right here, the next value above 11200 is 15200.And so it 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 xookup.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.
We're going to 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 um 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 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 56 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 where you're using this one um which is uh you know exact match or next larger and you caninclude that in this binary search in this one as well.All right, now let's head over to the xookup horizontal.I think we're we only have a few left.Yep, xookup horizontal.Then we'll do xookup 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 xookup.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 some um 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 XOOKUP atthe 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 xookup and then our next value is also going to
be an xookup.So, let's do xookup.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 oops goes into that.So, let's close that parenthesis.And now we're going to do a colon and another x lookup.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 parenthesy.So now we are basically adding this February and this March.So it's going to be 310 + 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 some, 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 uh honestly, it's pretty great.So, let's go over to VLOOKUP.So, 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, AxOookup, 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 isused 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.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 010.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 autodoing it, but there we go.And now we will do it and it's going to return it just as we had it.Um, 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 saywe um added another column which happens to data now it gives us completely different um different data.So let's say for whatever reason we added uh address.So now we have these people 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 um now the eth 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 u 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 XOOKUP.And right now the email is looking at O2 and through O10.
Um, we're just going to insert right here.And that will 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 or the original array that was selected.

50. Conclusion

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 Xookup 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 video.
What's going on everybody?Welcome back to another Excel tutorial.Today we'll be looking at conditional formatting.
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 and a lot of the things that I use the most and some of the things that I useit 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.U really good job, Microsoft.Exactly how I would have done it.So what you'll see right away is 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 rules.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 howthat 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 forming 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 it 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 and 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, actually let's get rid of our um 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.Um 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.Uh, as I just showed a second ago, if you want to clear the rules, you can clear it 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, 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, 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 Scots, Toby Flenderson's, and Dwight Shroo.Uh 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 Tru are and Toby are kind of bringing up that average quite a bit.So, everyone else is going to fall beneath that.
And 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 um 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.Uh 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 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 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.Uh, 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 just 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 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 of those things, all that customer or or client information.And oftent times 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 themall 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 workingwith 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 putthat in your toolkit 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, usethe 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, then that means there aren't any duplicates.And that's 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 Lorazzipam or something like that, um I would just search for like Lorazz or something and and not Lorax but Lauraz, you know, I I would just search for it and then allthe 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 oops 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 um 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 oopsa 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.Uh the duplicate values and the text contains are by far the ones 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 if 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 how you can apply them to your own data sets.Now, we've looked at all of these preset ones and 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 agoand 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 wanted 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 hard coding 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 it to be 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'll give it some color.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 it still has the G2 to 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 should be fine still.Um but let's see what it does.
And so now 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 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 it 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 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 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 umthese 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 inlike 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 video.
What's going on everybody?Welcome back to another Excel tutorial.Today we will be looking at 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 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 on my screen and get started with this 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.And 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 kindof 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, and 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.Uh 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.Uh 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.So 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 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 has 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 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 is 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, 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 I could not imagine a scenario thatthese are ever used.Um, but within these columns you can do they're called cluster columns.Uh, these stacked columns.So it 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.Um, 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.Um, 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 there are these stacked um 100% stacked line 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 clustered.Um, 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.Um 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, 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.Um, oh, 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.Um, 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, if 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 in 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 it a little cleaner.Uh, 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.Uh you just kind of want to make sure you're doing it the right way.So, let's get this back where it 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 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.Um, there are some good stuff in here.
Um, and I'm sure that, you know, if you are 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.Um, just not something I use.And 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 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 has 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 a different sheet to create some typeof little uh chart and visualization sheet that you can use to show your employers 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 video.
What's going on everybody?Welcome back to the Excel tutorial series.Today we will be looking at how to clean data in 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, and I feel like are the most helpful to kind of do the bulk or the majority of the data clean that you're going to doin 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.And 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 and 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 have 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.And 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's 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 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 not 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 uh in this Excel series where we're going to be doing from start to finish witha real data set.So, you know, if that's something that you're you're 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 with 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 where we have this wig and this wig 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 uh value.And then dates are always an issue.Always, always, always.Um, 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 youdon'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 up 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 okay.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 thatyou are going to see that there's duplicated data in there.So just running a a a quick um ddup 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 equals upper equals 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 equal upper oops upper and I'm going to go like this and close my parenthesy.
So, I selected this cell.I closed my parenthesy.I hit enter.It is and I'm going to hit um in the bottom right.I'm going to hit double click this.It's going to apply it 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 thirdparty 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 going to Oops.I'm going to say president dash 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 loweraseissues.It's all the same.So I'm going to 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's 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 is 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, uh, if we look right here, we have Democratic, Democratic-Republican, Federalist, nonpartisan, Republican, Republicans, wig, and wig 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 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.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.Next thing we're going to fix is this wig.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 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 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 on 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 uh most often it's happens on numerical data.So like uh you know there'll be a number of 101 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 uh the cell.We're going to close that parenthesy 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 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 adatabase.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 thatyou know you're having issues with but once you import that data into SQL you will know if there's an issue or not um 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 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 um 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 a 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 um 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 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 ora 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 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.Uh, 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 a 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 oftent times um you know just for just for demonstration purposes oftent times 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 thetime.All the time.Um, 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 that they are all the same format and that is fantastic.That is exactly what we want.Uh 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.Uh, 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.And let me do it right here.I'll show you.Sometimes I do this.Doesn't just depends.I'm going to go right here.I'm going to hit rightclick.And I'm going to paste as a value, which means it's not going to take the um 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 equals trim of 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 controll shift down copy and I just hit the right key uh or the left key sorry.Now I'm going to rightclick and I'm going to do paste as a value.And again 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 want 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 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 alot of things and that happened 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.Um, 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, um, 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 set.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 I 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.Um, these date updateds and date created, we may never use them, but we might.Um, so it's 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 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 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 dataset that has different uses and different um purposes for.So, you know, take everything that I've said and 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 dataset.So, I hope this was helpful.I hope you 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 video.
What's going on everybody?Welcome back to the Excel tutorial series.Today we're going to create an entire project in Excel.
Now, if you've never done a complete project in Excel where you take the data, you clean it, and then you create an actual dashboard where people can click on things and filter things, this is going to be areally 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 it or someissue.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 sheets.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 beusing 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 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 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, we do have duplicates in there.So, I'm glad we did that.Otherwise, we would have uh, you know, not good data.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, Fs, 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 CtrlH.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, what 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'll do S is single.This one is super easy.We're going to do the exact same thing right here.So, column C and 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 se 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 we'll 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.Um, 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 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 that 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 it 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 will 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 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 on 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 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 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 donethat before.So this is our 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 that L2 is and we're going to do this time we're going to do greater than or equal to 31.So now it's going to include that 31.So right here we did anything less than 31.So is 30 and below.This one is going to be 31 and above.So we're gonna say these people are middle age.And if not, then it's going to go to this if statement.And then we need to close it, I believe.So now let's try this.All right.Fantastic.Now if um everybody should be in one of these areas, right?everyone should either be an adolescent or middle-ag because basically all we're saying is is if they're older than 31 or 30 or below.
That's all these two statements do.So we have um you know our next group.Now we can add and go even further into this and now we can use this entire thing as the um what was it called?The value if false uh section.So that's what we're going to do.We're going to do one more.So we're going to have three different categories.So, we're going to say if and do an 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 it 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 do 55.and we're going to call them old and we'll do comma and this is the value if statement and we need to close the 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.Uh my dad is 55.That's why I'm doing it like this.This is for you, Dad.Uh because he should be in this old category to be fair.So now we have adolescent, adolescent, middle-ag, 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, uh, 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?I don't 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'll see.So, uh we are going to keep it just like this.Now what we are going to nownow 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 uh 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 are 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 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 oneswho did buy a bike the average salary was 55 for female and 60 for males.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.Uh, 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 we'll do gender.So, that's what that is.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.Um, 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 that 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 are 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 or all the visualizations that we need, then we will um we will start.So we're going to do control A 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, 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, our price points are the customers, do they make more money, so should we cater to them or not?Uh, that's a good question.Uh, 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're 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 uh 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 this 10 miles you know it's right next to the 0.1.So it's not an 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, don't know if I did that in my 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 m 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 Ctrl H and we'll do Oops, not this one.
Um, 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.Okay, it's already selected.Let's do is it 10 plus miles?Okay.So, let's do um m uh 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.Um that's that's the important part of this.It's distance um 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 um 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 in into groups like this.And you know, for this I'm just kind of made them up, but um 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 purchased a bike, count of the purchase.Um you know, pretty easy.So we just have the 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.You could do something like this.That's nice.See this one versus this.It just adds a dot.Oh, it looks nice.We'll keep that one.Um, 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.Uh 31 to 54 buying a ton of bikes.Uh they are they buy more bikes or look at bikes more than anybody.
Really interesting.Um but we'll make the dashboard a little bit.Um let's make these chart titles.We'll do ver oops the horizontal.We'll 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, understand this dashboard, this is going to be justit's going to I don't know.It might melt their brain.It 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 mid30s 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.Whoops.Um so, why don't why don't we do that?
Why don't we go back?I'm just gonna 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.Um, and I'll explain that in 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 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 and it's tough for me to watch.All right, let's go to this last one.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?Um 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 do 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.It just makes it look cleaner.It 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.I'm just going to get choose a color.I like this.And let's 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 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 make it much larger than it is.Okay.Okay.Sure.Let's do that.Doesn't look bad.Um, what is it doing?There we go.Uh, let's make 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 and just see how it looks.Uh, and then we'll go from there.I like this one there.Um, we could 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.Jeez.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.Uh, 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.And 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.is really nice to align especially if like the top um maybe like the left to right but like we're gonna 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.Go shape format align to the right.And it's not exactly what I wanted to happen becauseoh jeez, what am I doing?That's not exactly what I wanted to happen.I actually wanted this one to align uh this one to align with this one.It did the opposite.Um so let me just scoot this back.All right.Visually it looks fine.But that's how you do it if you want to do it.Um I 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 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.Uh, 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 be able 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 pivot chart 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 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.Is 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.Um 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.Um, 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 um sometimes 8 to like 10,000 more on average uh 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 pivot chart 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.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.Nail.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 for 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.Feel like it' look 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 colorcoordinated, you have these slicers on the side.
Um, to me, this is a 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 goodbye.
What's going on everybody?Welcome back to another video.Today we are starting our Tableau tutorial 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 into 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 nextvideo.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 to 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 uh 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 umyou 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 uh 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 um 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 f.
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 in 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 it right back into here.Um, and just so you know, that is a uh 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, uh, VGSK sales_1.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 um, some of these things or some of these fields.And if you notice, they they um 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 we're 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 sales_1.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.Uh, they just generated that field.um 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 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 uh this first came up on the screen because it has all these different charts and visualizations and graphs.
And uh these will become available as you start dragging and dropping our data into this sheet.And so if I go right here, it says four scatter plots try zero or more dimensions, two to four measures.So what our dimensions are are right here and 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 a lot of times the numerical is going to be aregoing 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, 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 um 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 um 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 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 uh 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 columns, 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 because we don't need it anymore.Uh, and this is where these um 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 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 uh 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 uh 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.4, it's a little bit more useful if we do it per each line.Uh, this at least gives us some context.I probably wouldn't do this in an actual visual visualization.But to give you some um understanding of just how it works.So now I know that um right over here the min and the max or the min uh 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 a really quickly becoming uh a pretty usable visualization.
And it'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.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 are making this for somebody, you want them to be able to filter down uh to very specific information that they want to see.So, let's take uh the platform.Lots of different platforms.Um as you can see, you know, PS4, Xbox, um 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, three or four.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, uh 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 you'll 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 uh 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 come right 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 one.And we'll put uh let's put it up top.So, now it looks a little bit like this.Uh, 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 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 can 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 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 video.
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 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 uh 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 of 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 we're going to come right over here to year and this little drop down 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.Is no longer um it is no longer a numeric.Now, it is a categorical.
So, now it's this is no longer just uh 1 2 3 4 5.It's ranges.It's 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 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.Uh, 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 whatever 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 this 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.Um 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 putuh 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 it created calculation two.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 millionish in this 2000 uh 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 uh 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 are 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 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 maps.
Now, before we jump into the tutorial, I have some very exciting news.In just two days, on October 7th, I am going to be partnering with AlterX 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 we will be bringing on guests as well who are industry experts who actually change careers to become data analysts, much like myself.They'll be sharing their stories of how they actually transition 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 it should be really fun.Without further ado, let's jump on 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 here we want to come in here.We're going to copy it or um you can cut it.Uh 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.Uh 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.uh exact same thing as directory but so the first 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 and 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 line, sometimes you just have these uh these bar graphs or these bar charts.Uh, 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 sum of global sales, sum of NA sales.So, if we go into this all, we click this dropdown, we can change it to a line.Uh, we can change it basically whatever we want.I just hit control-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 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.And 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.Um 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 and it's going togenerate 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 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 postcodes.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 postcodes.But 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, but over here we want to actually do this and make it a map.And so now it's going to fill in all the states.And we can, you know, why not?We'll add some color here.Um, but we can Oh, it has a numbered.I didn't think they were numbered.Um, oh, that's interesting.I haven't seen I didn't look at that before.I was just uh 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 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 poster codes are different, so it's just going to be complete mish mash.But uh this is kind of how you can use a density map.
And you can do this AC with uh countries, you can do this with postal codes, you can do this with any type of kind of like address or locationbased 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 are 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 add 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 cuz this is very small.Um let's see.I have this I just want global sales and let's label that the size.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 a 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.Uh 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.
Uh 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.Uh 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 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 consider, 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 sum 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.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 touse 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 video.
8:27:05 - 8:27:10
What's going on everybody?Welcome back to another video.Today we're looking at joins in 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 are having a massive Black Friday sale.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 a actual full Tableau course, there are fantastic ones on Udemy that I have taken myself.So, be sure to go and check out Udei 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 in Tableau.Tableau does a really fantastic job of visualizing it 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 and go right over here.And now we have uh 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 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 Tableau regularly, I would use the relationships when it was pretty simple and straightforward because 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 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 just highly recommend using that.Um and I recommend learning SQL, too.So, you know, two birds, one stone.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 joint is or this is what that joint 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 injoin.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 1,000 all the way through 10.So where is 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 1009.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 1009 and through 1009.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 one 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 null, null, null, null, null 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 lefth hand table.Um and now we are able to see the 110 or or 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 ago, 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 1,0 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 oneof 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 joint, a right joint, 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, 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% 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.Uh 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 in 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 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 let's 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 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 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 gettingthe 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 join 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 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 project.
Now, if you 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 aswell.But again, in this video, we're going to be singing to a lot of the basics.
But I'll switch over to my screen in just a second.and 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 toyour 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 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 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 date and 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.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 of 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.gz.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 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 cuz that's kind of where it all stems from.Uh we have our listing and the date or the data in here is um 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 good.Um, right over here, it has, you know, how many bathrooms, bedrooms, and beds.Um, you know, sometimes if it's a five bedroomedroom house, it's 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.There's 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 of, 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.Uh, you're not going to get data every column where you're going to be able to use it.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 u and something that if you're if you get a data analyst job you need to understand yourdata 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 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 line 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 ID 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 Fs.Um, let's try to find a blank one really quick.
Here's a blank one.So there's these T's and Fs.Uh, the T means that it was taken.Um, the F means that it's vacant.Uh, I don't know exactly what it means.Uh, what the TF 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 home made 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 buildingout 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 could 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.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 listings, we have our uh calendar and our reviews.
What we're going to do is we're 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 toget 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 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 u, 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 are about 3,600 um about 3,600 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 it this inner join because we know that if it's in listings, it's 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.Uh, 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 it's 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 2555 rows.If we do how it's supposed and there 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, uh, uh, 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, I guess you'd 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, and 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, anyways, so we'll see if that gets us underneath.I have absolutely no if this take 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.Uh, this is just for demonstration purposes.So, we're going to remove that.And let's see if that helps us in any way.
Because 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 joins.Uh, but we weren't actually using any of the data from 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 or all the rows that we needed to get under that level.Again, I was just doing that to show you the the that joins how you needed to change the columns to make sure that it joined properly.We don't actually use it for any of the visualizations.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, I'm 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 and 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 factors that I should be looking at?"Uh, and so that's kind of what our use case is.So, we're gonna the 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 uh 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 gonna um when we do the map 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 um 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 uh 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 longit 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're 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.Let 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 or 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, it's a blue.I I I 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 look at like this section right over here, I I 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.6.Um, I'm looking at the average price right here.And then we go over here.98134 206.6.So this all matches.Um, and we can uh we can actually change that size a little bit if you wanted to actually get it in um get it within each of these things.
You know, adjust it as you see fit.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 low.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 had 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.Football.Okay, here's the price.Where is that calendar one?Let me see.
Okay, there's the calendar.Oh, here.All right.I totally forgot where that was supposed to be.O, that looks terrible.Okay.Um, let's see.Let's let's start working on this cuz 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 Whoops.we need to change some some the way that these dates are are seen.So right here is act these are two separate things.So if I go right here and I do it 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 change 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.Um 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 cuz this is an this is a 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 filterup.Is it format?No, it's not format.What am I thinking?Bear with me.Uh let's filter.Well, I was looking for it.I just couldn't find it.Uh let's bring it back to the 31st.Let's see if that fixes what we need.Perfect.Uh that 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 going to 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 have been 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.Did I label this last one?I didn't.Let's label that last one.And we'll do price per zip code.Price per zip code.We'll just keep it at that.Let's 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.Well, 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 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 dropdown 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.I 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.Um, although this 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.Um, 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 onebedrooms 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 been doing is keeping average.Um, and we are going to get rid of this because 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.Um, 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, you know, get into those one that onebedroom area, you know, you're not going to be making a lot of money.It may be low cost upfront, but he's not going to be making a lot of money.It significantly goes up when you reach these five and sixbedroom 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 ones, 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?
Oh, let me see.U, 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 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 some 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, it 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 onebedrooms, there's 1,800 onebedroom, two that have 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 fourbedroom, 5bedroom, sixbedroom?Uh, 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.Um, there's so much data in here and we could absolutely figure that out.But for what it's worth, we're 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.Um, distinct I I'm going to butcher this one.I'm going to do 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'll 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 were like an actual project, but it works for now.So, we have our five visualizations.1 2 3 four and five.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 see if I can zoom in one more.No, I'm going to do it just like that.Actually, let me see
if I can make it even just a little bit closer.Perfect.Uh, that's the best you're going to get.Um, if you didn't see, I used 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 to 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.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.Add
Yeah, this caption.Um, if you've never seen something like this before, um, and I actually want to make this bigger as well.Jeez, give me a second.It's It's kind of lagging a little bit.
And make this a little bit.Maybe I don't want it as wide, but I definitely want a little taller.
Give it a second.Yeah.Let me scooch this back.
Just like that.That's fine.Uh, we can keep it like that.In my original one, I didn't have this.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 this, 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, fivestar reviews are peoplegiving on, you know, onebedroom, two-bedroom, threebedroom.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 Tableau public as and we're going to do this and we're going to make it um let's do air B&B.Is it like is it a capital B?Is it like that?No, that doesn't look right.Airbnb.Uh, 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 because 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 upto-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 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 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 video.
9:25:51 - 9:25:57
What's going on everybody?Welcome back to another video.Today we're goingto be starting our PowerBI tutorial series.
Now, I am super excited to start this series with you guys.We're going to be breaking this up in 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.And 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 and by the end of it, you should know PowerBI a lot better and you should have a lot more confidence using it.All right.So, the first thing I'm going to do is download PowerBI 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.And I already have it downloaded.So, when you see it, uh it'll already say downloaded.But, um for you, you can go in here, you can click download, and it will download it for you.I'm on Microsoft, uh 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 PowerBI.So, let's go right down here to our search.Let's go to PowerBI.
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 from but you just taking a quick glance through here you have a ton of options.There's databases there's um you know blob stoages there's postgrade SQL or different SQL databases um 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 pullthat 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 go right here in our PowerBI 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.So, 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 PowerBI 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 and this is uh 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 beforehand 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 purchased 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 backto its original state.So again, I'm just going to say purchased, 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.U 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 PowerBI desktop.So on this lefth 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 is called model.And this is especially useful when you have multiple tables or multiple Excels 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 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 and so I should just buy like the dried beans at Costco, but everything else I should bebuying 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 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 happen.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 and 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 $ 219 and Walmart at 225.And that really answers our question, but we want to visualize it better, be able to see it in a 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 stocked 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.Uh 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?Uh 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 uh 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.That's pretty negligible.But for the big ticket items, um, we're really spending a lot less at Costco.If we wanted to sp 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 PowerBI, transform it a little bit.Then we were 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 this series, we're going to have an entire project where we really use every single part of PowerBI and create a beautiful dashboard.And so, that's all we have for our very first video in our PowerBI 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.
What's going on everybody?Today we're continuing our PowerBI tutorial series and in this video we're going to be looking at Power Query.
Now Power Query is really great because it allows you to actually transform the data before you actually get it into PowerBI.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 PowerBI 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 there, 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 it 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 PowerBI 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 were 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 can 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 PowerBI, it did a few things for us.It chose 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 to 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 PowerBI 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 2 3 4 5s.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 are going to want to get rid of some of this and just clean this up to make it more usable for our PowerBI visualizations.This may be perfectly fine and acceptable in an Excel, but when you're pulling it into PowerBI, the real reason you're pulling it in is to create visualizations, not just it 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 cuz 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 the 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 cuz 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 one two is a decimal, but we're actually going to change that.And all you have to do is click on this 1.2 two 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 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 dropdown and we're going to try to filter this data before we actually load it into PowerBI.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 notcontain.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.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 it 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 PowerBI right now.And this is extremely usable and very good for visualizations 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_costand 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 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 text.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 created 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 PowerBI to create our visualizations.So let's go ahead and click on that.And so now the data has been pulled into PowerBI.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, be sure to like and subscribe below and check out all my other videos and everything data analyst related.I'll see you in the next video.
What's going on everybody?Welcome back to the PowerBI tutorial series.Today we're going to be taking a look at building 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 on my screen and get started with the tutorial.All right.So, before we jump over to PowerBI 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, units 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 PowerBI.So, we're going to say import data from Excel.We're going to choose this model right here.
And 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 PowerBI has automatically detected and created.From my experience, PowerBI 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 us 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 PowerBI 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 it 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 cardality and cross filter direction.Cardonality 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 forseveral different orders.So that's why the cardality 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 and 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 this 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 product IDs 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, 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.Missouri 8, New York 9, 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 custo 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 cardality 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 and Apocalypse store and drag this over the product ID in the apocalyp sales.And again, if we open it up, it created that relationship for us.It created the cardality 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 PowerBI.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 video.
What's going on everybody?Welcome back to the PowerBI tutorial series.Today we're going to be taking a look at DAX.
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 PowerBI 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 PowerBI.So, without further ado, let's jump on 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, units 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 rightclick 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.And 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 autocomp completion 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 and 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, rightclick, 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're 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 check box.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 or make them into an iterator function.So you can have sum and sumx or average and average x.Adding x onto the end of them can make them into 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 units 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 rightclick and create a measure.And 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 and 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 startwith 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 cost 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.Let's create a new uh table.We're going to click profit.And let's make it a table.And I'm going to pull this right over here.Now, we have our profit, but what 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 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, what I want to show you is the difference between sum and sumx.So, what I'm going to do is 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 profitcolumn.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.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 want it to show.What we want it to show is the profit for each row.What we want it 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.I'm going to say new column.And now we're going to say profit oops underscorec column sum x.And now we're going to use sum x 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 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 $15,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 and the difference between an aggregator function and an 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, dates, YTD, next day, previous day, 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's equal to 1, Saturday's equal to 7.I like this one personally, which is Monday equals 1.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 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.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 in units sold.Let's drag that down.Move this over right here.And this day of the 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.Um it's not easy to see if there's any pattern.Again, Monday has the most.So maybe that 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.And 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 PowerBI.And so we're going to name this one order size.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.
What's going on everybody?Welcome back to the PowerBI 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 into 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 that we're 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 and targeted, 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.And 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 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 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 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 it all uh 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.Uh, 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.And let's make it we'll just go like this.We have a customer and we have units 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 downon 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 ithelps 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 PowerBI.Thank you and I'll see you in the next video.
What's going on everybody?Welcome back to the PowerBI 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 PowerBI.Conditional formatting allows you to take a table or a matrix within PowerBI 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 PowerBI.And let me show you how to do that.So, the first thing we're going to do is come 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 rightclick 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 popup 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'll 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 it's a cheap product that's easy to purchase.The highv value ones are going to be just this 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 units 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 bars on units sold and not price because units sold is something like a sum, an average, something that's aggregated.But let's take a look at data bars cuz 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 taking a look at the lowest or 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 units 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 got 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 says 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 rightclick, 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 third percent, 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 units 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, units 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.I can just click the sum.So it now is 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 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 negatives, 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 our number one seller.So, you know, our weatherproof jackets, multi-tool, survival knives, and the nylon rope are perform 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 visuals to this little chart or table that you're goingto 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 PowerBI.And I'll see you in the next video.
What's going on everybody?Welcome back to the PowerBI tutorial series.Today we're going to be taking a look at bins and 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 and get started with the 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.It 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 rightclick 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, rightclick 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 ungroup, 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 going 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.U, but by far the easiest way 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 orin 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 and 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 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 10.So, 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 rightclick 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 could 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 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 is 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 purchased.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 months 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.Um let's go back up.Yeah.So it looks like we only have one buyer ID.Yeah.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 units 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 PowerBI.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 PowerBI.I'll see you in the next video.
What's going on everybody?Welcome back to the PowerBI tutorial series.Today we're going to be taking a look at all types of visualizations.
Now, when you're working in PowerBI, 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 getkind 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 PowerBI 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 or that I have used and showing you how to actually create that visualization, maybespice 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 units 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.And 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 aswell.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 control 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 units sold and click on units 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 or 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 prepping 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 prefer.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 uh a good visualization.And we're going to bring that right over here.We're going to have a lot on the screen.And 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 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-axxis, 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 gonna 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.We went to here just a different orientation.It's the same thing.Um just like this clustered bar chart, clust column chart.It's just its orientation either horizontal or vertical.Then we have things like an area chart, a 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 xaxis, 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 we 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 yaxis.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 yaxis 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.Uh, 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.I get right down into the corner.Now, let's go right over here and we have the the dreaded pie charts.Um, and donut charts.Now, look, I think it's kind of a joke in the data analyst community about pie charts and doughut 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 doughut 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.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, two, 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 ofthe 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 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 multiro 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.Just for example, I'll kind of show you how this might look.So, it look 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 visualizations, 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 units 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 and 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 others 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 PowerBI tutorial videos that I have on my channel.and I will see you in the next video.
What's going on everybody?Welcome back to the PowerBI tutorial series.Today we are going to be working on our final project.
Now this is our final project of the PowerBI 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 we're going to be looking at in today'sproject.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 professionalsand 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 now we're using it for a project.We're going to transform the data using Power Query and then we'll 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 on 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 PowerBI, 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.But 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 PowerBI because again this is a PowerBI 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 PowerBI 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 is 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 PowerBI, but none in here.
But typically with this amount of data in the way that it's formatted, we would do so much data cleaning um with this one.I mean, there's 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 a ranges and it has a dash and a k 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.So, this was 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 0 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 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 fe male, female, which country are you from?And then this is more like demographics.So, if you're a male, how old you are, and this was in a range.So, this is like a a a sliding bar.So, you can 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 PowerBI.So, let's exit out and let's come right over here to import data from Excel.We'll click on PowerBI final project and open.Give that a second.Doing this all in real time.and we only have the one.So, we'll do 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.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 diff people'sroles 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 ahundred different options and then a student or or none of these right umand 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.The and with AI.These two would typically be combined or standardized to software engineer.But it's not very easy to do that in PowerBI.We could do that in Excel, but not really in PowerBI 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 a 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 going 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 is 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.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 going to 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 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 cuz 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 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 PowerBI.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 asthey 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, but 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.Then we'll use some docs 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 + 125 / 2 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 a kind of roundabout number because they gave us this range.They said my salary is between 106 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 dash 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 rightclick.We're going to click on replace values.And so if it just has we just do a K.We'll replace with nothing.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 DAX.I forgot.But actually, if somebody has 225, let me find this plus really quick.Uh, let me filter by it because it'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 + 225 / 2, 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.So I'm going 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 and 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.We're going to say parentheses 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 uh 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 now.Or maybe 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 this one plus this one.and we'll do divided 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 movethis 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.Uh 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 can 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 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, thesame issue kept happening.Argentina, Argentina, Argentine, a Australia.So, we can't normalize those values unless we spend just 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 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 withthis.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 of our data as it is transformed in here as well.And now we can start building out our visualization.So, 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.
Make this right at the top.Call this the data professional survey breakdown.And let's 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 that'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 a count, it doesn't matter.Um, and 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 say total amount or of survey takers, but you can say count of survey takers.How many people took the 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, we 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 average age of survey.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 is 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 all 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.
They're making 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 are 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 analyst.So this one's probably the most accurate out of all of them.And I actually don't like how this looks as the clustered 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 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 cuz good night.Um this is like incredibly long.So let's go over here to this format visual.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 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 average salary.There we go.Looks much better, much cleaner.Uh, took away a lot of the anxiety that I was feeling about 2 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 is people's favorite programming language?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 programming 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 are 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 it 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 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 distinct.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 a data analyst, it's 80.And if we look at India, you know, the average salary for a data scientist is 68.The average salary is 26 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 dollars 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.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 ofwork 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.We want to put that at the minimum and pull this over and add the maximum value.So, now it actually has 0 to 10.And it shows that the average person is happy with uh which one was this?The average person is happy with their work life balance.Uh 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.So 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 uh 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, uh, 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 doughut 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 for female versus 53 for males.So actually the females are a little bit higher.Uh, 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 going to we're we're going to keep these or all these kind of over on this left-hand side.I'm going to 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 just want to format it, right?I'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 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.Jeez, this is such a I hate I hate having a lot of visualizations on here.It just really uh is annoying to me.So, what we're going to do, we're going to step this to the side.Put this to the side as well.Make it to where it's just Okay.
I didn't want it to cut off.We'll do that.Might make thesethese 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, um, 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.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.Um, 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.We're going to 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.I 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.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 hope 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?So, let's get rid of these.And I want to click on this really quickly.See what it gives us.Um, bum 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.Um 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'll just say 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.Programming 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 going to do, we're going to 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 uh not really my style.Uh, 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's not my I don't like how dark that is.Um, and so maybe it's like, you know, uh, 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 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, let me just 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 going to 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 gonna 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 video.
What's going on everybody?Welcome back to another video.Today, we're going to be starting our Python tutorial 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, y 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, mapplot, lib, seabor, 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 our 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.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 2 to 3 minutes, and then it will 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 Anaconda 3 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 recommend you having this checked.
We can also register Anaconda 3 as my default Python 3.9.You can do this one.And I'm going 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 cuz 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, Spider, 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.And 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 dropdown and we're going to open up a Python 3 kernel.And 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.But 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.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 wanted 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 aaa because I want it to be at the beginning.Um, so I can show you this.I'm going do a aaa 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 a 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 also 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 todo 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, routing 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.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 video.
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 and 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'll 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 over 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.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 bloat.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, tupils, 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 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 test variable case.Oops.Case.Now if we have a test variable case, 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 test variable case.Again, this is a very similar way of writing it.Very similar to camel case.um 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 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.So let's do something like test var.So test var is completely appropriate.We can also do something like test_var oops underscore.We could do underscore test_var.You'll see that often as well where people will start it with an underscore.
You can do test var capital T oops capital T capital V in test var or you could even do something like test var 2.Now adding a number to your variable is not inherently a bad thing.Usually it's semifowned 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 dash var 2.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 too.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 get 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 + c.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 is equal to 1 2 and y z is equal to 3.So this should equal six.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 video.
12:01:11 - 12:02:00
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 closed parenthesis.And if we say the type of 12, it's going to give us an integer.Or if we say a -12, that is also an integer.
We can also perform basic calculations like -12 + 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 plus 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 3 J.
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, and that is also boolean.And this can be used with something like a comparison operator.So let's say one is greater than five.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 one is equal to one.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 tupils.We'll 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 ran.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 this 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.We can say five.What this is going to do is it's going to say zero 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 two l.Now we can 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.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 a 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 quote 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 list 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'll do an open parenthesis.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 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 tupils.So a list and a tupil are actually quite similar, but the biggest difference between a list and a tupil is that a tupil is something called immutable.It means it cannot be modified or changed after it's created.So let's go right up here.We're going to say tupil and let's write our very first tupil.So we'll say tupil scoops is equal to and then we'll do an open parenthesis.Now these open parenthesis 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 tupil 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 tupil.And we can just check the data type really quickly.And it's a tupole.And just like we saw before a tupil 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 tupil object has no attribute append.It's just because you cannot change or add anything to a tupil.Just like we were talking about before, typically people will use tupils 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 tupil, 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_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 going to put in a one, a two, and a three.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 one, a two, and a three.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 set and this is something that I've done in the past is comparing two separate sets.Maybe you have a list or a tupil 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 daily and we'll just copy this right here.We'll say is equal to let's do our squiggly lines.Let's do one two.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 set and then trimming it down to just the unique values.So we'll take wife's daily pints 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 amperand.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 five.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 daily pints log?
It's in this one, but we're subtracting the values on this one.So let's reverse this and we'll say daily 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 are 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, 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 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 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, the 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 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 bracket or not a bracket but 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 added 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 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 deel.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 wait.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.But 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 parentheses 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.
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 20some whereas chocolate is three.Right?So it 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.
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 l if 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 it 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 LF condition.The LF condition or statement is basically saying if the first if statement doesn't work, let's try this if statement.If this LF 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 of these things don't work then run this body of code.
Now you can have as many ill if 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 dot dot dot.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 lf comes in.So really quickly, let's change this to a not true, a false statement.We're going to go down and say l if and we're going to say if it is, and let's say 30, we'll say l if 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 l if worked.So let's try running this.and lf worked.Now, we can do as many of these LF 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 LF, LF2, LF3, and LF4.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 LF or else statements will work.So, let's try this one.It should be LF3.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 one is less than three 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.Uh, 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 three.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 five.Let's do a colon hit enter and 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 five, 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 tupil, 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 it'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 of 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 andthen 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 four.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 tupole.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 five 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 it'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 plus one.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 a 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 dot 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 dot 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 five 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 dot items.So we could also do key if we just wanted to do a key, but we want to do items.So we want 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 somethinglike 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 five.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 list.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.So we're going to say 41 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 two in toppings and 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 one.So we're printing the one in flavors.And then we're going to say one, comma, we're going to say top topped with comm, two.So what this is essentially going to do is we're going to say for one, we're going to take the very first one in flavors and then we're going to loop through all of two as well.So we're going to loop through hot fudge, Oreos, 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 video.
12:46:20 - 12:46:55
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 plus one.If you've never done something like this, it's kind of like a counter.Most people will 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 1, a 2, 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 y 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 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 and it's going to continue back into the while loop, but it's never going to have that number change 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 tocontinue 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 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 putit 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 parenthesis.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 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 hard-coded, we can now customize that and we'll have 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 three.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 three, 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 callingthe argument.So, you don't have to do it up front 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_s 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 we'll say args.Now you will see something exactly like this.Typically if you're looking at tutorials that'll have star 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.So 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.So 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 5a 6 comma 1 2 8.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 tupole and that's what this is right here.We're calling in a tupole.So what it's going to do now is when it calls this number, it's going to call the very first within that tupole 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.Now like I just said this is a tupole.So we don't actually have to write out these numbers like we just did.
we can pass through a tupil when we are actually calling this function.Let's do that right up here.Let's just create um let's call it args tupil and we'll do open parentheses and we'll do the same numbers.Let's just copy it to make it easier.And now we've created this tupil 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 args tupole 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 tupole.So, right now, it's going to say tupil 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 were creating your argument up here.
we have to put a star in front of our tupil 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 is equal to five and number is equal to three.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 five, 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_gand 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 starst star 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 plus.And this is kind of where it gets a little interesting or a little bit more tricky.So we're going to say is 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 is equal to 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'll say my number is 2309.Then we're going to add, we'll say plus, 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 just put a comma.And we'll say integer oops, integer 2 is equal to, and we'll do a random number.And then we'll put integer two right here.And then we'll add plus 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 it 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 that 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, tupils, and even dictionaries.So let's start off by creating a variable.We'll say num_int is equal to 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 is equal to.And for this one, we'll also do a seven.But let's check the type.And we'll do an open parenthesis.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 intint plus 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 for int and string.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
is equal to 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 numstring converted.And let's run this.And now we can see that it was converted into an integer.So now let's add that numstring 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 numsum 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 tupils.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 tupil.It's fairly easy.All we're going to do is write tupil say list type.That list type is now going to be a tupil.And we can check that by saying type and wrapping it around this tupil.And it shows us that it is converting that list into a tupole.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 of 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 and we'll do a colon and we'll say Alex.
Then we'll do age and a colon and we'll say 28 and then we'll do hair colon.And 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 do 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.So 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.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.So let's type out weight right here.We'll say weight is equal to 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 and we're using pounds.Let's say pounds colon space.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.I should have saved it.Wait 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 as 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, 59 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 by height in inches.So we actually have weight and it's already written in there but I'm just going to do it like this.
We'll do weight time 703.So that's pounds there.Our weight in pounds time 703 divided by now we have our height in inches times 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 times 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 cannot multiply the sequence of non- integer type of string.Ah, that's because these are being stored in strings.So, if right down here I do and we'll do type of height and we run that.This is actually a string.So, we want to change that because we don't need that anymore.Get rid of 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 integer.And then 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 70.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 there BMI in 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, anythinglike 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 is greater than zero.
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 ortype 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 under under case underweight and just like that.
Um then we're going to pass several LF statements through here.But let's just say else.So I guess this would be like if they are if they don't input something properly or something messes up maybe we could write something like um print oops I'm thinking all this through.We can write 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 more minimum.So, we'll say LF and LF.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 25 and 29.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, let's run this.And now our prompt is you are overweight because 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.
So, that's really good.And I don't think I want this to be our output for the 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 is equal to input.And then we'll say enter your name.Um, 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 in 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 is that how you spell it?Severely obese.And then anything that's over that 40 and over.So if it's not this one, anything else should be se morbidly obese.So actually this else statement right here should say uh you are
you are severely obese.This is going to say morbidly morbidly obese.Now I added that name up here because I wanted to add that down below actually.So, we're going to say uh name plus and then we'll do like 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' I do?Get rid of that.Name plus you.Like that.Jeez, you guys are seeing me mess up a ton.Name plus you.And then name plus 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 17069.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 within 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 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 video.
Hello everybody.Today we're going to be creating an automatic file sorter for your files in 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, and then we're going to say 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 getthis path down.So, I'm going to go ahead and copy this path.And we're just going to say path is equal to, 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.list directories.
Uh and what this is actually going to do is show us all the files in there.So 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 plus 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 hard coding 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 uh folder_names and we'll say is equal to 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, well actually let's write folder names.Um then we can put something like uh let's write loop.Why not?Um, so a little trick for the for loop is going to say for and we'll say loop in 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 two.So if we do range from 0 to two 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 zero which would be CSV files, image files and text files.Um, so let's uh yeah, I need a colon.Let's run through this really quickly.Uh, 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 osmake directory and then we'll do just like that.Um I think it's make directory s I think that's correct.Um so let's test this out really quickly.Let's see if this works.and invalid syntax.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.Okay.Ah.Okay.So, I think I know what might be happening.I think it's giving us It may 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 in this path.We didn't have that.Um, uly 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 well, 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 it didn't create the text.Let's see.Okay, let's uh 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 right, 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_ame is equal to 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.So 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 and oh not not in but 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 um also we're not doing that for loop anymore.
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.Um, actually, no.It needs to be like this cuz 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, um, 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 plus 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 shuttle.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 a comma.We need to specify its original path, which it should just be this without this.I think it should be file path 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 wanted to happen.Now we can just recreate this for um for both our PNG files or our image files and our text files.So we'll say LF and LF 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 were not 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 were not moved.Exclamation point.All right.Now, let's run through this.Uh, uh, that's because if LF l 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 going to take that out for now.So, I'm just going to run it.Um I 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 itjust to see if it works properly from scratch.Right.I just want to make sure that I didn't miss anything.Um, 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 checks each one.
We check if there's a CSV and if it's 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 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 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.And 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, 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 minieries.
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 jump on my screen and get started with web scraping.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 it'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 angle 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/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.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 scrapethesite.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 rightclick.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 drop down.
You'll notice that here we have this string hockey teams forms searching and pageionation.Now let's say we didn't know we didn't want to click on that and go find it.There is 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 we didn't really look at as well in just our simple illustration.Let's come right over here.There's things like hrefs.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.So 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.Then, 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.
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 used 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'll 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.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 we'll just say URL is equal to 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 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 of 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 of 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 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.So, we actually need to name this and we'll call this page.We'll say page is equal to.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 in to 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 we scroll down, I'll try to point out some things that we've already looked at in previous lessons.Um 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.That's going to say equal to this information right here.Now I'm not going to go into all the history behind beautiful soup.But what I will say is the guy who created this beautiful soup library, uh, what he said was is that it takes this really messy HTML or XML, which you can also use it for.
Uh, and it makes it into this kind of beautiful soup.So, I just thought that was kind of funny.Uh, 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 href 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 makesure 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.pritify.And if you've ever used a different type of programming languages, uh, Pritify is very common in a lot of them where it'll just make it a little bit more easy to visualize and see.Uh, 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 lefth 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 pandasdataf frame.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.
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 beautiful soup.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 is equal to and we'll have that right here.
Now, we need to say page is equal to and then we'll do requests.get 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 is equal to beautiful soup.There we go.And then within our parenthesis, we need to specify the page.ext 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 uh 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 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 uh 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.That's all of our information.and we're going to sayfind.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 list.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 uh this for slashd, 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 is equal to container.Class is equal to co MD-12.I don't know what these are at the off the top of my head, but um 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 can also use this a tag if we wanted to look at this.So, we could say, oh, we're looking for uh these hrefs.So, we have an href here and this right down here, we have this href as well, which again u if you remember from a previous lesson, that stands for a hyperlink.
Now something like the class or the href um 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 uh within something like find all is you can even do class underscore.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.So if we took this a tag, this is an a tag which would go right here with the class of something like navl link or something like nav link again down here.We need to specify that more but we have our div.So we'll say cl co md12 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 uh col md-12 doesn't just happen once.If we scroll down, we'll see it multiple times.Something like right here.Uh or actually, let me see, right here.So, here's this comma.Then here's our next one.So, we have two of these uh div tags with a class of coal- 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.Uh, 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 a P tag really quickly.Let's just see what we get.And 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.
And 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 where 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 href 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 where 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 underscore 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 find all 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 strip.Look like there's some white space.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.Well, 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 date 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 Pandanda'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 dot 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.And 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 were 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 dataf 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 lesson.
14:07:32 - 14:08:09
Hello everybody.In this lesson, we are going to be scraping data from a real website and putting it into a Pandanda's dataf 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 kindof 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, a little bit more tricky.We're going to have to, you know, format things properly to get it into our pandas data frame to make it looking good and making it more usable.So, let's go ahead and get rid of 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.Uh 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 give 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.ext.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 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.Uh, 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.I'm 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 sortter wikip sortable jQuery table sortter.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 would 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.Uh 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 is come right down here.
I want to add in uh another thing.Actually, I'll just push this one up.There we go.So, we're going to say find_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 Wells 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 find all.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 could, 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.And this is just for demonstration purposes.We'll do table, blast 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 none type object.Uh, if I remember, it 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 I don't know if that's what I was seeing earlier.Let's just get this rank.Let's go back up.Oh, where's the rank?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-t
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-t 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 what 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 great because then we can just do world_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 world titles and I'll kind of walk through what I'm talking about.This is in 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 to where we can see it.Um we'll do world table titles.That's equal to.Now we'll do our list comprehension.Should be super easy.Uh we'll just say for title in world_titles.And then what do we want?We want title.ext.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 it.So let's go and print our world table titles and see if it worked.And it did.Uh, 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, Pandas dataf 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 dot.ext.strip, 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, it 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.Uh 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 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.allTth, find all th which is going to pull in that secondary table.U gez 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 is a little project we're creating here.So, we're going to run into issues, and that's okay.We're figuring it 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 pandas 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 dot.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.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 rows, right?Then the D represents the data within those rows.
So R for rows, D for data.So 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 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 headers.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.And 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 is equal to 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 and we'll do a colon.Now we need to loop through this.We'll do something like row.find_all.And then what are we looking for?We're not looking for the tr looking for the TD.And just for now, let's print this off.See what this looks like.Apparently, I didn't run this uh 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 we're printing off another list which isn't actually super helpful.um for each of all these data that we're pulling in.What we can do is we can call this uh 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 uh world table titles we can change this into uh individual row data right and now let's printoff 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.Uh, 25 uh two, what am I saying?572754 2.4 4 2300 572752.4 2300.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 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 Panda 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.Um, 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 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 dataf 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 loc and then a bracket and we're putting in that 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 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.And not 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.Uh this is I'm almost certain is probably the issue.Um I didn't encounter this issue when I wrote these uh 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.Um 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, just doesn't want to display it.But it looks like we have our rank, we have our name, we 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.2 2 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 and 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 one drive documents Python web scraping 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.Um 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 were automating this, this would get super annoying.
So, what we're going to do is go back and just say index equals false.Let's go out of here.And now we're just going to come right down here.We're going to say, comma, index equals 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 dataf 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 dataf 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 the 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 lesson.
So, the first thing that we need to do is import our pandas library.So, we're going to say import and we're going to say 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.Uh, that's what I always use and I've always used it cuz 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 dot 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 that 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 rightclick 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'd 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 backslashes 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 dataf frame.It's really what makes a dataf frame a dataf 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 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 Pandanda 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 because it's a commaepparated uh file.You can choose delimters, headers, names, index columns, 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.Uh 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 doc string 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'thave a header in your CSV and you don't want it to autopop populate that header.So that is something that you can specify.So for example, this header one and I'll show you how to do this.Uh the default behavior is to infer that there are column names.If no names are passed, this behavior is identical to header equals zero.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 comma header is equal to and we could say none.And as you can see, there are no headers now.
Instead, it's another index.So, we have 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 the header equals none.Then we can say names is equal to and we'll give it a list.And so, the first one was country and what's that second one?Oh, region.So, they're right here.That's the first um the first row, but we'll rename it and we'll just say country and 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 is equal to.DF stands for dataf frame.Again, this is a dataf frame.In the next video in this series, I'm going to walk through what a series is as well as what a dataf 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 dataf frame dot and you can uh you know pass in different modules but you can't really do that.
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 cuz 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 slasht region and then all of our values are the exact same with this backslash t.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 cvv, this is how we can do it.We'll just say is equal to we need to do back slasht.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.Okay.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 separator.It's just reading it in as a table.Let's run this.And it reads it in properly 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 readers 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 semistructured 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 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 readers cell 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 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_name says 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.Um, 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 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 quote display
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 of 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 optionsdoc 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 a, 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 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 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.Um, which we can always go back and change those.Typically, you'll do something like dataf frame 2.You want to do something like that.Um, so let's keep dataf frame 2.Oops.So, what we're going to do is we're going to bring dataf 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 dataf 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, CCA3, 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 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 reading 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 thanwhen 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 dataf frame 2 and we'll do shape.And for this one, we do not need the parenthesis.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 dataf 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 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 LO and I look 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.Loc.And there's lo and stands for location and eyelocation.That's only for the indexes.Whether it's the xaxis 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 dataf 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.lo.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 eyelock looks at the integer location.So even if these um let's go right up here even if this index had changed to let's say this rank or the CCA3 or country or whatever you make this index the look will still look at the integerlocation.So that 224 would still be 224 even if it was Usuzbekistan.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.
Is that how you spellistan?Hey, I nailed it.So that is how you use LO and I look.Again, I just wanted to show you a little bit about how you can look at your data frame or search within your dataf 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 video.
Hello everybody.Today we're going to be looking at filtering and ordering dataf 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 dataf frame is equal to and we'll say pandas and I need to import my pandas.So we'll say import p andas as pd.That's pretty important I think.Um so pdread csv and we'll do r and then we'll say the world population cv.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 then 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 is in and then an open parenthesis and then look for our specific countries.So, we're looking at just this column and we're saying is in.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 um this doesn't look right.There we go.I just had some syntax errors.I apologize.Made it way more complicated than it needed to be.But here's how you use this is in 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 Pandanda 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 is in, except it's more like the like in SQL as well.I'm comparing a lot of this to SQL because 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 in we're going to docontains and then an open parenthesis.
So we're 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 lo and lo stands for location and i look 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 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 CCA3 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 zero, it's actually going to search this axis.This is the zero axis.This is the one axis.So, where our columns are is one.So, if we go back and do one, we're searching on that one axis or those header axises again.
And this is the default, but you can specify that.So, if you just want to search on, you know, filtering right here, you can do that.And let's actually copy this and do that right down here, just so 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 zero 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, you can just say United just like we did beforeand we're searching where the access is equal to zero, 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 LO and I look.So we can say dataf frame 2.lo.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 eyel which is the integer location which is not the exact same because we're looking at the string for the lo.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 a jumbled mess in here.We can sort these columns however we would like.Ascending, descending, multiple columns, single columns.And let's look at how to do that.So we'll say data frame and then we'll do dataf frame.
Look at rank again just like we were doing above.And let's do dataf 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 dots 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 is equal to and we'll just order it by the exact same thing that we were doing uh or calling it on.So 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 in 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 9876 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 let's 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, 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 video.
Hello everybody.Today we're going to be looking at indexing in pandas.If you remember from previous videos, the index is an object that stores the access labels for all pandas objects.The index in a dataf 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.And you won't always use it, but it's really good to know in case you come across a data frame that has that in it.So, let's get started by importing pandas.import pandas as pd.Now we'll get our first data frame.We'll say df is equal to pdread_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 cv.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, especially if I 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 inhere when we're reading in this file and we'll say comma index oops 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 dataf frame.So we had our dataf frame right here.So we have dataf frame dot we'll say reset_index.And then we'll say in place is equal to 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 and I'll show you how to do this in a different way.You can do df do 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 set index column equals country.If we do this and we run it in, it works.But if we say dataf 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 is equal to 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 is equal to 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 pandas 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 lock and there's lock and eyelock.That stands for location or integer location.Let's look at lock first.Let's say df.lock 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 eyelock right here.And when we ran lock we're searching based off Albania which is in the 01 position.So if we actually pull the one position for that integer the eyelock 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 dotreset index and we'll say in place equals 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 dataf 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 separated by a comma.
So we have continent and country.Let's just say in place is equal to true.Now when we run this, we're going to have two indexes.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 it look a lot better.So let's go ahead and try this.We'll do df do.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 do set option and we'll say display.mmax doc 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'sdo 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 equals true and then when we run this oh meant 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 dataf frame.lo.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 angola And now we have what we werelooking at before where we're calling all of 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 eyel.
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 LO 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 integerbased 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 pandas 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 video.
15:15:20 - 15:16:11
Hello everybody.Today we're going to be taking a look at the group by function and aggregating within pandas.Group by 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, 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 group by and the aggregate functions.So, the first thing that we can do is look at our group by.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 I'll group together.So, this base flavor is actually a perfect one to group it on.And we'll do that by saying df.group by 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 group by dataf frame group by 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 Pandanda 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.and 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.group by 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 had three.So there's 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 vanillaas, but all the other ones were bad, it pulls that average down.So, knowing the count of 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 um 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 like.Chocolate I like.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 or 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 because this is um a little bit more complex.Although when I write it out or show you hopefully it makes a lot of sense.We can do agg.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 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.group group by 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 doliked.So now when it groups this, it should 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 a 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 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 highlevel 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 mean.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 group by 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 video.
15:26:25 - 15:27:08
Hello everybody.Today we're going to be talking about merging, joining, and concatenating data frames in pandas.This whole video is basically around being able to combine two separate data frames together into one dataf 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 dataf 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 it 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 dataf frame and it's going to give us everything that is similar but it's not going to give usanything that is just unique to the left dataf 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 and as pd.We'll run this and then we'll say dataf frame one and we'll also have a dataf frame two and these are the different data frames the left and the right dataf frame that we'll be using to join merge andconcatenate.So we'll say dataf frame one is equal to pd.csv read and we'll do r and here is our file path.
So we have this lo 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 read_csv.Uh I apologize for that.But this is our dataf frame.This is our dataf frame one.We have three columns.It's their fellowship ID 101 2 3 and four.Their first name Froto Sam Wise Gandalf and Pippen and their skills hiding gardening spells and fireworks.So this is our very first dataf 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 dataf frame two.Dataf frame two.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 78.
So we have three different IDs here.We don't have 67 and 8 in this upper this first data frame.We also have the first name.So Froto and Sam or Sam Wise are in the very first and the second data frame.But now we have three new people.Baramir, Eland, and Legalis.And now we have this age column, which again is unique to just this second dataf frame.Really quickly, I want to give a huge shout out to the sponsor of this video, and that is Zenesk.I've been using Zenesk for my company's customer analytics, and has been absolutely phenomenal.They're going to be hosting a conference called Zenesk Relate on May 10th, and they're going to talk all about customer analytics, chat bots, 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 the 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 Zenesk 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 dataf frame one.And when we specify dataf frame one as the very first dataf frame, we say dataf frame.This is automatically going to be our left dataf frame.Then if we do our parenthesis right here and we say dataf frame 2, this is our right dataf 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 1001 here, a 10, 102 here.
This is the exact same as up here with this fellowship ID and fellowship ID of 101 and two.But when we look at 1000 3 and 4, those aren't in this right data frame.And 678 is not in this left data frame.So the only ones that match are this 101 and two.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 it 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 underscorex and this first name underscorey.What the merge does as kind of a default is when you are only joining on a fellowship ID, we have this right dataf frame with fellowship ID, the left dataf 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 underscorex and an underscorey.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 it the first time even though we didn't write anything.But if we actually write 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 2.
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.But 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 underscorex and underscorey.You can customize that and you can put in whatever you'd like.Instead of the underscorex_y, you can put in some custom um string for that.
We also have an indicator and a validate.Again, all the things that 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 joint is probably the easiest one to understand.Let's look at the outer is spelled o u t e r.I don't know why I always want to say o u t e 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 and 8.So we don't have a 1005.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 legal wasn't one that we joined on or that hasa similar value in the left dataf 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 dataf frame one.Then if there is any overlap, it'll also pull the over overlapped or the, you know, whatever we're able to merge on from dataf frame 2.So let's go back up to our dataf frame one and two.So it's going to pull everything from this left dataf frame because we're specifying we're doing a left join.
So everything from the left dataf 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 10006, 10007 or 1008.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 10001 and 102.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 dataf frame one, then we will pull that in.So this is basically just looking like dataf frame 2 except we're pulling in that skills column.And since only 101 and 102 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 dataf frame or when I'm trying to merge a dataf 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 dataf frame and compares it to each value in the right data frame.So for Frodo in this left data frame, it looks at the Froto in the right dataf frame, Sam Wise in the right dataf frame, Legololis, Elron, and Baramir all in the right dataf frame.
Then it goes to the next value, Sam Wise, and does the exact same thing.Roto, Samwise, Legololis, Elron, Baramir.And it does that for every single value.So let's go right back up here.So it's taking this this 1001.It's comparing it to one two three four five.Then it's taking Sam Wise and it's comparing it to one two three four five Gandalf one two three four five 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 alot of instances in actual work where you really use or 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 and 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 dataf frame one.And then we'll do dataf frame two.very similar to how we did it before.And 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 comma and we'll say on and 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 samekind 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.And 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 L suffix is equal to and now it automatically when we did the merge did an underscorex but we can do let's do underscore uh left and then we can do a comma we'll doright 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 it 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 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 is 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 going to join it on df2 set_index.
And then we're also going to do that on the fellowship ID.And I'll just copy this.
Oh jeez, 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 because we do need to specify this.Now let's try running the data frame for.So really quickly, just to recap, we were setting the indexes.We were doing the same thing above, right?Right?We have this join.We were joining dataf frame one with dataf frame 2.Now we're joining dataf frame one with dataf frame 2 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 dataf 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 dataf frame next to one another which islike 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.conat.We'll do an open parenthesis and then we're going to concatenate dataf frame one, dataf frame 2.That's all we have to write.And let's run this.And so just like I said, it literally took the first dataf 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 thetop 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 lookinto as well but let's look at join let's do 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 data 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 1.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 it's one called append.
The append function is used to append rows from one dataf frame to the end of another dataf frame.And then we can return that new dataf frame.And so let's do dataf frame one.append.We'll do an open parenthesis.And we'll say dataf frame 2.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 not append method is deprecated and will be removed from pandas in the future version.Use pandas.conat 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 oftentimes 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 video.
15:48:34 - 15:49:22
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 spd.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 mattplot lib.pipplot 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 dataf frames equal to pdread 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're 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 dataf frame set_index and then we'll say date and then we'll say that's equal to the dataf 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 or 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 dataf frame.plot and we'll do our parenthesis.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 we 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 uh different indexes, you can add titles, add grids, legends, styles, all these different things.I mean, you can go through here because 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.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.
Uh 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, a,000, whatever you want it to be.And then we're doing this based 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 axis.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 x label 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 y label is equal to and for this one we can say scores.Hope you cannot hear my dog in the background because they are 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 it's 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 in 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.catter.
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 axis 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 and let's just do 100.We'll 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 or the data frames that we want to pull in.We 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.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, it's 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 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.So, 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 m medium point is at 6 versus 04 over here.
So the skews a lot higher.Now let's go down here and take a look at an area plot.We'll do df.plot 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 fig size.Um, so for this, it's know it's just looks small, looks a little bit cramped.So, let's say we want to increase the size of this.And we'll say fig size, oops, fig size is equal to, and let's just do a parenthesis and say 10, 5.That should be pretty large.This is going to make it a lot larger.Just something I wanted to throw in there.But 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.py.pi.We're going to 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 our column that we're going to plot.That's really all we need.So, we can just say y is equal to labor rating.
Oops.Labor 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, six.So now it's a little bit bigger.It definitely depends.So this legend is going to autopop 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 autopop 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 Mattplot Lib, there are different styles.Um, and so let's go right here.Let's add a new row or a new cell.And we'll say print.We'll do plt.So that's that mapplot lib 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 types of stylings that you can do to kind of change up this visualization.And then once we find the one that we like, we'll just do plt.styleuse.And then in the parenthesis, we'll just specify which one we want.Now, there's all these seabor ones.And seabour is a really great um really great library.Let's try seabour deep.I haven't tried this one at all.Let's go ahead and try this.It 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 a really good introduction on how you can visualize data within Python.And in future videos we'll look at map lib 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 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 whenyou 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 dataf frame is equal to pd.So that's pandas read underscore and we actually have this in an excel file.So we'll say read oops say read excel do an open parenthesis 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 dataf 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 1001 all the way down to 1,020.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 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 thedata set completely.All you have to do for that is say df.dropduplicates.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 dataf frame variable again.And now when we run this, our dataf 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 intothe 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 do drop.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 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.Um, just for keeping it the same.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 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.and 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 it to everywhere.So, if we're trying to do these, yeah, let's say 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.Strip.Now, what strip does, and let's see if we can open this up really quickly.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.Well, lrip takes from the left side.Rrip 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 swan_son, the strip wouldn't work at all because it's not on the outside of 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 left strip 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 L strip 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 1 2 3.Let's run it.And no, it doesn't.Um, this lrip 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 going to 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 dataf frame equals cuz 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.So, 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 to 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 R strip.So, now let's use R strip.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 R because we want to do apply it to everywhere.You can input all of those values individually and it will clean it up.So let's say we want to get rid of numbers.
We'll do 1 2 3.Then we can do the dot.So that's going to be for a period or for our 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 dataf frame and we assign it to that column, so the last name column, we're 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 of formats.I mean, it is um it's not going to be fun.And imagine, 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 1 2 3-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.it just oops that's not what I wanted.So we're going to do a bracket say phone number dot 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 program.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.
Now, at a super high level, what that character or 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 lower case.And then actually, I think this should be like this.A to Z.Uh and then 0 to 9.So any value like ABC 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 because we had an N- A for I don't know, 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 Nan 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 number is equal to and then we'll say dataf 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 gonna say DF phone number.We've already done that.I'm just going to get rid of it.Now we're gonna 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 colon.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 three.So it 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 third 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 that 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 three, four, five, 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 want 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 um 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 1 2 3-545-5421
and it does that for every single one where there's values even where there's nan or na it's still adding those values but we expected that so let's apply it says equal to and then we'll look at the dataframe and this looks almost exactly what we're hoping for we just need to get rid of these So, this nan- 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 sayreplace
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 callthat 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 um you know formatting and we got rid of all the ones that we don't have or don't need.Um all the ones that were just random values.So this column is now completely cleaned up.
Again, definitely one of the more difficult ones.Um ones that I've done a thousand times.I've had to work with a lot of phone numbers and stuff like that.This one does get very tricky, especially if you have like a plus one, which is like an area code.Um 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.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.And 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 oops.Oh jeez, not again.So, we want to specify that we're looking at the address.Then we're going to say dot string dotsplit.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're 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 012.
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 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 um it's sh is not a state uh but these all are state.So I'm just going to say state.And then the very last one that looks like a zip code.So we'll say zip and we'll do underscore code.In fact, I also want to do street address.Um, so what this 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 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, NY, yes, no, NY.Um, 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 keepit consistent.So, let's make anything that's an N into a no.Anything that's a a Y into a yes.I like it spelled out.So, let's change anything that's uh a yes into a Y.Anything that's uh a no into an N.That's usually how I do it.Just saves on data because it's less strings, although it's be often very minimal.Um, but let's specify the customer.We'll s say df bracket paying 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 y's.We now just have yeses.Although now these are 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.Um let's change the let's change that y into a y.So now it's doing y es.Uh we don't want that.So let's look for the yes and change into a y.Now when we run this that looks a lot better.Um so we'll do df paying customers 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 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 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 our 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 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 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 nan as well.And we'll 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.Um let's get rid of this.uh to get rid of those values because it's literally not a number there.It is technically empty.Um I forgot we can do um or we could not even specify it.We'll do df.fill na.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 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're 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 and 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 why 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 why, we're not going to call them.So what we need to do and 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 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 4x in and we need to look at our index.So we're just going to do let's do in 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 lock.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 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 in place equals true here otherwise it won't take
effect.Um otherwise you have to say like df is equal to df.ai and I don't I don't want to start messing with that.Let's just do in place 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.Need a colon.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.Uh 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.If 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 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 um those rows were removed.And okay, good.Actually, this worked itself out because these all have ends.Um so right now we're sitting really good.Everything looks really um 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 paying customer doesn't uh 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 called list, we probably should reset this index because they might be confused as why there's numbers missing or you knowthey might use this index um 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 gonna say df dot 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 uh 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.rop a 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 Y's.So, we couldn't do that.But because we're looking at null values, we could have also done drop NA.Um, and done subset is equal to and then done it just on this phone number and then done like this and done in place equals true.So, we could have also done this then said df equals.Um, 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.Um, 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, a hundred thousands, a million rows, these are all things that are going to beapplied to 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 doing 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, a lot more um 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 and 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 video.
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 um 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 are import our libraries.
So we'll do import pandas as pd.We're also going to import seabor and mapplot lib.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 a larger broader glimpse of everything.So, we're going to import and let's do seabour oops sns and then we'll import mattplot.lib.pipplot piplot as plt.Let's run this.That 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 dataf frame equals pdread csv.Do r 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.um 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'stoo 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 highlevel information from this.Now, if yours looks just a little bit different, like your values are in scientific notation, uh I have applied this so many times I think it's um 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.flat_mat.
And so we're going to change that float format by just saying lambda x colon and then we're going to change basically how many um 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.2F.So we're going to format it and we'll do percent x.This is going to format it appropriately.I'm I can run it.Um, and actually it will change it cuz 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.Um, let's go down here and let's just pull up data frame.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 highlevel information.This is how many columns we have.Here are the column names.Here are how many uh 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.Um, 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 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.The next thing that I really like to do, and this one is df.describe.This allows you to get really a highlevel 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 25, 50 and 75 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.I that's just interesting.Then if we look at the um 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, this is just a nice highle overview.
One thing that we just talked about was the null values that we're seeing in here.Um, I'd like to see how many values we're actually missing because that is a problem.Um, 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 dot sum.And when we do this, whoops, dotsum.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 47755424.Um, 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.
um 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 um either 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, this is definitely something that I would consider um 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.This is going to show us how many unique values, and it's actually n unique.Uh, this is going to show us how many unique values are actually in each of these uh columns.And this one makes the most sense um for continent because I think there's only seven continents, right?
Um 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, um, a lot of them are really low.0.00.01, like this one, um, 0.2.there are a lot of really low values for those small countries and so those are all um you know one unique value.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 sort values.This is how we sort and um not filter but um order our data.So we'll do sort values and then we'll do by is equal and then we'll specify that we want uh this 2022 population and then we're going to say comma and we'll say actually let's just run this as isbut 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.Um, 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 um, you know, 510.That's the value that we were looking at earlier.Now, we can do comma ascending equal to 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, um 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.Um if we look at this world percentage, just China alone, I believe, yep, just China alone is 17.88% of the world.So 17.88 88 and 17.77 and that's China and India and those are very large countries with a high high high population.That makes a lot of sense why that is the highest 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 like doing this which is looking at correlations.Um, so a correlation between usually only numeric values.We can do that by saying df.co C O R R 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 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, small area and a very high population.So there isn't a onetoone correlation there, but it's hard to really just glance at this um 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 heat map 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.core correlation.And then we also want to say anote equals true.We'll kind of show you what that looks like in just a little bit.Um, but let's do plt.show.And this will be our first look.And I need to say show, not shot.Um, we can get a little glimpse of what it looks like, but this looks um, absolutely terrible.Let's change the figure size really quickly.So, I want to make this much larger than it already is.We'll do pltr params rc params.Oops.Right there.Do an open parenthesis.And then right here we're going to do in quotes.Do figure size.This actually needs to be in brackets I believe.
Just like this, not parentheses.We'll say fig size is equal to.And now we can specify the value that we want.Let's do 10 comma 7 and see if this looks any better.No.No, that doesn't look good.Do 20.Okay, that looks a lot better.And um 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 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 have assumed that on some levelthey went handinand the area does um which you know again makes sense you know larger area larger population that kind of thing but even density um I guess I guess density and growth rate um growth rate I cansee because that's a percentile thing that could 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 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 you really comes in handy when doing this.But sometimes you don't.Sometimes you're 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 I'm kind of looking for.Not doing full data analysis or 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 dfgroup by and then we'll say continent.Oops.Let me just copy this.I'm I am not good at spelling.We're going to say dfgroup by and then we'll do mean.And we can just do it just like this.And now we have Africa, Asia, Europe, North America, Oceanana, 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 ocean is.Um 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 then we'll say content.Let me sound that out for you guys.Um then we'll do string.contains.Oops.Contains.Good night.And then I want to look for ocean.Uh and let's let's run this.Oh, I need to do like this.
Now let's run this.So now we're looking at our data frame and we're seeing when the values have this continent as ocean.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 Oceanana.Um, Oceanania Oceana 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 Oceanana Oceania.Jeez, I'm just going to call it Oceanana.That's so wrong, but I'm just going to 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 dot 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 when we're looking at this average or the mean population, Asia has the highest population on average.Then we have South America, Africa, Europe, North America, and then Oceanana at the very bottom, which makes perfect sense.Again, small islands.Um 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 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 I would be like what is this Oceanana 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 can do DF2.Oops, what am I doing?I don't need to do that, but I will.Okay, DF2.and we'll do df2.lotand we'll run it just like this.Um, as you can see, Asia, South America, Africa, Europe, North America, Oceanana, 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 umin 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 parenthesy 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 for my earlier dataf frames.So now we have this dataf frame three.So now let's do dataf frame three.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.We're 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 2 that we transposed.We can go right up here and we can specify within this.We actually only want specific values.Now, we can go through and handwrite all of these.And by all means, go for it.But I am going to go down here.I'm going to say df.c 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.Again, you get 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.c 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 3.Okay.So we can do five up to 13 because I think it's seven.And we'll just let's see if this works.Uh 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.Um, okay.It's backward.So, what I actually want to do is not this.Uh, 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 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 have 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, 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 ocean, ocean, 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 02 so they've almost doubled um in the last 50 years and again you can just get an overview a highle overview of each ofthese 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 wanted to
give you an example like you know when you're looking at this sometimes times 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 yousee.Um, the next thing I want to look at is a box plot.Now, I 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 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 um really really powerful and useful to be able to find these.So all you have to do is df.boxplot.Yeah.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 fig size.Oops.Sorry.Fig size is equal to let's try 20 by 10.Um, okay.That didn't help at all.I apologize.I thought it would, but let's keep going.What this is showing us is that these little boxes down here, which are actually usually much larger because you have a more equal distribution of of um numbers or values in this 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 or 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.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 and you know oddly enough but that's what box plots are really good for showing you some of those cortiles the upper and the lower um as well as denoting these points that fall outsideof 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.Uh, 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 dftypes.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 themexplicitly 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 underscore dtypes now let's run this now it's onlyreturning 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 wanted 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 typesyou'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 dataset.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 uh 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 someway 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.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 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 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 infact 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 thatwhile 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 of 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 Jupiter 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 Andaconda, 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 know, 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's 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 have it like 90% of the way done.
Um, but I have this one completed and so I wanted to get that out to you guys now.But that'll 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 is 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.Did I spell that 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?Was 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 going 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 because 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 right 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 nobody should be able to do this off 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 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 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 in 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 theselibraries.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 as we go along the way so that you can kind of see what it looks like and how we're goingto 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 soup one 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 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 soup one.I don't like I don't like doing uppercaps 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 this stuff is good to know.So, as you see, I'm scrolling on this right side.By the way, I did rightclick 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 t 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 soup two.We're just going to do a very uh you know uh an upgrade to soup one basically.We'll do beautiful soup again.And then we're going to do uh soup one.So we're pulling in that content again.So that's soup one.And we're going to do pritify.Uh, 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.It that's really all it is.Uh, I don't know why I'm using double quotes.I don't know why I can.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 can tell, it was it 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 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 um 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 soup 2.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 soup 2.So using taking all that content and we're 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 dodot get text and then we're going to do open parenthesis.So now let's um 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 uh let me let me 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 soup 2.find.And then it's going to be again ID is equal to and then it's going to be price block_rric.Did I spell 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.
you 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 what why do I have all this too much uh too much space?So let's t print the title and print the price.Now 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 it just is, you know, if we try to use this, it wouldn't be super useful because it'd be it's 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.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.This is 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.Um and pull uh just do everything after that first um 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.Um, super easy.So, we're just going to do title strip and open parentheses.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 let me just add a few of these because 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 thisprocess to pull this data um to create a data set.Right?Just pulling this one time and putting it 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.Um, 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.Um, I'm doing a lot of talking.Let's do some writing.So, what we need to do is we're going to use um 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 uh 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.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 do 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, 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 this stuff.It's really important to remember what what type um how do I say this?Uh, 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 want to show you that really quick.But what we are now going to do is create a CSV.Um you're create an Excel.I I call an Excel CSV, you know, whatever you want to call it.So what we are going to do is we're 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 we're going to do underscore W and that means write.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 write.Um, and then we're going to do new line.And 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 encoding 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 needs 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 is 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.riter and we're going to do open parenthesis and that is that and we'll just call that writer and then we'll do and this is where we need toactually create the header.So uh we're going to do writer is dot sorry writer.right row 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 write
17:41:21 - 17:42:28
row open parenthesis.And this is where that header is going to go.So, we're going to the 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 write row.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 um my subscription.Uh why does it say $6.99?Uh 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 699.If I do it again it's 99.Uh and if I did it again it's you got it gets rid of everything.So I'm just going to run this again.Run this again.
Uh now everything's back to normal.Okay.So now if we run this, it's going to overwrite this Amazon Web Scraper 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 of 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 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 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.Jeez, I hate having to format stuff like that.And what you can do is you can do date.Let me get date time.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 21st 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 pdread_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 I do our uh let's actually call this um data frame 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.It's 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 a 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.Um 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 this CSV.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, oh, 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 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 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 will 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 are going to put this all into uh this check price.Now, you may never have used Oh jeez, 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 there'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 date time.
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 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.Uh 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, 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 price.That's what we just wrote out.And we're going to do time.Now, this is completely up to you 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 and 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 now 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 ever 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 that's 86,
400, I believe.Did I read that right?Oops.Did I read that 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 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 andI 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 illustrator 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 jeez, it's hounding me.Let me get out of here.Oh no.I This is embarrassing, guys.I'm embarrassed.We now have a CSV file with data in it.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, you lose connection, just come in here, run this through the 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 and 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 a 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 thensend 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're going to create this.Super simple.Um and that's 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 I'm 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 a Black Friday sale.I was really really happy about that.So, this can be used in that way as well.Um, not something you have 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 um 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 instructionalI 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 product or go to something that you are interested in or you know, fluctuates often.Um, and there are plenty of those on Amazon.I promise you, there's 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, 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 sendoff.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 you 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 video.
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 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.Then, we're going to do a little bit of transformation with the data.I'm going to show you some cool stuff on 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 beginner's 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 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 youpull from.So with that being said, let's jump on 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 this script right here and I'm starting basically from scratch.I have a completed one up here.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 setter 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 is 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, 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 two date time and then we're going to do now.And what this is literally going to do is take the the date uh the the time stamp of right now when it's running and it's going to show that.Now we need to of course add a new uh a new column for that.So all we're going to do is we're going to say data frame.Whoops.Say dataf frame.And let me see real quick.So we just have the data.We need to add we need to create this data frame right here.So dataf frame equals and then this JSON normalized and we're going to say dataf frame and then we're going to do a bracket and we're going to say timestamp and we'll do well 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 time stamp.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 time stamp, but it is not the same thing.Um, but if you looked through this data and you really dug 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 h 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 through 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, whenever 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 do 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 or an automate a script to automate this that is going to append data to this data frame righthere.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.
I'm 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 def and we're going to call this the API_runner.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 you need to go over here.I'm going to hit tap.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 going to need to add this.We'll just put it down here.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, format it right here.Then we're going to add this timestamp and then we will have this.Now, right now it's just call 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 dataf frame set up up top is we
now want to say that this is going to be dataf frame 2.And we're going to say it's going to append it to dataf frame 2.And so the original dataf frame, we're going to say dataf 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 time stamp 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.
18:12:35 - 18:13:24
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're 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 or 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 goingto 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 uh 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 say uh spell successfully.If that's if it's 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, it ran the first time.Now, I'm not going to 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 createthe final product where we're creating all the visualizations that 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 youwant 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 wehave.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 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 dataf frame 2.So, um, take change your script.Do not do what I just did.We're supposed to be append.It's supposed to be dataf frame append.And we're supposed to be appending the original d this data frame two to the original data frame.So, um, I messed up on that one.Let's rerun that.Let's rerun that.Um, let's see.Um, 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 are 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 whatthey 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 ran 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 or issues that I had to research for hours um and hours.
I'm legitimately on Stack Overflow and just googling and figuring 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 up.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.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 this was ran on 52651.Let's go down.526 at 150 2905.I say 1501 2905.And the next one you can see was ran at 3006.
31.These are all the ones 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 intoa CSV.Now, all we've done in this one is we we've kept it all enclosed in a dataf 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 3es and fours.These were tests that I did before.But what you can do is instead of just putting it into a dataf 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 ina dataf 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.pathdot is file.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 dot or or r.Um, if you have never done um if you've never done CSV stuff before, uh, 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.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 dataf frames.That's this dataf frame right here.Dataf frame dot and we're going to say 2 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 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 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 col the column headers every time, which you don't want because every time you append it, if you added the headers, every15 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 dataf frame, which it's already appending it to this dataframe.So, every time you'd be creating a lot of duplicates 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.Uh, 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.
CSV.Do that.We're going to call this just like that.And then we're going to say data frame.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 data frame 72.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 to 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 zero 1 2 3 4.And if we look at the time stamp, it should be 1 minute apart.So it's 11945.It said 120 45.So this worked exactly as planned.Um 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 dataf 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 clean.That's not what this project is.We're not doing a full data cleaning of this data.That would be a m 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.
This the math will be fine.It's just the way that it's shown on here is in state uh the scientific notation and I don't like it.So, what I'm going to do really quickly is just um get rid of that.So, we're going to uh we're going to say PD set and do underscore option and this is going to be do parenthesis.We're going to say display this is just this how this is formatted.So we're going to display uhflat_mat
and we're going to say comma and we're now we're going to use this lambda say x colon and we're going to say percent 5f that right there and we're going to say percent 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 going to hit df.Click 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 1 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 lasthour, 24 hours, 7 days.So, as you can see, it's it's barely fluctuated over the past 24 hours.A little bit over the past um 7 days, a lot over the last 30 days, 60 days, and 90 days.20 - 26% - 33%.We're in May.Hey, 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.Um, now another issue, not an issue, but another thing that we have to take into consideration is we have Bitcoin right here.We have Bitcoin right here after different polls.Now, we just did it a minute after each other, but for your project, you 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.group by.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, ethereum to other.So, we're going to we're going to do that on name.And uh I'm not going to I'm going to 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 gonna do boom and then go over one.And we're going to take 24 hours.Paste that comma.We have the 7-day 30-day.And we're going to do like that.And I'm just going to do comma.I'm going to do the same one, but I'm just going to manually change it to 30-day 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, uh, 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 mean.
We're going to do an average.Um, and and so we're taking this number.So, 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, it doesn't really work because these percent changes are up here as columns and we don't really want them as columnsbecause 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 in Excel or or PowerBI or something like that, that was my first thought and I tried everything and I could not could not get it to work and I almost
gave up until I I ran across um something called stacking or a stack 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 if I'mbeing 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 day four.And you don't have to do this.Uh 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 it 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 this 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 data frame three.This is before um before we stacked it.This was in a dataf frame.But now let's go and look at dataf frame 4.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 it can be up here better.So now what we're going to do is we're going to say dataf frame 4 dot and something called two 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 actually mean the name of these values right here.This is part of the stacking process in 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 data frame five and let's see the output whoops for data frame 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 type dataf frame 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 dataf frame five we'll do set index and then you'll do something like um name.So let's just do dat 6 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 day frame five bracket name.
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 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 index and we're going to say uh you know we basically want how many um rows are in here.So that's what 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 going to take the super lazy route.Um and I'm just going to say let's do df5 or oops df5.count.count and there's 90 values in here.So 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're 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, and 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 and we're causing issues in 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 dataf frame six dot rename.And then we're going to do an open parenthesy.Say columns equal to, and we're going to do one of these bad boys.
Oops.One of these bad boys.This this type of bracket.And we're going to say level underscore 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 dataf frame 7.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.This is 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 Seabor as SNS.And if we need to um we're going to import mapplot lib 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 xaxis is equal to and we want to do this as the percent change percent change.And then we have the yaxis.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 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 names.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.Now, 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.I 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 dataf frame seven.And we only want to look at this one column.So, we'll do that right there.and we want to say dotreplace and we're going to do an open uh uh parentheses 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.This is what it's going to change to.I'm just going to say 1 hour.Oops.1 hour.
Um, and we'll do this one really quick and then I'm going to 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 forthose.But let's let's see this really quick.And so now, as you can see that um the originally it said quote usdp 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 dataf frame 7 is equal to and then we'll run dataf 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 underneath.
So I have 24 hours, comma, with the seven 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 one 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 gonedown 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 doing 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 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, USUSD price.This is the price of the actual cryptocurrency.Then we're going to do time stamp.And let's make this data frame.And we're just going to do 10 for absolutely no reason.Maybe I should have made it nine.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 dataf frame 10 dot query do 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 equalequal 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 dataf frame 10 is equal to let's try running that think Something's wrong with it.Try like this.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 line plot and that's going to be like a little line chart or line graphwhatever whatever you want to call it.Then we're going to say x is equal to and we'll say quote no actually we want the time stamp 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.Could not interpret timestamp for the parameter.Uh that's because it's not understanding that the data equals dataf frame 10.Now let's try this.All right.So this is uh looks terrible.Let me just say snss.Set theme open parentheses.We'll do style is equal to dark.
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 can look at multiple and we're showing this, you know, this line that's showing us this trajectory overtime.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, 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 balland 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 and data, but I wanted to show you just a few things that I initially saw that I might do with the data.
And 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 I 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 and I'll see you in the next 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.
Now, we just completed our data analyst portfolio project series where we walked 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 will 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 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 um 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, HTML 5.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 the GitHub project.Um and then you this whoever's checking this out like a 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 websitewith the Wix um in the URL.So, you know, try this out.These are super easy and you can find thousands of templates and a million tutorials on 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 uh down here.So, once you have that installed, what you're going to do is you're 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 going to 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 just 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 it's 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.I'm just going to call it massively or you can call it um port website.Whatever you want to call it.I'm just going to do port 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, gonna 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 port website.And we're going to go select folder.And you're going to 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 view.So, like if I click right here and I click open with live server, you don't have that 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 says 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.Let me see what this 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.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 li 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.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 enjoy this project series.I think I'm just going to do more of them.So uh all right, I'm going to 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 squish, and I'm sorry about that.Um, but if we look right over here, this says this is massively.So, 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 going to hit control save.You can also go up here and hit save.But I'm I'm 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's 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 gonna try not to go full and go back and everything like that.So, we're just gonna say Alex the analyst portfolio.Um, control S.And right up here, it 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 5 template.We can customize that and I highly encourage that 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.include 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.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 any 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 about 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 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 we're now you can have this full story.I chose to do view project.And if I hit Ctrl 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 indiv individual posts.Um, actually, no, wait.What I want you 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 COVID uh that's our COVID 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 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 Magna.
Again, I think this might be like some language.I just don't know about.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 would 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 whatthey want to look at, then just choose this URL that we're choosing right here.So, um, in here or on in the, um, HTML, we're going to put I'm going to put Tableau 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 Crl 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 uh, no, I'm just going to do these three.I'm not going to 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 cuz 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 this section.So, don't delete this section.We want that.I'm going to delete this footer section is 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.67890.So, we're going to do that.Phone number one, two, three, five, six, 789.And then email.and we'll put Alex thean analyst 95gmail.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.That is my actual email if you are curious.Now, um, now that we have this, we also have these this 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 in.And then for right here, I'm going to replace that with linked in.And what you're going to do is put this link right here.And then we're going to go get do get the GitHub.So, let's do GitHub.
Oh, who's is this sign up?What is going on?Um, I don't there.Let's just go back here.That was something 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 of 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 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 all 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 two 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 COVID.Um, if I open up this COVID 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 had.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, um temporary images that they had for us, and we should be golden.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/pick01.jpeg.So, uh 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 COVID.So, we're going to get rid of this.Want to say COVID.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 Tableau.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.Oh, this one still says full story.Go change that.Um, I'm gonna go change it.Just doesn't feel right.
Uh, view project.That's not useful.Okay.Crl S.Perfect.Okay.So, now this looks a lot better.Um, and when we host it um through GitHub pages or github.io, Oh, 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 theanalyst 2.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, um 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.Says 75, but it shouldn't take that long.
And let's just wait for it.I was 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 it's loading, let's go over to Oh.Oh, there it is.So, perfect.So, here's everything that we have.Has this read me that it generated.Let's go over to settings.And we have this u github.io.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 we want it to do pull from the main.Um I think it's the docs.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 Alex analyst, but I'm going to 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 umio 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 and it's being ho hosted through GitHub and it's completely free.If you want to pay you can hide this from your GitHub.Um your repository has to be public.Uh 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 may 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 so that you can go in there and if you want to download these images, you can download the images that 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 now 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 to 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.Goodbye.
What's going on everybody?Welcome back to another video.Today I'm going to help you create a data analyst resume.
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 and 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 on 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 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 belike, uh, this person doesn't have any experience, I don't want to hire them.The first thing that you want to have on 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 because sometimes your job is going to be location-based, whether you're in Dallas or another metropolitan city.It's just 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, my SQL, Postgrade SQL.
Now, I have used all these different types of SQL in my actual job.If you don't you haven't done that and you're just starting out maybe you put something like um you know sub queries store procedures joins whatever the actual things within SQL I don't really think I don't recommend that asmuch 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 packagessomething like R there are packages and libraries within them so you can specify I 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, where you have like Python and the libraries underneath it.I've even seen it to where people will write out almost like um, 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 use to um, manipulate data and I'm not spelling that right in pandas dot dot dot and they write it out.You can do that as well.Again, I like bullet points because it's to the point.That'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 skills 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 lie 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 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 youactually 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.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 mapplot lib.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 skills 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 in this other than that this is exactly how I would have it very very very similar to my own um and a lotof this that I did I actually took from other résumés and formatted it how I prefer and like it um so again some of this 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 healthcare 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 do 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 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'd think, just in a teacher way and not a data analytics way.But you can reward these things and make them sound good.If you are a a nurse, like I was saying, you've 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 a way 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 video 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 one's on Udemy, one's on Corsera, 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 ré 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 skills section.They again this is the project same projects and then work experience.So this is just a little bit different um order.
So you can do it like this as well and different way 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 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 chat GBT 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 chat GBT.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.All right.So, here on my screen, we're on Chad GBT.If you haven't used it, I'll leave a link in the description.I also have a whole video on how to use Chad GBT for a data analysis.Um, so I like Chad GBT.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 teacher, 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 commute 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.And 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.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 sent I said write a two.Write two sentences highlighting my COVID tablet dashboard to add to my resume.And it's going to say developed a COVID tablet 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.that can help you generate the descriptions in your projects.And this can be really helpful to just generate some ideas because 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, see if it has what they're looking for, and then that resume, if it gets through that system, gets passed on toa 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 résumés 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 résumés have different uses, right?You're not just handing it off to somebody to where they can read it and it's needs to be visually stimulating.Really, what you need is you need it to get through those initial systems, which these résumés, 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 video.
What's going on everybody?Welcome back to another video.Today we are going to be solving easy SQL technical interview questions.
Now, when I was interviewing for data analyst positions, I almost always got some type of technical interview.And the vast majority of the technical interviews that I got were in SQL.Not only that, but I was also on a hiring team.And then later as a hiring manager, I almost always conducted some type of SQL technical interview.Now, why do hiring managers conduct these interviews?It's because they want to make sure that you actually know the skill.Because you can just put SQL on your resume and not actually know it at all.And then when they hire you, they have to spend 2, three, four months training you on the basics of SQL for you to actually understand it and use it.That is not what any hiring manager wants.And so that's why they conduct these SQL technical interviews.So in this series, we're going to start with easy questions.
That'll be in today's video.Then we'll go on to medium, hard, and then very hard SQL technical interview questions.So without further ado, let's jump on my screen and take a look at the easy SQL interview questions.We're going to be practicing these questions on analystbuilder.com.And if we come right over here, we can filter to the free questions and we can filter to the easy questions.These are all the free and easy questions that you can go and take right now.I will leave a link in the description.I will also leave a link to the two questions that we're going to be looking at today, but go ahead and check out this if you want to try out all of these different questions.There's also different difficulties.So, we're going to be working through the moderate and the hard ones in future videos.
And then we'll also be looking at the very difficult ones in the very last video in this series.But let's go ahead and get rid of this because we're going to go over to our very first question.Now, really quickly, I just want to show you the interface before we actually dive into the question.Now, we're going to be solving this in my SQL, but you can also practice in Postgra SQL and Microsoft SQL Server.Whichever one you have an interview coming up for, if that company uses Microsoft SQL Server, come in here and use Microsoft SQL Server.And we also have Python as well.But we're going to be doing this in MySQL.This is where we'll write our actual SQL code.Then we have the prompt.Now, in an interview, typically they're going to give you some type of prompt and then the data.
They're going to ask you to do something with the data and our data is right down here.So, this is our data.Now, this is a practicing platform, right?To practice for technical interview questions or practice for technical interviews.So, we also have hints and expected output, as well as a video explanation walking through this question, showing you exactly how to do it.Um, but if you can't get it at all, you can always come in here and look at the solution for any of these.But let's go ahead and start this question.The question is called car failure.It says, "Cars need to be inspected every year in order to pass inspection and be street legal.If a car has any critical issues, it will fail inspection.Or if it has more than three minor issues, it will also fail.Write a query to identify the cars that passed inspection.
Output should include the owner name and vehicle name ordered by the owner name alphabetically.Let's go take a look at this data.So we have the owner name, vehicle name, minor issues, critical issues, and that's all we have.So it's just a simple one.Um, again, this is an easy question at least on Analyst Builder.And so, let's try to solve this without any of the hints or looking at the expected output because I think we can solve this one.Now, the first thing that we need to take into consideration is we're going to need to be filtering.So, we'll need to filter down some data.So, if a car has any critical issues, it'll fail.So, if critical issues is 1 2 3, it's going to fail.So, it can't have uh no critical issues.And then I'll say and because even though this says or right here, it doesn't mean one or the other.
It means if it has this or it has this, it fails.So, we actually need an and here.So, both conditions need to be met or more than three minor issues.So, you can't have either of those.Now, in our output for what we're going to get down here, we need to have just two things.We just need the owner name and vehicle name.So, let's put that owner name and vehicle name.And then lastly, we just have to order by the owner name.And that's going to be ascending ASC.Ascending is just A to Z.So, I think we can go ahead and start writing this out because I think that's all we need to do.Now, let's go ahead and run this.And so, we have our data right down here.Now, here's what we need to do.We are trying to identify cars that passed the inspection.
So, we need to filter out the ones that had a critical issue or that had three or more minor issues.So, what we're going to do is we're going to come right over here, and the first one we'll do is critical issues.So, we're going to say where critical issues and we need to say is equal to zero.And let's run this.And it looks like I had a space here.Let's run this again.There we go.So now these are cars that have no critical issues.So they're p these ones are passing.But if we just look at our data right down here, we have some that have four, four, five.So, we also have to say and and I'm going to copy this so I don't have another uh problem with that.So, I'm going to say where it's less than or equal to and I'm going to say three.
So, if has three or less, it should be in our output.So, let's run this.And I say greater than.Let me do less than.There we go.And we can see that now the minor issues are all three or less.And let's just make sure or if it has more than three.So if it had four or five, it should not be in our output.So this has 3 2 0 222 and this has 0000.So these are cars that should pass.Now right now we've been selecting everything, but what we really need to do is just select the columns that we need.That's going to be owner name and vehicle.So let's run this.And this looks really good.And the last thing that we need to do is order by.So we need to order by the owner name.Let's get that owner name.
And we need to do that in ascending.Now by default when you use order by uh to organize and sort a column, it automatically isn't ascending.But I like to at least put it there, you know, explicitly so I can see it.And this to me should be the correct answer.Now, what we need to do to check our answer and actually show if we got the answer right is just click this check answer button.We can also do control uh shift enter.But I'm going to click the uh check answer.And there we go.We got the solution correct.So, let's go ahead and come up here.We're going to go to our next question.This is another easy question on analyst builder.Again, I'm going to leave a link in the description if you want to try out this exact question.But let's take a look at this one.
This is called apply discount.It says, "A computer store is offering a 25% discount for all new customers over the age of 65 or customers that spend more than $200 on their first purchase.The owner wants to know how many customers received that discount since they started the promotion.Write a query to see how many customers received that discount."Okay.And let's go down and look at the data.So, we have customer ID, we have their age, and then we have their total purchase.And let's just see if there's any duplicates in this customer ID.It doesn't look like it.It looks like they're all just one purchase.The reason I was looking at that is it says all new customers and it looks like these are all new customers.It doesn't look like there's any repeat customers that are old customers.So, we're going to assume these are all new customers.
If there was a multiple 101s, I would look for something like a transaction ID or a transaction date.But those types of questions are a little usually a little bit more difficult um in like the medium hard types of questions.But let's go make some notes real quick.So we have to filter on two different things.They have to meet uh one of these criteria in order to be in the output.They either have to be over the age of 65, so over 65, and let's do over 65, or they just have to meet one of these, or have spent more than 200 or spent more than 200.And that's shouldn't be capitalized.Uh, so that's what we need.And then the owner is just wanting to know how many customers received that discount.So, we're going to do a count on the number of customers uh that fit that filter.
I'll write it like that.So, it's just going to be a number in our output.This one should be uh I would say even a little bit simpler than the last one because we're not having to filter or really um do anything like that.Now, let's run this and let's come down here.So we're going to do a count eventually on this customer ID, but what we need to do is filter on both the age and the total purchase.So let's write this out.So age needs to be and I need to write where where age is greater than 65.Now I'm not saying greater than or equal to because right here it says for new customers over the age of 65.If it said age 65 or over, I would say greater than or equal to.I want to be these questions can be very specific and then we'll say and or actually or because it's either of these need to be true or the total purchase and again it says more than 200.
So we're going to say greater than 200.Now let's run this and let's just kind of look down here.There's a lot of people that fit this bill.It looks like um yeah the majority of people.That's great.So we're going to give them a discount.These are people that received a discount.So all we're going to do is a count on this customer ID.So let's do account on customer ID.Let's run this.And our answer is 14.All we have to do is check this answer to make sure uh it is correct.So let's hit the check answer.And there we go.Your solution is correct.Now one thing I will say about just technical interviews in general is oftentimes they want to make sure you know how to write it.But even more so, they're really checking to make sure you understand how SQL works.
So, when I'm writing this out, if I'm in an actual interview, I would be talking this out loud to the interviewer who's interviewing me.I would say, "Okay, I looks like I need to filter on this and I need to do a count on these things."Now, you only would know how to do that if you know my SQL or if you know SQL, right?Again, they really want to hear your thought process.And so walking through it exactly how I did in the actual interview is exactly what the interviewer wants to hear.Now, writing it correctly is still very important, especially as you get to the more uh difficult questions, right?You want to know certain functions and certain ways to write things, but you should be talking all this out loud during your interview.Now, one other really cool thing, I'm just going to show you this at the end, is if I go over to my profile, I'm actually earning points for these questions.
So right down here, I just earned a couple extra points towards my my SQL badge.And I can go all the way up to expert and then master as well.And so I am well on my way.And then in future videos when we do the medium and the hard and then the very hard questions, we earn even more points for those cuz they are more difficult and they go towards these badges.So that is how we solve those easy SQL technical interview questions on Analyst Builder.Go ahead and try those out.There's tons of other free questions on the platform that you can just try out and there's lots of easy ones, but then we're also going to be taking a look at medium, hard, and very hard in future lessons.With that being said, I hope you enjoyed this video.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 solving Medium SQL technical interview questions.
Now, if you watched the first video in this series, you saw that we answered some easy SQL technical interview questions.Now, we're going to be solving medium level questions.The medium questions are going to be a little bit more difficult, but I will say that if you are practicing for a SQL technical interview, I highly recommend practicing the easy and the medium questions.But let's not waste any time.Let's head over my screen and take a look at our medium level questions.But actually before we take a look at our two questions up here, you can come over here, go to the free questions, go to the difficulty, and go to moderate.And these are all the medium level questions that you can try for free on analystbuilder.com.If you've not tried out analyst builder, I highly, highly, highly recommend it.That is my data analytics learning platform that I'm extremely proud of.
You can take my full courses and try out these technical interview questions all in one place.But let's head over to our first question which is called tech layoffs.It says tech companies have been laying off employees after a large surge of hires in the past few years.Write a query to determine the percentage of employees that were laid off from each company.Output should include the company and the percentage to two decimal places of laid-off employees.Order by company name alphabetically.Uh and I think this is extremely accurate because uh that just happened.Uh, I'm recording this in late late late late 2023.Um, but I'm sure I'll release this in 2024 and I think you guys know what I'm talking about.Uh, it was just a bad year for 2022 2023 with all the layoffs.Now, we have Apple, Microsoft, Google, Amazon, Facebook, Tesla, and these are the employees fired.
And what we're trying to do is output a percentage.So, we need to look at the company and then percentage of laid-off employees.So, if they had zero laid-off employees, the percentage should be zero.But let's say they had 6,000 of 181,000.We need to see what percentage of the entire company size was laid off.Was it 1% 2%?Um, that's what we're trying to determine.Now, we always can use hints and expected output.if we need help or if we need the video walkthrough, we can use it, but I don't think we'll need it.Let's come over here and make some notes before we get started.Now, before we write anything, remember when you're in a technical interview, whether it's for data analysis, data engineering, data science, it doesn't matter.When you are applying for these jobs, writing it out correctly is important.But I would say even more importantly, it's about how you actually talk through the problem because that really shows your skill level.
If you're walking through it and you're just typing random stuff and it kind of makes sense, but you're not talking out loud, they may not understand that you really know what you're talking about.And so, you want to practice these questions, know what you're talking about, and while you're solving them, do what I'm about to do, which is I'm going to kind of talk through the steps that I need to do,then I'm going to write it out.That's what I recommend during actual interviews.So, the first thing that we need is we need to find the percentage.Now, this is going to be a calculation.So I'll write percentage calculation.Now how do we determine what the percentage is?What we need to do is employees fired divided by the company size times 100.So it's employees fired divided by comp size times 100.
That's the calculation that we need.So we are going to go and do that in just a little bit.But after that our output needs something.So, our output needs and I need to comment this out.Our output needs the company name and it needs the percentage.So, we're definitely going to need to include both of those.And then lastly, we need to order by the company name as C, which means ascending.So, A to Z.So, this is what we need to do.Now, let's do one thing first.Let's just pull this up.But we don't really need to start looking at the output or the order by just yet.Let's keep everything.We'll keep this uh comma here.Let's keep everything, but let's start working on our calculation.So, let's see if our calculation is correct.It should be employees fired divided by the company size.
I'm going to put this all in parenthesis um just to make sure we're doing PEMDOS correctly.and let's multiply it times 100.So, let's run this.And here we go.Now, this looks correct just glancing at this because here we have 0%.Because Apple didn't lay anyone off.Uh 3% 6,000 of,800.That also looks correct.This one, I think, is the most um straightforward one.15,000 into 140,000.That should be around 10%.But because it's 11uh 15,000 to 140,000, it's a little more than 10%.And so this one looks very right to me.Now, one thing I didn't say mention here is we need to round to two decimal places.So let's go ahead and round this before anything.So let's put round and let's wrap this entire thing.Now we need to round this to two decimal places.So we need to do is do a comma two here because that says round to two decimal places.
So let's run this.And there we go.That all looks correct.Now we can say this as let's just rename this as percentage just so we don't have that really long name.Uh it basically makes this the column name that's way too long.So we're going to call that percentage.Now the only thing that we need in our output is company name and percentage.So let's come back here and let's put company and let's run this.And this looks good except we need to order by the company name ascending.So we'll say uh order by we'll do company and then we can say ascending although by default order by is in ascending.We just I like explicitly writing it.So let's run this.And there we have Amazon, Apple, Facebook, Google, uh, Microsoft Tesla.So, this looks great.I think this is our final answer.
Let's go ahead and check our solution.And there we go.We got the solution correct.Now, if you remember in the last video, we checked our profile.We earn points towards our badges.A medium question, you earned 25 points.Um, and so if you're following along, you're doing these questions, then you should go check uh your profile out because you should have uh in your profile, you should have more points.Now, let's go to the next question.This one is called separation.It says, "Data was input incorrectly into a database.The ID was combined with the first name.Write a query to separate the ID and first name into two separate columns.Each ID is five characters long."All right.I've seen this in real databases uh a million times.Usually when we're like getting data from like an Excel file or something, we always have issues with Excel file or CSV files or stuff like that.
So let's talk about how we are going to actually solve this.Now we're doing this in my SQL but again you can do this in Python, Postgra SQL, Microsoft SQL Server, whichever one you are practicing or or you know you have an interview coming up.Whichever one you have an interview coming up go ahead and use that one.Now, I think one of the main things that I'm interested in right here is that each ID is five characters long.Um, because we need to separate this out.So, it doesn't matter how long this name is.What matters, it's kind of kind of the key to this is how long this ID is.Cuz if it was 3 4 5 6, we might have to use something like regular expression to separate that out to extract all the numbers.But luckily, it's all five characters.So, with this um we should be able to use something like substring.
This will be to pull out numbers and then names.So that's what we need.Uh and then we'll have two separate columns.So the output will then be the ID and the first name.And I believe that's all we need to do is separate them out into two separate columns.And then uh we needed to figure out how to actually separate it.So I think that's all we need.Let's pull this up.There we go.Now I'm going to keep everything.So just keeping this column, but then we'll separate it out into two and we'll see what this looks like.Now this substring is going to take a few different parameters.First we need to pass through the string.Now when I say string, I mean the column that contains the string cuz it's going to go through each row of that data.We need to select the ID and then we need to specify the start position and the end position.
Now that's where this comes into place.uh where that five characters long comes into place.So because it's five characters long, we should start at position one and then we'll do a comma and end at position five.So start at position one and take through position five.Let's just run this and see if it works.There we go.So this pulled out just the first five characters in this string.Now we also need to pull out the full first name.And we can actually label this.Um let me bring this down.We'll do as um let's name it something.I'll say new ID.That's what we'll name it.And then we'll do the next one.So this will be substring.Now we also are going to pass through the ID.But this time we're not starting at position one.Now we need to start at position six.
But we don't know how many characters are in each name.It could be S.It could be Harry.It could be uh Escariat.I don't even know if that's a name, but it could be really long.Um Alexander.That's my name, a long name.So, we don't know how long it could be.So, we could put something like 20 here.And if we run this, it's going to extract it.But what if someone's name is longer than 20 characters?That's not good.Luckily though, that uh third parameter, the end position, we can just leave blank and it'll go from the sixth position to the very end of that string.So, let's run this.And that looks really good.So we're going to say as first name.And there we go.So let's run this again.So we have the new ID and we have the first name.
We can get rid of this initial one that has everything.And I believe this should be our full output.Now we have this new ID and we have this first name.Let's go ahead and check our answer.And there we go.Your solution is correct.Now these are just two of the medium questions on the platform.There are a ton of others.So, I'm going to leave links in the description to these questions as well as just to the questions page.So, you can go on there and you can practice and you can really get comfortable writing these out and using them because when you feel comfortable going into that SQL technical interview, you're going to do a lot betterand you'll know how to talk through these things.And if you're ever having trouble with them, you can always go to this video explanation where I will walk through it and tell you my exact thought process on how I solve these questions.
And honestly, I think that's one of the best features about the whole platform because when I was first starting out, I didn't have this.And so, I'm really happy that this is here for you.So, you can really learn.It's really just a learning platform to get better at these skills.So, if you have a technical interview coming up either in Python or SQL, try out analystbuilder.com.It is phenomenal.I created all the content myself.We also have full courses on there, so you can go ahead and check that out as well.In the next video, we're going to be going on to the hard questions.And it's going to be quite a big leap from medium to hard.And then after that, we're also going to be going into very hard questions.I would say the very hard questions are more of like a challenge.
They're very difficult.They're a lot of fun.But go ahead and check all that out on Analyst Builder.With that being said, if you like this video, be sure to like and subscribe, and I will see you in the next video.
What's going on everybody?Welcome back to another video.Today we are going to be solving hard SQL technical interview questions.
These hard interview questions are something that you would get in kind of a medium or a senior level data analyst position.The easy and the medium are more towards the entry level or slashmid level somewhere in that range.The hard ones are not something that you're going to get in the kind of more entry level range.These are questions that you might see in kind of a more advanced SQL technical interview.I've been on the interview side where I've interviewed for a ton of data analyst positions.I was also a hiring manager and then even before that I was on a hiring team where we conducted a ton of SQL technical interviews.And so the questions that we're going to look at today are very very similar to ones that I have seen in the real world or even given myself to interviewees.With that being said, let's jump on my screen and take a look.
All right, so we're here on analystbuilder.com.We're going to go over here to the questions tab.We're going to filter to the free ones and then we'll go to the hard ones.Now, there are a lot more hard ones here on Analyst Builder, but under the free tab, uh we only have three.Looks like I didn't uh get this one right, but we have that one today.So, we'll see if I get this one right today.You can go try out these questions completely for free, and we're going to be taking a look at temperature fluctuations and Kelly's Third Purchase.And then there's another one called Cake Vers Pie, which I think may be the hardest of these three.So, you might want to go ahead and try to take that one and see if you can get it.Now, this is Kelly's third purchase.
We'll start with that one and then we'll do temperature fluctuations.Uh, we'll see how quickly I can do these two because these are hard, but I think we can do it.So, let's look at Kelly's third purchase.It says, "At Kelly's Ice Cream Shop, Kelly gives a 33% discount on each customer's third purchase.Write a query to select the third transaction for each customer that received that discount.Output the customer ID, transaction ID, amount, and the amount after the discount as discounted amount.Order the output on customer ID in ascending order.Note transaction IDs occur sequentially.The lowest transaction ID is the earliest ID.Now, that's really important.We'll have to remember that.Now before we jump in anything, let's um let's go look at the data, but then let's start making some notes.So we have a customer ID, we have the transaction ID, and the amount that they spent.
Now, this is the amount that eventually we'll need to use to calculate the end uh uh amount that they paid with the discount.So they get 33% off whatever this number is on their third purchase if that if you're tracking that.So, what we need to do, and let's start making some notes.One, we're going to need to apply a discount.So, that's going to be 33%.We have to identify though the person's third purchase.So, when they come in three times on that third purchase, they then get to get that discount.So, how can we do that?Well, I I'm almost certain just looking at this data because we have 101 for a customer ID.1001 1001 what we can do is we need to order this transaction ID and then give it some type of rank now because each transaction ID should be unique and we'll double check that but it should be unique
we should just be able to use row number but we could also use rank or dense rank um but they should give the exact out same output for each of them it shouldn't matter so I think using justrow number um and then filter ing when it equals three.So, we're going to apply a row number based off the customer ID and the transaction ID.And then for each customer, we'll give it a row number.And then when it's three, which is the third transaction, that's the one we give the discount to.Um, in our output, let's look at what our output is going to be.Our output is going to be, let's take a look.Select the third transaction.Output customer ID, transaction ID, amount.So all columns, all columns with uh and I'll just copy this discounted amount.So really everything with just that new column.
And then we need to order by the customer ID.So we got a lot to do.Uh this this definitely doesn't look like of course is a difficult question.is a hard one but it doesn't look like a super straightforward one.So the first thing that we need to do is we have to identify this row number because we cannot apply the discount until we know which data to apply it to the output in the order by will comeat the very end.So let's look at this.Let's do um let's do a comma here.We'll come down here.Let's do row number.Now this is a window function.It's it, you know, if you haven't used these before or you haven't taken like my full course and and you know, worked through these things, row number uh is a window function that's going to apply to a window
or kind of like a group by is is what I compare it to.When you group by, all of those customer IDs with 101 are going to be grouped into one row.With uh a window function, they aren't going to be grouped into one row.they'll just be in a window where you'll see each row individually and you can apply something to each row instead of grouping it and aggregating the data.So, it's really unique um and really useful.So, we're going to do row number and what we need to do this is over the transaction ID and we need to order by order by transaction ID and that's going to be ascending.So, the earliest one it says lowest transaction ID is the earliest.So, we need to start with the earliest, then go to the highest and pick the third one.So, let's just run this.
And I need to do this over.I said row number.I didn't write that right at all.So, we'll do over and then we write it.So, we're doing we're applying this row number.The over is the keyword that we use to specify that this is what we are doing it on.And so now we have this.And we can't just do this because it's applying the row number appropriately based off of only the transaction IDs from from lowest to highest.Here's the thing though.We have to do it per each customer.So it's each customer's third.So we have to use partition by before the order by.Now partition by is going to separate it out by the customer ID.It's kind of that's kind of like the grouping part.Um, and so we'll use partition by customer ID.And why did I copy that?
By customer ID.And now let's run this.And now when we come down, it should say 1001 101.And notice that we have this um row number applying at the customer ID level.And then when it gets to the last customer ID and it goes to the next one, it restarts.So now this is that third person's transaction 1001 and then at 10002 this is the third transaction.Now here's the tricky part about trying to then use this row number is I cannot come down here and say where and let's label this.We'll say as row_num.Let's run that.Uh whoops because I have this as blank.Let's comment that out real quick.So I have this row num but I cannot say where row num is equal to three.Let's try it.So it's going to say unknown column.It doesn't understand that that's a column.
And you may be thinking well you know in aggregations with group by you can use the having statement.Well let's try the having.And let's run this.It says the window function is allowed only in the select list and order by clause.We cannot use in the having.So what we need to do is we need to actually make this as uh its own little output is what I'll say.Now we can do that in two different ways.We can use a CTE and we can use common table expression to kind of store this data down here how it is and then we can query off it later or we can put it in a subquery.Or if you know we wanted to get really advanced and we're using um actual MySQL database, we could use something like a temporary table or a view or something.
We could do other things, but for here let's wrap all of this in a um let me come right here.Let's wrap all this in a subquery.And when you have uh a subquery in a from statement, you have to label it.So you have to give it a name.So we're just going to call as row numbers.And let's select everything.And what this is doing is we're selecting everything from this data right down here.This table that we've essentially created.So what we're going to do is we're going to select everything.Now what we need to do is we need to say where row num is equal to three.And let's run this.So now we have each person's row num three.This is the third person's transaction.Now this is really good.So what we need to do next is we need to then calculate this amount.
So it gets a 33% discount now.So let's select the columns that we actually want in our output.We need customer ID.We need transaction ID.We need the amount.Now we need to calculate the discounted amount.Remember we have to label this last one.Um we'll say as discounted amount.So this next column is going to be this calculation.Now we have to give a 33% discount.So we can't say amount times let me bring this down like this.We cannot say amount times 0.33.Let's run this and let me see.I just spelled transaction ID wrong.Transaction ID.That's it.Always gets me.Um, this is actually a This is 33% of this number.That's what this is.Now, 33% of this number is not a 33% discount.We're giving them a 67% discount.What we want is 67% of the amount.Let's run this.
This right here is 33% off the total amount.It's a discount.So instead of paying $94, this person only had to pay 62.98.Now the last thing we need to do, the very last thing is order by customer ID.And it looks like it already is, but I'm going to do it anyways.We'll do order by customer ID ascending.And let's run this.This should be our final output.And you know, it took a little bit of work to get there.We had to use this subquery, but I'm pretty sure this is right.Let's go ahead and check this answer.And there we go.Our solution is correct.Now, remember, there's other ways to write this.There isn't just one way.Um, this is kind of the difficult part about hard interviews or like senior level data analyst interviews for for SQL um technical interviews.
The difficult thing is there's not only one way to answer it.And so it starts getting down to okay, what's the best way to solve it?Walk through your thought process.So everything that I just did where I walked through and I said, okay, I could use any of these, but row number makes the most sense for this data, understanding the difference between those and why I'm choosing oneover the other um is really helpful for the interviewer to understand and gauge kind of your skill level.That's why I recommend you write it out well, but also talk about it.The thought process is kind of the most important part.Now, if you tried this question, you could not get it or you couldn't solve it, you can always get a hint, um, you can take a look at the expected output or you can go up to the video
explanation where I walk through this entire question or just go look at the solution and let's see if I wrote it the same way.Well, I called it Rn for row number, but this is essentially the same although I wrote out the column names.It's essentially the same, but you could have done a CTE uh with this as well.But that is how you would solve this Kelly's third purchase.I will leave a link in the description if you want to try that one out.Now, let's go up here.Let's go to temperature fluctuations.So, this question says, write a query to find all dates with higher temperatures compared to the previous dates.Yesterday, order dates in ascending order.Okay, let's look at the data.So, we have our date over here and the temperature.So, it looks like for example this one, this is the 2nd of January.
This temperature was 70.The previous days was 65.So, we want to identify this date.And I think it's just the date um to find all the dates with higher temperatures.It looks like our output is just going to be the dates.And I'll write that real quick.Um output just date column.Now, how are we going to do this?How are we going to compare this?Uh initially, there are two things that I think we could do.One, we could use a window function.We could use a lag uh a lag function on this which would look at the previous rows data.So if we ordered on the date which it already looks like it's ordered, we can use the lag function to look at the previous value.So here is 70.Then we use the lag function.It would pull over 65 over here.
That would perfectly fine uh way to do it.The other way we could do it is we could do a self join.So we could tie the table to itself, but instead of doing it where the date is equal to the date, we say the date minus one.That's another way that we could solve this.So you can go ahead and try whichever way you would like to.I think I prefer the self join.Um I just think the last one we did uh a row number which is a window function.So I don't want to do another window function, right?Although you could solve this with a window function.Um I'm going to try a self join.So let's pull this over.Um, I think I'm going to do a self join but on the previous day where there's a one day difference.So where the day is one day off is what I'll say.
Um, then we can use that to compare.So use the temperatures to say where one is higher than the other.And that should make more sense uh in just a second when we start writing it out.But now we also need to order by dates ascending.That's it.So we have our data down here.And in order to do a self join, we're just going to say um I'm going to say inner join, but we can do if there's a different type of join you want to do, you can also do that.But I'm going to say on temperatures and we need to label these differently.So we'll do T1 for temperatures one and then T2.So now it's like we have this table over here which is temperatures.We have this table over here that's temperatures.And we're going to join them together.Now what are we going to Oh, let's do T2.
Now what are we joining these together on?Um we're going to be joining this on the dates.Now there's a few different ways that we can write this, but there is a function called date diff where we can take one date and compare it to a different date and make sure it's one day different.So, let's go ahead and take a look at that.Let's do um a join on and we'll do date diff and then we'll do t1.And it's autopop populating it for us.But date diff, t2 dot and then we'll say date right there.And it should be a one day difference.Let's try this.Let's run this.And the reason why it's not pulling up is because we have all the same uh column names.Now, when it has the same column name, it's just showing up as just one.One is overlaying the other.
So, what we're going to do is T1.ATE, T1.
And let's get rid of that.Then, we're going to label these other ones different.So, we'll do T2.as date 2 and then we'll copy this and we'll do t2 temperature as temperature 2.Now let's run this and let's see what happens.So we have uh this date compared to the previous date this date compared to the previous date.So 3 versus 2 and let's keep going.4 3 5 4 6 to 5.And so every single date has the previous date.Now what we can do is we can compare this temperature to this temperature.Now we can do that in a wear statement or we could just do it in the join.We can make it a conditional uh part of the condition in the join.Maybe I'll write out both.But let's say and we'll do T1 dot uh T1.
Is greater than T2.So let's run this.So now we have 70 compared to 65.And it looks like the other one wasn't as high.So the third day is gone.58 compared to 55.90 compared to 58.82 compared to 70.88 compared to 82.These are all of our dates right here in this column that this temperature was higher than the previous day's temperature.And so what we should be able to do is just get rid of all these columns and just take the date.And let's run this.And there we go.And all we have to do now is order by.And I think it's already correct, but I'm just going to I always like to write it out if it's asking us to do it.take do this in ascending and so let's run this.Yeah, in ascending order.I didn't write that.
Oh yeah, here I did.I wrote it right here.So now this looks correct to me.Let's go ahead and check our answer.And there we go.Our solution is correct.Now again, there's multiple different ways to solve this.Genuinely off the top of my head, I could think of two, probably another one, another third option.Um, just off the top of my head, because I've been using my SQL for a while, walking through that in your interview, saying, "I think I could do it in this way or this way, but here's why I'mchoosing this way."That really tells an interviewer, "This guy knows what he's talking about."Or, "Girl, this person knows what they're talking about.They understand it.They get it.I can trust that this person will know how to do the work that we're going to give them if we hire them."
You want to give them a lot of confidence.That's all I'm going to say.Now, if you don't know how to do this or you've never done something like this before, that's what this platform is for.Um, so that when you get into those interviews or you know you want to learn and go take a course, when you get into those interviews, you can confidently say, I know this skill.Uh, and so if you had trouble with that one, you can always go to hints.You can always go to the expected output video solution solution.Um, let's see how I solved it here.Oh, I solved it the exact same, but I could I could have solved it a different way.I think the lag function would have done just as well.Uh it may have been simpler actually.So this is the one that I used, but honestly the lag function in a window function may even be better.
So we solved this Kelly's third purchase.We solved this temperature fluctuations.I will leave links in the description for both of those.Go ahead and try those out yourself.And again, even back in the question section, there's this cake versus pie, uh, which is probably the most difficult of the hard ones, uh, under the free tier.Now, if you go back under the, you know, there's a, uh, where you can pay for a subscription under those, there's like 20 hard questions, and they're all very unique, very different, focusing on data cleaning, window functions, uh,different types of joins, and they're all really unique uh, and fun to do.But this cake versus pie one is really interesting.I want um I want you guys to go try this one.I'll leave this one in the description as well.This really interesting, difficult question.So, those were our two hard SQL interview questions.
Uh they were pretty challenging.You know, window function and then self join.Two things that are a little bit more complex than you'll see in easy and medium questions.Uh in the next lesson, we'll be solving a very hard question.So, if you have not check out analyst builder.com, it's one of the best platform for data analysts.I created all the content on there, all the courses, all the questions, and we have so much more coming to the platform.If you like this video, 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 solving a very hard SQL technical interview question.
Now, if you've been following along with the entire series, we had videos on easy, medium, and hard SQL technical interview questions, and we solved two questions in each of those videos.But we are on to the very hard questions.These very hard questions are in fact very difficult.So, I'm only going to be doing one, although there's multiple on the platform that you can try, but I'm just going to be doing one because it's going to take a long time to solve it.Now, practicing these questions is meant to help you learn as well as feel comfortable and get ready for these technical interviews that you're going to get as a data analyst.The easy and medium questions are more geared toward entrylevel beginners or maybe even mid-level for the medium questions.The hard questions are geared more toward mid-level or senior level data analysts.
And then there's the very hard.I don't think that you're going to get a technical interview this difficult.I know I haven't, nor have I ever given one, even though I've given tons of technical interviews before.Um, I've never gotten a question this hard.These are more of a challenge.Really a challenge of can you figure this out?Uh, because it's pretty difficult.So, I hope that you find this really interesting.I want you to try it out.But with that being said, let's jump onto my screen.All right.So, we're here on Analyst Builder.Let's go over to the questions page.Let's filter down to very hard.Now, I will note these are not under the free tier.If you go to the free, the very very hard ones are not under the free tier.So, if you want to try these, these are the very hard ones.
We have consecutive visits, Twitter addiction, employee hierarchy, biggest spenders, complex address, Uber cancellation rates.Now, today we're going to be trying this complex address.But if you want to try out any of these other ones, head over to analybuilder.com.They are super super fun.But let's try out this complex address question.It says, "You are given a database containing customer addresses.Write a query to break out the address column into separate columns for street, city, state, and postal code.Note, some addresses may have additional unit or suite information.For example, sweet 5A or unit B, which should not be included as part of the street.So, let's go down here.Let's look at the addresses.We have 123 Main Street, sweet 5A.So, that's for example, that sweet 5A should not be included, it says.Then we have New York.That's the city.Uh, I'm guessing that's New York City.
Then it's New York.Uh, then 1 2 3 4 5.Then the same thing.Minneapolis is the city.Then we have the state.And we have the zip code.I think that's all we need to Yeah, the postal code.So, let's start making some notes here.So, we have to the output needs to be uh street and I should just copy this street all the way down to postal code.There we go.So that's what our output needs to be.There's nothing on ordering.Uh I think the most difficult part is going to be just breaking it out.So breaking everything out.Now how are we going to do this?There's um one main way that I would be doing this and this is using substring.Now I've done this a thousand times in my real job.This is an extremely realistic thing.Happens all the time.
data comes in just like this or sometimes separated by commas or just spaces and you have to figure that out, right?So, this is interesting because this is separated by no it's just a space.These are separated by these dashes.Um, and then we can't include this 5A.So, I'm going to use substring and we'll see if this works.Um, but with this we can choose our delimiter and that's really important.So we can say whether it's a space, whether it's a a dash or something like that.But we also have to note I'll just write note right here.Can't include things like sweet or unit.So we have to remove that somehow.Um let's go ahead and pull up the data over here and let's take a look.And I wanted to do this in my SQL.Now you can do this in Python.
You can do this in Microsoft SQL.I had started out writing this in postgra SQL which uh the syntax is actually a little bit potentially maybe a little bit different actually it's different in Microsoft SQL server I believe postgrace SQL the substring is the samedon't quote me on that but we're going to be using my SQL because I've been using that throughout the entire series but if you want to you can use Python my SQL Postgra SQL Microsoft SQL Server whichever oneyou feel comfortable using now let's run this so I'm going to keep everything here, but I'm going to add to it so we can confirm that the it's accurate.Like our output is correct.So that's why I'm going to keep the everything there.Now, we're going to use this substring.And the first one that we have to figure out is um this one right here.
Now, it should be fairly easy with something like one that does not include sweet 5A.And for example, we would just do substring and we have to pass through some parameters.The first one that we need to pass through is just the string.Now this entire string is kept in address.So when I say we're passing through the string, we're passing through a column where it has multiple rows with strings in it.That's all that's all I'm saying.The next parameter is our delimiter.A delimter is something that how are we separating this out from itself?So I'm going to put in quotes I'm going to put a dash.And then the next parameter is where are we starting?So are we looking at the first delimiter, the second delimiter, the third, fourth, fifth?Because this one has multiple delimiters.This one has one right here and it has one over here.
So if I put a one here, um, we get null.And that's because I wrote substring.We actually need substring_index.
Uh, I'm thinking of Python.In Python, I'd be using substring.In my SQL, I need substring index.There we go.So, now we're doing this on the first delimter right here.But if I change this to two, now we're looking at this delimiter.So, that's the first delimiter.Second delimiter.So, we only want the first delimiter.But here's the issue with this.We have And there's a unit right here.So we have one that has unit and we have one that's sweet 5A.Here's what we need to do.We have to get rid of it if it has a sweet 5A or if it has unit B.So we'll need a case statement for this.Um what we'll write is we'll write case and this will be our else.So if it has auite in it or it has a unit in it, we will use the substring index on it.
But if it doesn't, we're just going to treat it as normal.This is like our normal one.So, I'm going to say, and we'll do it right here.I'll have to format this in a little bit, but we'll say when when the address is like, and now we're looking for a pattern.We're going to search does this pattern exist in this?Now, uh, it's possible in some instances if you're using like a million rows of data, suite could be in like one two three Sweet Street.I've never seen that before.Um, I don't think we need to take that into account today, but that might be something to consider in a in a real world example, but this is a real world example, but we're just going to include sweet.And I'm going to include and I'm going to use these um these wild cards.
So this means anything can come before this, anything can come after this.It just has to have a space suite.Now you don't have to add the that you could do it just like that.It makes more sense to me because we actually need to remove that in the future.And I'll explain that in a little bit.But when that happens, when there is a suite in there, what do we want to do?Well, we need to use substring index on it.But we cannot use the dash.The dash has got us in trouble last time.It kept the sweet 5A in there.What we need to do is we need to use this suite as our delimiter.So then when it gets to that delimiter, it's not included, right?So then we come over here, we put the suite in there.Let's run it.
And I got a syntax error.And that's because we need an end.And we need and we can label it as well.But this will be our street.Uh we have to have an end to signify that the case is done.I'm pretty sure that's the issue.There we go.And that fixed it.That's because like the delimter with the dash, when it got to the dash, it took everything before it.So now if we find a suite, we're using that space suite as the delimiter.Now, if we put this as the delimiter, you may not be able to see it, but there should be a space right here, and that might cause dirty data.I'm going to actually I'm going to keep it like that.We'll see if my hypothesis uh is correct.Now, we're going to do the exact same thing except now we're looking for which one was it?
Unit.So, if it includes sweet 5 A or unit B, those are the examples.We need to get rid of that and we'll use unit.And let's run it.And there we go.So, this looks perfect.This looks exactly like what we should be getting in our output.So now uh Whoops.Now we need to come here down to the street.So now we have the street, but we need to get next we need the city.So the city is right after the street.But here's the thing.It's in the middle.And if you've ever worked with data like this, it's a little bit tricky because uh a delimiter only goes to one point, right?So what we can do is use a double uh substring index.So we're collecting the substring index and then uh within that text of that substring index we do another substring index.
So I think that's what we need to do here.So let's come down here and we can just copy this because it's already written up for us.Um and let's run this.Now what if we say two here?Let's run this.Um we can do it this way and then go backward we can do a minus.So in substring index instead of a positive one looking forward that's starting from um the left hand side of the string and looking this way for the first one we can do negative which starts from the right handside and looks this way.So left to right when it's positive right to left when it's negative.So then we can wrap this as a substring index.And now this whole thing right here is our string, which is this.This is our string.So now we're going to look backward.
We're going to do minus one.Um, actually our our delimiter first is a dash because we're looking to this dash.And then we need to go to negative one.And let's try this out.And there we go.New York, Minneapolis, Goldsboro, Maples, Flower Town.So this looks perfect.So, let's keep that exactly how we have it.Now, for the next one that we need, uh, and I'm going to label this as city.Now, we're going to copy this whole thing, bring it right down here.We'll do this as state.Now, obviously, this isn't going to be our answer, but we can run it.So, here's what we need to do.Before we took this whole string and we got here and then we went backward to this delimiter and selected New York.What we now need to do is we need to go we need to select this New York Minneapolis.
Now there's a space here and so what we should do is we should go backward to this index right there.I think we need to do that first.So we'll use that as our our starting place.And so we'll do negative one.Um, yeah.So I'll just do it.So we'll go negative one, but then we need to go forward.So this is going to be our string right here.New York 1 2 3 0 5.So then we need to go forward.And our delimiter should be a space.Let's do a space right here.Let's run this.And there we go.We have New York, Minneapolis, North Carolina, Massachusetts, I think, and Florida.So that's our state.And we have one more, and that's going to be our very last one.Now, this one should actually be a little bit simpler because we're just starting at the very end.
It's not in the middle, which is a little bit tricky, right?So, we're going to come in here.We're going to say as, and this is postal code.I really want to stick to exactly what they told us to call them.I don't want to go changing it.So, now we're looking for a space delimiter, but we're looking backward negative 1.So, we're starting from the right hand side and going to the first space.And that should give us that 1 2 3 4 5.Let's run this.And there we go.Now I'm going to get rid of everything.And let me actually come up here.I'm going to get rid of everything.And let's run this.So now we have the street, city, state, and postal code.This all looks correct.I don't know.I genuinely don't know if I check this answer if it's going to be correct or not.
My hypothesis, what I think is going to happen is is is not going to be correct because I think somewhere in our output, we have some spaces that we can't see.For example, this suite, if we're using just the suite and not the space suite, I think we have an extra space at the end of this one right here.So, it goes sweet space, which I don't think is correct.And it shouldn't you shouldn't have that in actual output in a real database.You don't want uh uh leading or trailing spaces.That's dirty data.So, let's try checking it.And there we go.Our answer is wrong.Let's try just fixing this and seeing if that's it.If not, it could also be one of these.But let's try this one now.Uh there we go.So, that is that was the exact issue.And it's really hard to catch.
If you're not looking for it, you may not catch it because it is a little bit tricky.Um, but that is I let me see if I added this in as a hint.Maybe I did, maybe I didn't.But that is something that you need to account for in real data.So, um, I know that there were people in the Discord, if you haven't joined Analyst Builder and tried out these questions, um, we have a we have a Discord with like 2,000 people in it.And this question when people have been trying to solve it, have been really having issues with this exact thing.Is I it looks correct, but it's not correct.um that is a real world solution, a real world issue.And so that is how you solve this question.Now you know I have a whole video explanation on how to do this.
Um as well as you can just come down here.Let's look at the solution.So yeah, this is exactly how I wrote it.Um there are other ways to write this actually.But that is how you can solve it.Now remember, you can come in here even in the in the questions and go to the difficulty and you can take a look.You can check out all these other questions um and see what they look like and what the questions are.These are really tough.U for example, this Uber cancellation rates is a really interesting one.Find the cancellation rates of requests with unbanned users.Both client and driver must not be banned each day between 2023, 1223, and 1225.Round the cancellation rates to two decimal points.So, this is another really interesting question.Um, and there's actually two tables here.I'm not doing this one today, uh, but these are more questions.
I'll do more of these videos in the future just because I really love them.They're super fun.Um, but if you want to try that question out, I will leave a link in the description.You can go ahead and check that out.If you have not tried out Analyst Builder already, I highly recommend it.I created all the content myself.All the questions, all the courses are all done by me.So, if you like my YouTube channel, you will love Analyst Builder.All premium, really high uh quality content.So, go ahead and try that out.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 video.Today we're going to be starting our Azure series.
Now, if you don't know, Azure is a cloud-based platform owned by Microsoft.Azure is one of the biggest cloud platform and has millions of users all around the world.I myself use it for many years and I absolutely love Azure.I think Azure is a fantastic cloud platform and that's why we're going to be starting to learn it.I think knowing a cloud-based platform is an essential skill today for any data analyst, data scientist, data engineer out there.So, that's what this entire series is going to be for.We're going to get our account set up.We'll look at things like account storage, SQL databases, uh even some things like data pipelines.So, using Azure data factory and Azure Synapse Analytics, these resources and tools within Azure are ones you're absolutely going to see.And so these are the ones that we're going to be focusing on in this lesson.
We're just going to be getting everything set up.So we're going to be creating a Microsoft account.We're going to be creating an Azure account.And then we'll be doing a walkthrough of the UI just so you can kind of see it and get familiar with it.So with all that being said, let's jump on my screen and take a look.We're going to start right here on the azure.microsoft.com/freeover here.Now this is going to be a little bit different if you're in a different country, but this is for uh me here in the US.But I'll have this link in the description so that you can come to it.you can create your account and then we'll get into all the uh UI and how everything looks once we actually set up our account.Now, before we actually create it, just go down here.
Here are some of the things that you're going to get when you create your account.You're going to get uh popular services free for 12 months, which is really, really great.Um 55 services that you're always going to be free.And then we're going to get this credit right here.Now, this credit is really important because some of the things that we're going to be looking at in this series are not things that are completely free all the time.So, uh, we're going to be using some of this credit throughout this series.So, you want to make sure you can get that.You just need to create a new account, and that's what we're going to be doing.And then we don't have to use our money.We can use Azure's money, and we will all thank them for that.Let's come over here.We're going to click on start free.
So, we're going to start our free trial.Now, if you already have an account, you can use it.If not, we're going to click on use another account.Now, again, for this, you can sign in with things like GitHub.You can sign in with a previous account.If you do not have an account, I'm just going to show you how to create one really quickly, and that's what we'll use going forward.If you already have an account, if you're already signed in, go ahead and skip a little bit forward, maybe like a minute or so, and we should be done creating this account.But let's go ahead and see how we can do one.We're going to go to create one.We're going to call this uh Alex the analyst atoutlook.com.And there we go.So, we have Outlook or we can do Hotmail.Hotmail feels like it's from like the 90s, so I'm going to do Outlook.
at least feels uh somewhat current.Then we need to create our password.I don't want any tips.So, I'm going to do a password right here.And let's go ahead and click next.You're going to fill in when you were born.And we'll go ahead and click next.And it should be creating our account.Looks like we need to do a little uh puzzle here.Looks like we need to rotate it where it's pointing.And there we go.So, now we're signed into our Microsoft account, but now we need to actually create an Azure account.And those are two separate things.You need two accounts.So, we're going to go through.We're going to fill in all this information.Your name, your phone number, uh your address, and all these different things.Then, we're going to have to fill out uh our card, so a debit card or credit card so that we can actually if we go over the $200 or if we use a service that is not free, then
it is going to charge us.We won't be doing that, thank goodness.But you do need to have a card on file in case you do that.Let's go ahead and fill out all this information.Then, we'll go to the next part.All right.So, we just created our profile.Now, we need to identify our verification by card.One thing I will note in the profile, I did have to verify my phone number.So, they sent me a text.I put in the number and there you go.Next thing we need to do is we need to put in our debit card.So, go ahead and do that.And once we fill that out, you're going to see this right here, which is a little welcome to Microsoft.You can go ahead and look through this if you'd like.I'm just going to get out of it because we don't really need it.
Now, this is going to be the first thing that you see.This is just the homepage of Azure.This is where you can access different services and resources and look at your profile and notifications and all these different things.Now, the first thing that we're going to do is just take a look at some of these resources because there are a lot of resources within Azure.And so, if we come down right here, let's go ahead and click into one of these.This is Azure Synapse Analytics.If we want to uh actually use Azure Synapse Analytics, we need to create a Synapse workspace.then we can start using this resource and start using this application and all we would have to do is create this.So we'd come in here to create synapse workspace.We would start filling out all these things and then we would actually have access to that resource.
And so this one specifically is one that we will be looking at in this series.Uh let's go down and just really quickly take a look at some of these.We're going to be looking at data factory.So creating workflows and data pipelines.We will be using Azure Synapse Analytics.And if we go down to databases, we'll take a look at SQL databases as well as maybe one or two others because knowing how to use databases uh with the resources within Azure is actually quite important.And then if we go down to storage way down here, let's keep going.We go into storage, we will be looking at storage accounts, and that's actually where you can access something like a data lake.And so this can be pretty intimidating just looking at this because there's so many different things.But in this series, we'll really focus in on the things that I think you need to know that you're definitely going to be using as a data professional or especially a data analyst.
But you know, even things like uh let's come back up here.Even things like data factories are used by data engineers, database developers, data scientists, it's everybody.And so knowing how to use these tools uh within Azure extremely important.So that's what we're going to be focusing on in the next several lessons.We'll be getting into specific resources within Azure and how to use them.That is all we're going to take a look at in this lesson because we're just getting set up, creating the accounts, looking at some of kind of the user interface of how Azure actually looks.And in the next several lessons, we'll be diving in, getting hands-on experience with a lot of these tools.Thank you guys so much for watching.I really appreciate it.If you have not checked it out already, I have a full course on AWS and Azure on analystbuilder.com.
Be sure to go check it out.I'll leave a link in the description.If you like this video, be sure to like and subscribe, 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 taking a look at account storage in Azure.
20:57:41 - 20:58:23
Now, account storage is super important within Azure.This is where a lot of companies are going to store a lot of their data.Using account storage in Azure is a super flexible way to store your data.It can store just about anything and you can even upgrade it into a data lakeink.And so, we'll be taking a look at all these things in this lesson just to get you familiar with how to use account storage because you absolutely will be using that within Azure.Without further ado, let's jump on my screen and take a look.So, let's start by taking a look at our resources.Right here in storage, we have our storage accounts.Now, as you can see, there's lots of different options for storage, but by far the one that you're probably going to use the most is storage accounts.Now, we do have right over here, you'll notice data lakeink storage gen 1.
If we click into this and let's say we wanted to create a data lakeink, it says right up here, Azure data lakeink storage gen 1 will be retired on February 29th of 2024.We recommend that you migrate your Azure data lakeink storage gen 1 to Azure data lakeink storage gen 2 and that is located in the storage account.So let's come back here.We're going to go right into storage accounts and let's really quickly set up a storage account.Now this is some helpful information if you've never used a storage account before.It says you can store about 500 terabytes.It has general purpose storage use for object stores.No SQL data store.uh you can define and use queries for message processing and you can also set up file shares.At the very end we have blob storage accounts for hot and cool access tiers.
These are all things that we'll look at uh in this lesson.And so that is just kind of a preview of a lot of the things that we're going to be looking at.So let's go ahead and create our storage account.Now this is a brand new account uh as we set it up in the last lesson.So I'm going to be walking through this with you as if I have a brand new account.Now, you have to have your subscription, which if you're using the free tier, you'll have a free Azure subscription, but we have to have a resource group.Now, we haven't created a resource group.Let's go ahead and create a new one.And we'll just call this one Alex the analyst.And we'll click okay.Next, we need to specify a storage account name.We'll call this one Alex the Analyst storage.
I'm guessing that's unique.Uh the storage account name has to be unique across all of Azure.So if you type in something kind of generic, usually it will already have been taken.So you have to do something pretty specific.Now this part and the next part uh these are pretty important.This region says choose the Azure region that's right for you and your customers.Not all storage account configurations are available in all regions.Now if you're just setting this up for yourself, just to store some data on the cloud or you have a little app that you're creating or something like that, it's very easy.You're just going to select your local region.And for me, that's US East.But what if you have a company or a product or an app that's being used by people all around the world?For example, you have a client-f facing app that they're using and they're going in and they're uh retrieving data from some type of storage account.
Or maybe they're running a query on your website of data that's stored in a storage account.And what's happening is is it's stored locally to you, but they're way over here in uh let's say they're in central India.And so in order to get from central India to the US, it's going to take a lot longer to retrieve that data.And so it could take 5 10 15 20 seconds for it to get to them in India versus if it's just locally in US East.And so you need to know where your customers or where your clients are located who are going to be using this.Now, just for this lesson, we're going to keep it in East US because that's where I am located.Uh but that is something you really need to consider, especially as you get more advanced uh with using Azure.
But, you know, just for the basics, you know, you don't really need to be thinking about that.I just want to walk you through my thought process as we're going through this.Next, we have to specify our performance.This is just going to determine how quickly and how easily you can retrieve your data.We're just going to go with standard, but premium would just allow you to retrieve that data even quicker.Next, we have redundancy.Now, redundancy is important, and it's one of the benefits of the cloud, which is if a server goes out that's storing your data, they're going to have a backup of that data somewhere else.And you can specify where that is going to be located.You can either do it a locally redundant storage, a geo redundant storage, a zone redundant storage, or a geozone redundant storage.And so if your data is super important, it is critical to what your website does, it is critical to your clients, if it was deleted by accident in any way or destroyed in any way, your whole company would
collapse.You're going to choose this one down here.But if it's just some local files that you're uploading for someone to pick up, uh, and it's not that important, you're going to do something like locally redundant storage.And so that that's what we'll choose.Uh, just something to consider though.Now, there are other things you can do in advanced networking, data protection, encryption, tags, and all these different things.But if I'm being honest, 99% of the time, you're never going to use any of these unless you really, really, really know what you're doing or that's your job.you're some type of database administrator creating these storage accounts for people on your team.Most likely, you're never doing that.So, let's go down here.We're going to click create and it's going to say we have our deployment in progress.So, it's going to start creating the resources needed for that storage account.
And then we're going to actually get into the storage account and start using it.And just like that, took about 10 seconds.It says that your deployment is complete.We don't need to go to the resource up here.We're going to go to the resource right here.Now what we're looking at is the user interface for this specific storage account.So we have Alex the analyst storage.If we go back to all services, we come into storage accounts.You can now see that we have one.We don't have to just have that uh boilerplate text and then create.If we want to create another one, we'll come right up here.But we can come into the storage account and we can look at this overview.So this is just some of the information on the location, the subscription, uh the subscription ID, the type of performance, the replication or redundancy, and a few other things as well.
Now, there's a ton of things on this sidebar on this left hand side.We have things like activity log, tags, diagnosis, solve problems, access, data migration, events, storage browser, storage, mover, and all these different options.It's kind of overwhelming, but I know just from experience that you're not going to use almost any of these.In fact, things like monitoring are typically used like something like logs are typically used by it if there's an issue.Most likely, you're not going to be coming in here and taking a look at all these things or creating uh different alerts.You may be working with metrics if you're in the IT department.But again, a lot of this stuff you're not going to be working with specifically.Most of the time, we're going to be here in this storage browser.And this is where the data is actually uploaded, stored, and accessed.
So if you come in here, let's come up here to a blob container.Let's say we want to create a blob container just to store a bunch of data.Maybe it's for a client or an application or whatever.We just want to be able to store that data in the cloud.And this kind of the simplest version of being able to use the storage browser or just storage in general.So what we can do is we can add a container.Now we're going to name this container.We'll call this uh ATA container.There we go.And if we come down here, we do have an advanced tab.You're most likely not going to use it because this is uh deals with encryption.And just this is completely, you know, as a sidebar above and beyond what you probably need to know.But when you start trying to access data later on in different applications, whether it's a SQL database or you're using it in PowerBI or whatever you're using uh this data for, if you have it encrypted, you're going to
have to have a way to unencrypt it within Azure.And so it is an additional level of security, but it makes it a little bit more difficult to access that data later on if it's not super sensitive data.So just something to think about.Let's go ahead and create this.And now we have this ATA container.So we're doing great over here.So we've already created a storage account.We've gone into the storage browser.We've created a container.And these blob containers are amazing.I've used them thousands of times for so many different things.And blob containers are really just used for anything.Anything you need, you can use and you can dump inside of a blob container, whether it's structured, semi-structured, or unstructured data.And so let's see how that actually works.Let's go into this.And we have nothing in here.And we want to upload some data.
So let's come up here to upload.We're going to go and browse for some files.So in here we have a bunch of different files.We have a SQL text file, a PNG which is just an image.Uh a Jupyter notebook file and a CSV.All of these are completely different.None of these are similar almost any way.And so what we're going to do is we're going to select all these.We're going to open these up and we can upload these.But really quickly, let's come in here and take a look at some of these advanced options because this part actually is something that you might use.The really the most important one in here is this access tier.If we hover over it, it's this piece that's kind of important.It says optimize storage costs by placing your data in the appropriate access tier.
And you can come over here and look at all the access tiers if you'd like.But let's take a look at what these access tiers look like and what they actually do.We have four options.We have hot, cool, cold, and archive.Now, this refers to how the data is actually going to be stored in the blob storage.If it is hot, that means that you can just retrieve it anytime you want right away within milliseconds.It's just going to be ready to go and it's going to be there for you.But if you go with an option like cool or cold, it's not going to be there hot and ready just to be able to pick up and use that data.It's going to be sitting in a data store where if you want to retrieve it, you may have to wait a little bit.
And so these options are actually a lot more cost-effective because if you're not using that data actively, you can just plop it in there as a data store where you're not using it for any application or any projectand you have the data stored securely but you don't have to pay a ton of money for it.Whereas if you store it in hot, it's going to cost more money to store that.Lastly is archive.And archive means you most likely won't ever use it.This is a contract that was signed uh six years ago.you need it on file, but most likely you're never going to use this.If you do, you're willing to wait 5 or 10 minutes cuz it's not going to be an emergency to get that data or that file or whatever it is.And so these are the different tiers that you can use.
Now, we'll just use hot because that is the default option.But if you have a use case where it's not important that that data is quickly accessible, you don't need it right away, then these other options are going to be a lot cheaper.So, let's come down here.We're going to go ahead and upload these files.And there we go.Then what we're going to do is we're going to actually upload one more.And this is going to be for a future lesson when we actually access some of this data.We're going to browse for files.And we're going to select CSV file 2.I just made a copy of this.And all we're going to do is we're going to open this up.And for this, we're going to choose uh you can do any of these honestly, but let's put it in archive just to be have the most dramatic effect.
Let's go ahead and upload this.And as you can see here in this access tier, we have hot inferred inferred inferred and then we have archive.And so later on in a future lesson when we try to access some of this data, we're going to try to access both of these and you'll see what actually happens when you have data stored in archive orcool or cold.It's quite similar.We'll see how these are retrieved.Now the next thing I want to take a look at is right over here under settings.Now under settings, you'll see this data lakeink gen 2 upgrade.Let's go ahead and click on this.It says that you can upgrade to a storage account with Azure Data Link Gen 2 capabilities.So, if you need things like data analytics and big data storage, you should consider upgrading to Azure Data Link Gen 2.
Now, we're not diving into data links within Azure.I may do that in a future lesson, but this is where you can access to create a data lakeink.You can upgrade your storage account into a data lakeink.They used to have a completely separate data lakeink gen 1 which is what we just looked at earlier but now this is all located within the storage account.So you just upgrade from this location then you'll have those data lakeink capabilities.So that's just something that I wanted to mention while we're here.Now the last thing that I actually want to look at within the storage account is actually the IM which is the access control.Now, within here, you're going to have complete access to this because if you come over here and view your access, you can see that you're going to have grants full access to manage everything.
And if you come over here, you can read it more.You you have access to everything cuz you created it.But what if we want other people to have access to this?Cuz right now, this is a private account.Nobody else can access this.If you want other people to have access to this, you're just going to go to add.You can add a role assignment or a co-administrator.Let's just say we're going to add a role assignment.You can say this person has the ability to read, but you can't make any changes.So, I'm going to click on this one.Then I'm going to come up here to members.Now, right now, I am the only person in my Azure account.So, if I wanted to add somebody, let's say Bob.If I wanted to add Bob, he'd have to be have an Azure account.
But I would click on Bob and I'd say, okay, I'm going to give Bob this access.I'm going to select him and we're going to give him just the read access.We don't want him to, you know, delete all of our files by accident.He's not the brightest uh bulb of the bunch.So, we're just going to give him that access.Review and assign.And we'll go ahead and add that role assignment.Now, you can see that my access I am an owner, but I'm also a reader.And so, that is how you grant access to storage accounts.You can also create roles, deny assignments, uh create classic administrators, but typically this is done by a database administrator, but it is something that is extremely extremely frustrating about Azure just in general because any single tiny thing youwant to do within Azure, you're going to have to request access.
And so when you're first getting started up at a company, they're going to give you a lot of the base access.They're going to, you know, create your accounts.They're going to give you some access to PowerBI or the data lake or a SQL database.But whenever you want to use anything outside of that, you have to request IM access.And so that's just something I want you to be aware of because if you want access to specific storage accounts, you're saying, "Oh, this team, you know, wants me to work on their data or use something with theirdata, but I don't have access to it."That's because you weren't given access to it.You just have to request it or go to your database administrator, whoever runs that, to ask for permission.And so that's kind of the nuts and bolts of what most people are going to use storage accounts for.
There are things like fileshares, cues, tables.Honestly, I you don't use them that much and so I'm not going to dive into it.These blob containers within storage accounts, the data lake, which uh is an upgradeable option, these are kind of the more important things.And so knowing how to store, where to store, and all these uh different options is very important.And so we'll be coming back to some of this data or putting in new data for different lessons when we actually start accessing data within a storage account.So, I hope that that was helpful.If you have not already, I have a full course on Azure and AWS over on analysts.com.I will leave a link in the description if you want to check it out.If you like this video, be sure to like and subscribe.I will see you in the next video.
What's going on everybody?Welcome back to another video.But today we're going to be taking a look at SQL databases in Azure.
By now I think you all know how much I love SQL.I think it's one of the best skills for any data professional to have.But using it in the cloud is a little bit different than using it on your local computer.So in this lesson we're going to see how you can use a SQL database in Azure.Without further ado, let's jump on my screen and take a look.All right.So the first thing that we're going to do is we're going to come right in here into databases under the resources.Now we have a lot of different options in here and there's a ton of different databases that you can choose from and it kind of depends on what your company does.I'm only going to be showing you the SQL databases but other popular ones are things like using my SQL or Postgrace SQL with flexible servers as well as things like Azure Cosmos DB.
They all have different use cases and they all have different ways uh that they are implemented.But by far the most common or the one that I've used the most in my career is SQL databases.So let's come right in here and what we need to do is we need to create a SQL database and let's click on create SQL database and let's actually create it and then we'll see how we can useit.So what we're going to do is come right down here to subscription.We have to select our resource group which you should have already created.Let's create a database name.Let's call this Alex the analyst DB for database.Now we have to select a server but we haven't created a server.So we need to create a new server.And again I'm going to call this uh we'll do ATA for Alex the analyst.
I'll call this server.It looks like this needs to be lowercase.Let's do ATA server.And then we'll do YT at the end.Have to make it unique.There we go.All right.We're overcoming some hurdles here.Next we have to choose an authentication method.We can use the Microsoft Entra only authentication SQL and the entra authentication or just SQL authentication.Now what that means is is if you come in here and set your uh Microsoft Entra admin you can set it as yourself and that does help if you're already signed into Azure going to be using it withinAzure.This can be very helpful.It's actually kind of the default u method.Let's get out of here.This is the default method.If you come down here though you can also create an admin login and a password.Both of these have their, you know, place and sometimes you need to use both.
Um, and so just choose the one, the authentication method that you want for that server.For us, I think we're just going to stick with the, uh, Entra admin.We can always change that if we want to.So, let's go ahead and we're going to select ourselves here.We're going to select that.And there we go.Let's go ahead and click okay.And that should create our server.And there it goes.And now we need to finish creating our SQL database.So, do you want to use a SQL elastic pool?If you look at this tool tip right here, basically helps you manage your resources, but we're not going to be looking at the elastic pools.For our workload environment, we're just going to choose development.Production is going to be a lot faster because if it's in a production environment, you're going to want better speed, better compute, all these different things.
Development is going to be a little bit slower.We can also choose a cheaper database or a more budget friendly database.So, we don't have to uh choose what it gives us.We can come in here and we can define this.So maybe you want to have a provision tier instead of serverless, which I don't really recommend.Uh serverless is uh quite nice for scalability, but we're just going to keep it at is.But if you want to come in here and change some of this configuration, you're free to do that.Uh just don't, you know, if you don't know what it is, I wouldn't mess with it.Let's come back to the create SQL databases.And then we have our backup storage redundancy.You can either do locally, zone, or geo.We're just going to stick with our local.Let's go ahead to review and create.
It's going to tell us our cost, which is very, very, very low.Um, if you don't even have the free $200 that they're giving you, which will be uh which can be used for this, it's going to cost you like a dollar uh for, you know, what we're going to bedoing or maybe even like 10 cents uh if I'm being honest.Let's go ahead and create this.It's going to take a little bit of time to set up all these servers and all the databases and all those things.And then once it is done, we'll take a look.All right, so our deployment is complete.You can come in here and look at some of the details.We created SQL databases, the server, SQL server, SQL server.And so all these things are ready to go.Let's go ahead and click on go to resource.
And let's exit out of this.All this information is just an overview of our SQL database.Now, we have down here some of the more important things that we're going to be taking a look at.We're not going to be diving into all of them because uh I'm just going to show you the most common way.Now we have configure access connect application and start developing.Now in the real world when people are actually using the SQL databases and when they are getting in here and setting everything up you can do this in a few different ways.One is you can connect to a MySQL database and this is a very common practice where they connect it to a database management system.It could be MySQL Workbench or a ton of others that are out there.And you can do that by configuring it and you're going to get some of that information.
You're going to plug it in and connect it.What we're going to be looking at is not that option, although uh that is something that happens often.I'm going to show you Azure's tool for this and it's going to be open Azure Data Studio.So, we're going to open up Azure Data Studio.We're going to click on this right here.And you're going to need to download the Azure Data Studio.Now, I already have this.So, I'm going to come down here and go to Azure Data Studio.And this should resemble a few different things.It should resemble a little bit of Visual Studio Code and it should resemble something like Microsoft SQL Server.It's kind of a combination of both.You have a search, you have some notebooks that you can use, different projects, an explorer, source control, extensions.It has a ton of stuff.
And so, this was really popular when I was using Azure.Everybody used this.um as well as sometimes we connected to MySQL databases or uh Microsoft SQL Server databases and just use those database management systems but oftent times we would have everything in Azure data studio.So let's come right up here.We are going to connect.Now we have to specify our server name.Let's go back really quickly.We're going to come right over here.We're going to go back to uh this right here.We need to select our server.So this is our server.It's ATA server YYT.Uh we could even come in here into the server and we can just uh copy this if we want to.But we're going to get that.We have our server.We have our Windows authentication type.And so it can either be a SQL login, a Windows authentication, but we chose the Microsoft Entra ID.
Now, right here, it's recognizing the analyst builder at Outlook.com.That was for the course that I have on analyst builder for AWS and Azure.We need to add in our Alex the analyst atlook.com.So let's come in here and we need to sign into our account.So let's go ahead and sign in.And there you go.Your account was added successfully.Let's go back.And there we go.Now we're signed in.And we need to select our database.Now, it's not popping up the database right away, which should be called like Alex the Analyst DB or something like that.Let's go ahead and try to connect and see what happens.It looks like we're getting an error here.I think let's actually come back here.I think our server name is actually this one right here.I just chose the actual server, but this is the connection that we actually need to make.
So, uh I'm actually quite certain about that.Let's go ahead and click on this.And now it's saying our connection was denied since deny public network access is set to yes.So, this is something I was waiting to see because we need to configure this just a little bit.So, let's come over here and we need to go to configure access.So, we're going to select configure.And it says public network access is disabled, but we can enable this.And then what we can do is we can add in our IP address.So, we're going to add in your client IP v4 address.And all we have to do is click save.So, now it's going to update.And it's going to say, okay, you can access this.Let's not, you know, get too crazy and too wild here.Now, we can go back and we're going to select this.
And we already have that selected.So now you can see that we have our two databases.We have the master which is the one that you're going to get and then we have the one that we actually created.So all of that to show that you do have to configure a few things.Make sure you're doing it properly.And now we can come down here and we can connect to it.And so now right in here we can come into our tables.We don't have any tables but we can come into these tables and views and uh all of these different things.Now we can actually use this.So now we are connected to our resource.So, we're connected to our server and we can actually access the databases, create them, do all of our querying, all of our uh things that we need to do with our data and we have all these options on
the left hand side.Now, this isn't an Azure Data Studio tutorial, uh, but there's tons of stuff that you can do in here.So, if you've used something Azure Data Studio or if you've used Microsoft SQL Server, this should seem really familiar.You should feel right at home.Now, I want you to be able to actually use this.I don't just want this to be something pretty.So I need to show you one other thing that you need to do.Let's go ahead and try to create a table here.Right down here we have this script create new table.We can keep it new table just with the one column.Uh it doesn't really matter.Let's just say this is ready to go.Let's go ahead and publish these changes.Then we're going to come down here and we're going to update our database.Now we can come over here and we have a new table.
So we can actually uh open this up.We'll select the top 10,00.And of course, we don't have any data in it, but uh we have a working table.So now this table is being stored on a server in a cloud.And this is great.So if you've ever used something like Microsoft SQL Server, you have all these tables and databases and all these things you're working with.That's how it's actually used in the real world, except you'd probably see a ton more tables.You'd have access to a bunch of different servers for different clients and different uh data.So that worked perfect.And what you can now do is let's do CtrlN.just get a new query window available.I'm going to paste in here just like this.Um, we're already selecting our database.We don't have to say use this database go.I'm just, you know, that's what I'm used to, so I'm going to keep it in there uh for any, you know, if you have a put this in a store procedure or something like that.
I don't want it to fail out.But this is just a super simple table.Um, and we're going to go ahead and run this.Looks like that should be done.Let's refresh or actually refresh this table.And we have this products.Let's open this up.And now we have data in here.These are little under uh underlined in red.Sometimes if you do control ctrlalttr, it'll refresh it.Or maybe it's control shift r.That's okay.It'll get rid of it eventually.It just doesn't recognize it uh yet, but it will.Um so anyways, we have our data in here and now we can write regular queries.And so this isn't a SQL lesson.I'm not going to show you how to write SQL, but I have hundreds of other lessons and courses on how to learn SQL.And so this is uh kind of the nuts and bolts of how you set everything up and this is how people actually use it.
So this shouldn't be too intimidating if you know how to use MySQL Workbench or Microsoft SQL Server.And so uh that is really awesome.Now if we come back here, we're just going to take a look at a few more things.This is just within our server, but we don't want to look um at our server.We want to go back to our database within our SQL database.right here.We already looked at a little bit of configuration and Azure data studio.Again, remember if you need to uh connect it to my SQL or something like that.Now, just within the SQL database, there are a few other things that you can do.One, they have something called a query editor um where you can come in here and you can query off of let's say you have tables you can query off of in here.
I can assure you that almost nobody ever uses this, almost ever.Uh this is not really something that people use.It's there to kind of test connections sometimes.So if you're just setting up a new server or a new So if you're just setting up a new server or new database or whatever it is, you can kind of check to make sure it's working.But you won't use this in your real work.Uh that it's just not doesn't make sense.Now let's come over here and take a look at this lefth hand side.There are some interesting things that I want to show you.One is this power platform.When you start working with a large amount of data, you have a server and a database set up and you're using it.You have tons of real data in there.you're like, "Okay, now it's time to connect this."
Well, you can use things like PowerBI, Power Apps, and Power Automate.All these things just kind of automatically integrate into it.There's also integrations, but just knowing how, you know, these are actually used.You most likely won't use them, but just knowing kind of what these are and how they work, you most likely won't use these too much.For people like you and I, PowerBI is something that we'll probably use quite a bit.And we most likely won't use monitoring too much, but I will say I've had to come into the monitoring quite a bit over my years to debug a bunch of stuff.So if a store procedure is failing, if the database is failing and you know you need to figure it out, you can come into the logs.If you need to see how much compute, how many resources you're using, you can look at the metrics.
So there are some reasons to come in here.Typically though, this is more IT related.this isn't as much of what a data analyst will typically do unless you work like I said in IT where they monitor a lot of those things to keep cost down and keep things running and you know goingsmoothly.So, I hope that that was helpful.I really appreciate you guys watching.If you have not already, be sure to check out my full AWS and Azure course on analystbuilder.com.And if you like this video, be sure to like and subscribe below.I will see you in the next video.
What's going on everybody?Welcome back to another video.Today we're going to be taking a look at Azure Data Factory in Azure.
Azure Data Factory is a super cool tool within Azure because it allows you to create data pipelines and different workflows to extract data and clean data, transform it, and put it places.And so it does a lot of different things.It's one of those skills I started using when I started getting a little bit more advanced in Azure, but I don't think you have to wait till you're really advanced as an analyst or a data scientist or engineer.I think you should start learning it now because it's a really really great skill to know.So with all that being said, let's jump on my screen and take a look.All right, so let's get started by coming right down here to analytics and under here we have data factories.Let's go ahead and click on it and let's create a data factory.So let's come in here.
We need to give it a name.choose our resource group and we'll be rocking and rolling.So, let's call this the Alex the analyst and we'll do ADF just like that.For the region, we're good.And for version, we only have one option.So, let's go and review and create this.Now, as we know, this is going to be uh deploying this.It's going to take just a minute and then it'll be done and then we'll get going.And there we go.That literally took maybe 15 seconds.And so, uh just set up the data factory version two.And let's go to our resource.And there we go.Now, this should look uh, you know, fairly straightforward.We just have some of this information up here.We have our launch studio.And then down here, we have some of the monitoring.So, when you're actually running these automated systems, pipelines, everything that we're going to be doing, um, you have some data on it.
And you can see some of the, uh, data on that.Now, they do have some quick starts, tutorials, template, galleries, and training modules.go ahead and take those cuz I've looked at a lot of these and they're really great.Uh, but what we're going to be doing in uh this lesson, which we're going to cover a lot of stuff, is I'm going to help get you set up.I'm going to help show you how to do different things.And there's going to be a lot of stuff that we cover.So, I'm going to be moving pretty quick, but let's go ahead and launch our studio.And here we go.So, this is the Azure data factory.There's a bunch of different things that we can do in here.We can ingest data.We can orchestrate.So create codef free data pipelines.And we can transform data.
Now we're going to be looking at a lot of this but not all of it.So stick with me.The first thing that we are going to do is we're going to work on an ingestion because being able to pull data in is actually a pretty important thing to know how to do.We're just going to select run once and we're going to select next.Now uh there's a lot of different places that you can ingest data from where your source data is stored but for us we are going to select the data that we put in the last lesson.So in our last lesson we have put some data um in a SQL database which this is our server right here ATA server YT and we have this table right here.So we're going to ingest this data and so what we're going to do is we're going to come over here.
We're going to type in uh SQL.Should have Azure SQL database should be right there.And we don't have a connection yet.So let's just select our new connection.This is basically like connecting to the Azure data studio uh before.And so this should seem really really familiar.So we have our ATA server YT.We have our Alex the analyst DB.And so now we should uh for our Azure subscription, we have our subscription.And let me go back because now it's not remembering.Uh so what we need to do now is we need to select our uh system assigned manage identity.So our manage identity is this one right here, Alex the analyst adf.Now that's going to be really important in just a second because this is by far the most confusing and you know frustrating part of doing this if you've never done this before.
So let's just say we want to go ahead and create this.It was successfully created but we're getting this connection failed.And if we look at this, it says it cannot connect to it because basically it cannot open the server requested by the login.Now what we need to do is we need to edit this and we need to do something quite important.We need to take this manage identity name and we're going to actually update our database and make sure that this identity name is in there so it recognizes it and can connect to it.So let's go ahead and copy this and let's come right over here.Let make sure I have that.There you go.Let's do controlN in our Azure Data Studio.Now, this right here is the most important thing, but we have to put that in a few different places.
So, I'm going to write out all the code and then I'll explain it to you and I'll have it to where you can just copy and paste it yourself.You don't have to write it all out.All right.So, I went ahead and wrote everything out.What we're doing is we're creating a user and that's going to be our user for Azure Data Factory that we have right here.So, we're adding that and then we're altering the role to make them a member so we can get access.Now, if we run just this, let's go ahead and run this.You'll notice that we don't have anything in this database principles and this database role members.This is our uh CIS databases.So, we're just checking there isn't uh that account in there.So, what we now need to run is this top part.And again, I'll have this as a copy and paste down below.
Let's go ahead and run this.And looks like it worked.And now, let's check these two queries again.And there we are.So now we are in both of these uh CIS databases or CIS tables that we need to be in.So we should be good to go.Let's go ahead and go back and we're going to come right in here.And now that we have all that connected.Let's make sure let's see.Let's make sure everything's good in here.Let's go ahead and test this connection.And there we go.You can see that the connection is successful.Now, what we can do is cancel out of here because now this should be working.Now, what we need to do next is select what data we actually want in the output.Let's go ahead and select our products.We'll select next.You can preview the data if you want, but we don't need to do any of that right now.
Let's go ahead and select next.Now, where are we going to place this data?Because we have data sitting over here in Azure Data Studio right in here that we want.And let's say we want to put it in the Azure blob storage.Maybe this is a report or some type of query that we want to send to a client.Uh, and so that's what we're going to do to get it into the Azure blob storage.We need to select our subscription and our account storage name.And we'll go down here to create.Next, we have to choose our folder path.So, let's pull up our storage account.We can duplicate this over here.And let's come back and let's see if we can get it right here.Here's our storage account.Let's go to Alex the Analyst storage.Let's go to our storage browser.
We're going to go to our blob containers.Now, we should have uh one blob container in here.Here we go.Ata container.So, we can come back here.We're just going to select browse.I did all that just to show you where the data was coming from.Uh but that's in our uh storage account over here.Or is it called account storage?Storage accounts.If we just uh come in here and we say, "Okay, we want a file."That doesn't really work cuz we're putting data into something.So, we can't put it into a different file.We need to select a folder that we're going to place it into.So, we're going to select the ATA container.We're going to select okay.For our file name, we'll call this one SQL database output.And that should be good.Let's go ahead and select next.Now, these are the file format settings.
We need to specify how we actually want this data to sit once we move it into the blob storage.Now, this is a delimited text.You can choose JSON files or C files, paret files, whichever files you want.So, we're going to do a comma delimited file, which is should be a CSV.We shouldn't need to add any compression onto it.Uh, because this isn't a massive amount of data or multiple files at all.So, we should be able to go ahead and select next.Next, we need to specify our task name.Now we're going to call this one uh SQL to blob and we should be good to select next.And this is the whole process.So we have Azure SQL database going to Azure blob storage.Let's go all the way down.We'll select next.And this is uh creating this.It says our whole deployment is complete.
It validated the copy runtime environment, created the data sets, created the pipelines, and ran the pipelines.Go ahead and select finish.If we come over here to our storage, you can see that right here we have our SQL database output and uh let's see if we can just click into it real quick.Let's go ahead and download this just to see what it looks like.I'm just going to put this in downloads.We'll go ahead and save that.If we open up this file, uh just ignore those pictures of me and my wife on the Segway.Um if we open up this file, we can open it up as a let's just open up in Notepad.And you can see here's our data.Now, this isn't in a CSV format.Um, and that's okay because it's really easy to change it.But it is CSV uh separated.
So, it was a text file.It meant to be I kind of want it to be a CSV, but we can very easily uh change that if we do CSV here.And now we've changed it into a CSV.Let's open it up.And there we go.So, uh you can definitely change that and we may actually look at that at some point in this lesson.But very easy to change that to a CSV file because it is comma separated.Um, so all this looks great.This looks really, really good.I don't need to save this.Let's go ahead and go back.Now, let's go back to Azure Data Factory.One thing I want to point out really quickly, uh, before we get into some other things is, uh, for our recent resources, we have our SQL to blob.You can find that right over here in this author.
So, when we go over to author, you can find our pipelines and we have some data sets as well for our destination and our source data set.But that's regardless of what we're looking at in our pipelines.We built our SQL to blob.So if we come over here, this is what it's doing.And we can click on this and we can see uh kind of what it's doing.Down here we have our source data.That's where the data is coming from.That's our table.You can also have it write a query.So you can change this to a write a query from that table if you want to do some advanced stuff.Uh um you know, this data is super simple.But if we wanted to just select units in stock where it's greater than 100, right?you can just write the query in here, copy it and put it right in here and then you can have a query instead of pulling over the whole table.
And so that's actually uh really really useful.And so that is all really interesting stuff.Now within what we're looking at right here, we'll take a look at that in just a second.Um but what we're going to do is we're going to come over here to transform data.Let's go ahead and select this.You can see right up here we have our SQL to blob.That's our pipeline.And we have a bunch of stuff.And then we have our data flow right down here.Now what our data flow is is we're able to take different data sources, different things, transform it, join it, uh do aggregations, do anything we want to it, and then spit it out wherever we want.If we want to pull all these different files and put into a SQL database, we can do that.If we want to take a bunch of different data and we want to put it into a file, put into blob storage, we can do that.
Or if you want to take multiple tables from a SQL database and then put it into a file, we can do that.And so it's kind of limitless what you can do within here.You just have to kind of know how it works and and kind of piece everything together.So let's start building this transformation.Let's come in here and we're going to add a data source.Now within our data source, we can come down here and we need to select a data set.Now these are two data sets that we've already used.uh these were in the ones that we did when we created the SQL to blob.Let's say we want to create a new data source.If we select a new data source, you'll notice all the different options for this, right?We have a ton a ton a ton of different places and applications that we can pull in.
Um if you just want to scroll down, there's a lot.And so there's a lot of different things.Now, we're on a free tier, so um we may not be able to use some of these, but you know, if your company's paying for it, you should be able to do it.So let's just say we're going to take it from Azure blob storage.We're going to come right here.Ours is uh a delimited text.Let's go to our link service and go to our storage.And we need to select our data.So let's go to ATA container.Let's take this CSV file.CSV.So we just came in here.We're just selecting our data source.And you'll see we select it from our blob storage.And there's the path to it.Let's go ahead and select okay.And there we go.Now, one thing we will want to do as we're going throughout this process is to turn on data preview.
So, we have to turn on the debug mode.Debug mode is right up here.So, data flow debug.And you can let it live for a certain amount of time.This does cost money.It's very cheap, but uh it's well worth it because as you're doing all these different things, you're going to want to preview the data and see what data looks like as a final result before you push it somewhere,before you put it into a database or a file.So, we're just going to wait for just a second while that um while that debug session starts and then we'll have our data preview available.Now, this is taking forever and I don't want to wait around forever to keep going.Uh it should work at some point and maybe we'll see it throughout the process, but uh we're just going to keep going because if yours is taking as long as mine, we don't need to wait on it because
it's not vital.You don't have to have it.Um so, let's come down here.What we can do is we can add another source if we want to.You don't have to, but if you have multiple sources, you can add that.Uh so if you wanted to add a source down here, you just add uh another source.We aren't going to be doing that.So we can just delete that.Let's click this little button right here cuz there we're get a little different options than we have been uh before.We have a bunch of things that we can do to this data.So let's just scroll down really quickly.You should notice and you should be able to see a ton of these and one of the most important is actually this destination sync destination at the end and we'll take a look at in a bit.
But we have all of these options to actually change and transform our data.And so if we want to clean the data, if we want to filter the data, if we want to aggregate the data, uh if we want to pivot the data, there's so many different things that you can doto it.Now, really quick, uh while we're here, I'm just going to show you the actual data that we're working with.If we open up this file, we have this CSV file.Let's go ahead and open it.And this is the data that is actually in that file that we upload.And there's a lot.There's about 32,000 rows of data.We have things like state name, county, city, place, type, etc.And so there's a ton of data in here.Let's say we just want to filter this data.So let's go back.
Let's go ahead to don't save.I just wanted to show you what it looked like.Let's go ahead and let's say we want to filter our data.So we're going to come down here.We're going to go to a row modifier which is filter.And so what we need to do is come down here and I highly recommend opening up the expression builder because what we can do is we can say we want to filter on one of these columns.Now over here in the dataf flow expression builder we have our expression up here and we have all of our elements.So we have things like functions, input schemas, parameters, cache lookups, dataf flow libraries.99% of the time you're going to be using functions and your input schema.So our input schema is our table and the functions are all the functions that we have in here.
So we can do one there's one called equals.Let's do this one right here.So we can do equals.You have your expression.You can even say over here here's some examples that you can do.But what we're going to do is we're going to go over here the input schema and we'll get rid of this.We have something called a state name.So if we come up here, select in there, select state name.So if we do state name and then in here let's do Alabama.So what we're saying is is we're going to filter where the state name is equal to Alabama.That's what we're going to do.So we're going to save and finish this and that should be good to go.Let's see if we have a data preview.This hasn't been working for me at all.I hope it's working for you.
It's just taking it abnormally long time.Maybe because they're not prioritizing uh me as a small account, which is understandable, but um you know, thanks Azure.So now we have this source.We've filtered our data.And now and you can do so many different things in here.We're just not this isn't a full um you know lesson on how to use this.Now we need something called a sync.Now what the sync is is how you can actually save and publish it because you can't publish it without a sync.The sync is how you can specify where you're placing this data.So what we're going to do is we can place this anywhere we want.We can place this as a new file.We can put this in our SQL uh database.Now, if we come in here, we're going to have several different options here, but let's go ahead and select a new one and and let's say we want to put it back in the blob storage.
So, we're cleaning the data up and we're going to save it as a delimited text file.Let's go ahead and select continue.So, now we want to put it in our blob storage.Again, we need to select our container.Container is going to be ATA container.You could set up another container if you want.Now, I don't think we want to select a file name because uh we're choosing the file path where we're going to place it.So, I think we just need to select okay here.Now, there's one last thing that we want to do before we actually publish all of this.Let's go to settings.And we have some options in here, which is a file name option.Now, when you're doing files in here, you in fact, you should probably publish this and just try it and see what happens.But often times you're going to want this as a single file, but it doesn't always happen when you're using Azure.
Sometimes it'll make it 2, three, four, five, six files depending on what you're doing.So I like to output this as a single file.And then we get to output as a single file.And we can select the name.So we can just put this as we'll do filtered data.Uh, and that's it.I'm actually not sure if I need to do CSV right here.Let's just try it as CSV.Let's go ahead and try to publish this.It looks like it says the file name option output to single file requires single partition be selected in the partition type.So if we come over here I think it's in optimize for the partition option.You can use current partitioning but we need to select single partitioning.It now says it is fixed.We can close that and let's go ahead and publish all.So what we are going to do is we're going to review this.
We have our different data sets.Um and then we have our data flow.So our data flow we're going to go ahead and publish.These are all changes that we've made uh throughout this process.It's going to deploy those and then it's going to uh run this data flow one and then we should see a new data set uh which is filtered based off of our source data.We should see that in our storage account.We should be able to come right up here and it looks like uh all those things are completed.Now I forgot we're actually not going to see this uh because it didn't actually run.It just saved as a data flow.We need to come up here and we need to create a new pipeline.So let's come up here, create a new pipeline.And what we're going to do is we're going to go down to our data flow.
We're just going to drag this over.So this is our data flow.And we can name this anything we want.We can say uh transform.I need to spell that right.Uh transform data.Let's just call it this.And then we need to add a trigger.So we're going to go ahead and say trigger now.And that should run that data flow that we created.So let's go ahead and trigger now.And actually we need to publish it first.So let's go ahead and publish all.We'll publish this.And that publishing is completed.And now we can trigger it.So now we're going to say okay.And it's going to start running.And so this is one of the things just to kind of understand about building data flows and pipelines is that the pipeline you can do a lot of different things in it, but you're mostly chaining together different data
flows.When you actually get in the data flow, you're chaining together all the different combinations that you want to do with different data sets and transformations and data cleaning and all these different things and then you put it intoa pipeline.And that pipeline when it runs, which I think it's still running, when it runs, it runs that data flow that you created.And so these data flows can get really complex and you can chain multiple data flows together.You can say once this data flow is done running, then do this.Once this data flow is done running, do this next data flow.And so there's a lot of different things that you can chain together.And it's pretty awesome.So we're just going to wait on this for just a second.And when it is complete, we'll take a look at the output.And there you can see that it succeeded.
Let's come over here and take a look.Let's go ahead and refresh this.Let's go to our blob container.And there we go.We have our filtered data.csv.So you can go ahead and check that out.Uh so those two things are working great.Let's go back home really quick.So we've worked on ingestion, we worked on data transformation, and lastly we have this orchestrate.And let's just come in here really quickly and take a look at how this looks.So as I was telling you before, we have these uh different pipelines that we've created.We've created a few extras that don't do anything.Um but what we can do is within this we can orchestrate this by taking multiple different pipelines, multiple workflows, multiple data sets and orchestrating all of it into an actual full pipeline.Now with that, and we're not actually going to be uh doing that right now, but with that, you can see that we have a ton of options right here.
And in fact, you can take data from a ton of different places.You can copy data, you can do a Spark job function or even an Azure function.And you can customize so many different things and take data from so many different places and you can use so many resources within Azure to do just about anything you want.And so uh and I don't say that you know as in like you can actually do anything but just look at all these options.There are so many things uh that you can do.And so I've just given you a brief kind of introduction to ingesting data uh and transforming data.And then to build these out you just kind of combine those things together.So you say okay I want this uh pipeline right here and then if that works then we want to you know transfer it over here and actually we need to do something like this on success and so you
can say if this works then on the success of that we'll do this and then just for an example we can say um we'll add this down here and we'll say if it fails we'll do this one andso this is just a demonstration of how this looks.This isn't actually what you should do by any means.Um, but you can give it some different instructions.You can say if this successfully works, if this pipeline works, then go do this piece.And then if this works, go do this piece.Oftent times you're going to chain these together.And this is the full orchestration of Azure Data Factory that we're not looking at in this lesson, but you can imagine uh you're taking data from a client.So the client drops data into a specific location.You ingest that data.So you have a data ingestion data flow.
Once that data gets in, then maybe you have one for transforming your data.So if the data adjusts properly, then you're going to come up here and you're going to transform the data.Then you'll have another one afterwards.You'll be over here and you'll say once it's transformed and then we're going to send an email to me who is the person who owns that and saying, "Hey, this ingestion process worked or this data pipeline worked."And so you can get really advanced.You can also keep it really simple.And in my time as a data analyst, I worked with a ton of data engineers and data scientists and database developers who use this all the time.So I get in there and I get to mess around with it quite a bit.And oftent times it was mostly keeping it kind of simple.You're ingesting data, you're transforming the data, and you're placing it in somewhere.
There were some use cases where we did a lot more advanced stuff, but this is the meat and potatoes of it.So play around with this, mess around with it, try to get these different things to work, try to create a full endto-end project.I think that'd be really cool.And maybe I'll do that in a future video.So that is in general what ADF kind of is.That's the meat and potatoes of Azure Data Factory.And I hope you're able to follow along and really understand that so you can start building on top of that and trying out your own stuff.If you found that helpful, be sure to check out my full Azure and AWS course on analystbuilder.com.And if you haven't already, 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 taking a look at Azure Synapse Analytics in Azure.
Now Azure Synapse Analytics is meant to be this all-in-one place to go for all your data analyst needs.It's going to have ETL.It's going to have workflows.It's going to be able to query data.So, it has a lot going for it.So, we're going to be taking a look at that and I'll talk a little bit about the comparisons between Azure Synapse Analytics and a few of the other resources and tools within Azure.So, with all that being said, let's jump on my screen and take a look.All right, so let's go down to our analytics tab.Let's go over to Azure Synapse Analytics and let's create a Synapse workspace.As you know, we need to select our subscription and our resource group and we need to name this.So we'll call this Alex the analyst and this is called uh oh wait I need to make them all lowercase.
So we'll do Alex the analyst ASA Azure Synapse Analytics.That should be good.Now the next thing that we need to do is select a data lakeink storage gen 2 when we are using Azure Synapse Analytics.We are using a data lakeink.So we need to create an account name for this.So we'll do Alex the analyst ASA.That should work.Then we need a file system.Now we don't have one.So we're going to create the Alex the analyst FS and let's select okay.Now it says right here assign myself the storage blob data contributor role for the data lakeink storage gen 2 account to interactively query it in the workspace.So we're making oursel the person who is the main contributor so we can actually use this data lakeink gen 2 that we're using.Let's go ahead to review and create.It is going to cost us cuz we're using a serverless SQL per terabyte.
It's going to cost about 5 USD for that and that's not a big uh cost for us.So, we're going to go ahead and create that and that should be covered under your 200.If you had the free $200 uh credit, that should be covered under that as well.All right, so that was deployed uh successfully.If you look in here, we did a few different things or it did a few different things.One, it created a new storage account for us and that's going to be our data lake.Next, it created our Synapse workspace.So, we have the new storage account and we have a new workspace.So let's go to this resource group here and let's actually come into our Synapse workspace and you can see a lot of our information up here but then the most important part which is open Synapse Studio.
So let's go ahead and open this up.Then we need to go ahead and sign in here.Now let's just take a look at some of the things that's in here because this should seem pretty reminiscent of Azure Data Factory.And I say that because in our last lesson we looked at Azure Data Factory and we had a lot of these different things.We had things where we can ingest data.We could transform data and then we can place it somewhere.And believe it or not, you're able to do that within Azure Synapse Analytics as well.Not only that, within Azure Synapse Analytics, we're going to be able to explore our data and analyze it as well.You can come in here and see how all that works, but this is going to act very much like an Azure Data Studio.If you remember from our SQL databases video, we looked at Azure Data Studio and how that works and how you can actually access the data.
And we'll be coming back to uh some of these things in a little bit.So, we're going to keep this up.Let's come over here and let's take a look at our data.Right now, we have no data in here.So, let's come in here.Now, if we connect to a SQL database, we're actually creating a SQL database or a lake database, but we don't need that.We're going to connect to external data.In here, we can connect to our Azure blob storage.So, we're going to go ahead and say continue, and we're just going to bring in some of our data that we've been working with.So, we're going to go to the Alex analyst storage.This is where we have some uh data in here and we need to select our subscription right there.There we go.We'll go ahead and create that.
So, now if we come over here in our workspace, if we go over here to linked, we have our uh blob storage.Then we have our data link.Now within our data lakeink uh we don't have any uh data but if we come up here to the blob storage and so as you can see here we have all of our data that we have in thatblob storage.If we wanted to access one of those we can do something like select new script.We do a new notebook where we can load to a data frame or a spark table.We can create a data flow.We can take that as a source.We can transform the data and we can load the data to somewhere else.So there's a lot of things that we can do with this data.One other thing I want to show you just with the data section is we have these browse galleries.
And within here, there's a ton of real and really unique data that we can uh use and we can look at.For example, let's come over here to New York City uh safety data.Let's go ahead and click continue.There's a bunch of data in here.We're going to add this data set.It's going to take just a second, but it looks like it was created in this sample data sets uh in Azure blob storage.If we come over here, we can click on city safety New York.Let's go ahead and right click on it, select top 100 rows, and we'll go ahead and run this.As you can see down below, we're just looking at, you know, data.So, this is how we can run it with SQL.And with this, we can do just about anything we want, right?If we wanted to do some type of group by or joins or anything we want to do, you can do it.
Uh, this is going to be by default SQL Server.Um, so you can do a lot of things uh that you want to do in there, but let's just say we wanted to group by category um and subcategory.And then up here, we'll select the top.We'll just do all of it, but we'll do select category and subcategory.And then we'll just do let's do a count of the subcategory.We're just going to get a count of it.Let's go ahead and run this.And let's take a look.Okay, it looks like our output is correct.Uh I was getting worried at first when I saw the nulls at the beginning, but we could probably uh clean this up a little bit, but we don't need to.Okay, we're just taking a look at what Azure Synapse Analytics can do.So this is where we can query data.
We can also save this.We can publish this.And now that's been saved.So if I came over here to the develop, you can see we have SQL script one.Now we just got to change the name of this if we want to change it to something else.We can come over here.We can say rename.We can sol say this is the uh was this New York City.We'll say group by uh category.We'll just select okay.And there we go.So now we've saved that script.And so that's really important.That's really really useful.One other thing that we can do down here is we can also look at this as a chart.Now, this data in and of itself isn't very helpful as a line chart, but if we did a bar chart for the category column was the category and maybe we just want to select the top 10.
We'll order by let's do the count of subcategory.Let's try running this again and we can go look at the table really quickly.And I need to do this descending.Whoops.All right, let's run this again.All right.So, there's the day that we want.Let's go back to this chart.Uh, again, this isn't a good visualization.We would do something like a bar chart.Uh, we would have the category here, and that'll be fine.But you can customize this a little bit more if you'd like to.Um, but we're able to look at little visualizations in our output when we're working with the SQL scripts.If we want to, we can save that as an image.And that would be great.Again, we can publish this and we can save this and we are good to go.Now the next thing that we can do, let's go back to our data.
Next thing we can do is we can also create a notebook.So let's load this into a data frame.And you're going to notice this looks a little bit different.Now before we can actually run this, we have to create or attach a spark pool.We don't have one.So we're going to go create one uh really quickly.And we'll just call this uh ATA pool.There we go.We're going to go back down to review and create.going to create this.That was successfully deployed.So, our uh pool is ready to go.So, let's go back here.We're going to go to our ATA pool and we're going to choose spice spark.That's the one I've almost always used.You can also use SQL in here.Now um SQL in uh Azure Synapse Analytics or in other tools maybe like data bricks and other things like that they don't always have a SQL option but now it's being added a lot more but I used to
have to use Scola and Pispark and all sorts of things but now if you know SQL you can do that in here too.Um so you're good to go.We're going to this is Pispark though.So we're going to go ahead and run this.And right here we're running into an issue.Your Spark job requested 24 vores.However, the workspace has a 12 core limit and that's because we need to message Azure support and request more.Um, and unfortunately for this video, we're not going to do that.So, let's get a smaller data set.So, we're going to come back here to our storage and let's add a new file.It's going to be this products file right here.Let's go ahead and upload this.And there we go.Now, we can go back here.We're take a look within our container.And we have this products.csv.
So let's right click on this.Let's go to new notebook.You can load to dataf frame or spark table.Whichever one we're going to load this to a spark table.Let's choose our pool.And we're using Python.So now let's go ahead and try to run this.Now this didn't work.It says either the cores of the memory of the driver executes exceeded the spark pool node size.So for this what we're going to do is we're going to come back here.We're going to edit this.We're going to make it just the smallest one possible because we're just exceeding uh what we are working with right here.So now that's updated.Let's go back.Let's come right here.All right.And we got our output.Took a while, but that's cuz we're using a really small pool over here.Now, if you use a larger pool, it'll go a lot faster.
Uh so if you select a ton more nodes and uh you get a larger node size just in general, it's going to go a lot faster.And so right now, oops, let's get out of here.Right now, uh before when we tried it with this one, it wasn't working because our node sizes were just too large for what they're allowing us to have.We have to again ask them to increase that.But again, that's mostly for really large data sets.For this one, we have a really tiny data set.and we get our data right down here.And so everything is working properly.But what we can do, which is really neat because this is a notebook, is we can come down here, we can write more code.So if you use something like a Jupyter notebook or there's tons of other notebooks out there that are really great.
Um, if you use a notebook, you know, you have some code up here.You can put code down here.You can also put markdown.And so you can add in, you know, any title that you want to uh add in here.You can say this is a title.I'll go ahead and run this.And another really cool thing about using a notebook, especially within here, is that you don't just have to use Python.If you uh for some reason you say, okay, I want to use SQL, you can do that using this magic command, and you can says SQL and then you can just write SQL like normal.So you can select everything.We'll come right down here.We'll say from and right now it's called dataf frame.But I don't know if that's actually going to work.Let's go ahead and run this.And that's not going to work because it's not uh in a table.
So we can do dataf frame dot and we can say create and there's this option for create or replace temp view and then we can name it whatever we want.So we can say this dataf frame to table.So we'll call this uh that right there.Let's go ahead and run this and then we'll come down here and replace that right here.Now we can run this and we just created it into a temporary view.And now we can run this just like we're running SQL.And so there's lots of options that you can do with this.Um I have a hundred tutorials on using Jupyter notebooks and how to use uh Python.It's very similar within this.And so it's really neat to be able to combine the two uh languages.I guess if you want to call SQL a programming language, it's technically not.
Um but we have Pispark, so we can use Python and we have this as well.And so lots of options, lots of really good stuff in here.And so that's a big part of working with data within Azure Synapse Analytics.Now if we come down here to integrate, we can create now pipelines, link connections and copy data tool.Not using them, but we can use these things.And this is very very similar to Azure data factory.There are also some really good uh options in here if you want to kind of copy these.Let's say right over here it says bulk copy from files to database.If you want to do that, you can come in here, click continue, and then you can use this.So you can open this pipeline.You can say this is what I'm looking for.And you select your link service and your other link service.
You open the pipeline, it creates that pipeline for you.So just something to be aware of.I think that's really awesome.And in fact, I've used these uh many times.Let's go ahead and click back.So there's tons and tons of just sample things where if you are doing one of these, let's say you want to create a system that deletes files older than 30 days.There you go.And so there's tons of things in here that you can use.Um as well as there's different SQL scripts you can use, different notebooks, different data sets.These are all free things that you can use within Azure Synapse Analytics.But let's get out of here.Let's go ahead and close this out.So let's say we do actually want to use something in integrate.Let's uh use this copy data tool.And this should look extremely extremely familiar if you use the Azure data factory uh if you took that lesson.
Now, we're just going to copy it from blob storage.We'll go to next.We'll go to browse and we'll just select a file.So, we're going to come in here.We have our products uh data.So, we're going to take that products data.We're going to select next.and it wants to know what our file format is.Right now, we have it kind of as a CSV and we don't need any compression.So, we're going to go ahead and keep it as is.And we need to select our destination.Now, we can put this in almost any place we want.In fact, Azure uh SQL database would be a perfectly good spot for it.We're just demonstrating how to move one thing to another.So, I'm going to select Azure blob storage.We're just going to place it in the exact same one, exact same container.
We're going to make some uh weird copy of this.Let's go ahead and click okay.And we need to select the file name.Now the file name is going to be products_copied.It's all we're going to do.CSV.Uh so now we'll select next.We'll select next.And our task name is going to be copy data.We'll do underscore.So copy data.And we'll select next.And we're going to select next.Now I'm not going to deep dive into the transformation and the pipelines and all those things because that's what we did in Azure data factory and in Azure Synapse Analytics.It's very very similar.Now you can see here we have this pipeline built.We can come right over here and this pipeline is ready to go.All we have to do is we have to publish it and then add a trigger.So let's go ahead and publish all.
We're going to go ahead and publish this.Now that we've published it, we can add this trigger.We're going to say trigger now.We're going to click okay.So, as we looked at in Azure Data Factory, once we publish it, it saves it.We can add this trigger.We can run it to trigger it now to actually activate that process.And now, it's going to copy that data over.Now, that should take a little bit of time, but we can view that pipeline running.And it looks like it just succeeded.We can go back to our storage account.We're going to refresh our storage uh really quickly.go back to our blob containers and there you can see we have products_copied.csv.So even within Azure Synapse Analytics we can create these workflows and these pipelines.So let's go back over here back to the integrate.
So this integrate allows us to do just about almost everything that we were doing within Azure data factory.It is a little bit more limiting but we copied some data.That's what we worked with.And there's a bunch of other things in here as well.You can create full data pipelines within Azure Synapse Analytics just like you can Azure Data Factory.But within Azure Synapse Analytics, we can also use the data.So we can take a look at the data and we can uh run queries on it and we can create different notebooks as well.And this is really awesome stuff that we're able to do.So Azure Synapse Analytics is really meant for a more mature data team.They're using large amounts of data.Again, this sits on top of a data lake.So you're creating all these pipelines, you're working with all these different data sets and you're querying the data, you're using the data, you're transforming the data.
That's what this is really really for.And so if we come back over here to the home, you can see that we ingested some data.We explored and analyzed some data.We also have visualized data.Now, if we click in here, we can connect to PowerBI.We don't have an actual workspace for PowerBI set up, so we can't do that.But this is meant to be something that you're supposed to do.You're supposed to be able to ingest it, explore it, and then visualize it all in one place.So, it makes the work for data analysts or even data scientists quite easy.If you have kind of a smaller team or depending on your team, what data and tools you use, you may be able to do most of your work within Azure Synapse Analytics.Again, just depending on uh, you know, how everything's configured.
But if you have a lot more complex systems, a lot larger data sets coming from a lot of different data sources, you may need to go branch out and use some of these other tools like SQL databases.Azure data factory as standalone tools, but sometimes you're able to get it all within Azure Synapse Analytics, all your ingestion, your data analysis, and your data visualization all in one place.And so it's a really powerful tool, and this is one that I used for quite a while.And so, uh, just coming in here, this is really bringing me back to one of my previous data analyst jobs where we were in here all the time.Now, one thing to note, and I didn't really mention this, is that this is actually a workspace.And so, uh, we have this workspace that you can then share and you can collaborate with people on.
And so, if you're over here in a notebook and you're trying to run it, it's not working or, you know, whatever it is.Um, we can run these run this one real quick.It'll take a second.Um, we can run these and you can collaborate with other people and they can see your code.So then you can, you know, publish this and you can save this and all these different things and other people can view this.And so it's kind of more of a collaborative environment as well, which is really nice.So get in here, mess around with it a little bit.This is kind of just a little crash course on how to get up and running and some of the features of Azure Synapse Analytics.And this is a really great tool to know how to use.And I hope that that was helpful.
I hope you got kind of a good overview of how Azure Synapse actually works.If you have not already, be sure to check out my full course on Azure and AWS on analybuilder.com.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 AWS series.
Now AWS to me always seemed really complicated compared to Azure because I started with Azure and I knew it really well.And so when I started using AWS, it just seemed like a whole another world.So if you've already gone through my Azure series, that's really good because I'm going to reference it quite a bit to make some comparisons, but we still will be focusing mainly on the AWS portion of it.In this series, we'll be getting everything set up.We're looking at S3 buckets, Amazon Athena, Glue, Glue Data Brew, and Quicksite.And so that's a lot of different tools within AWS.And these are ones that I think are really, really important to know how to use.In this video, we're going to be creating an account and doing a walkthrough of the user interface.So without further ado, let's jump on my screen and get started.
All right, so what we're going to be doing is creating an AWS account, looking at the UI within AWS, just getting familiar with it before we jump into some of the tools within AWS.Now, here I'll have this link down in the description.we are going to get started for free.So let's come right here and what we want is the AWS free tier.With the free tier, we get a lot of things within AWS completely for free.Of course, there are some things that are not underneath the umbrella of the free tier and so we won't be using those, but we will be able to do everything in this series with just the free account.So let's go ahead and create our free account.We need to sign up for AWS.Let's go ahead and verify this email address.So, I'm going to use my Alex theanalystytgmail.com
and my account name is going to be Alex thean analyst.We'll do AWS.I got the code.I'm going put it in here and verify this.Now, we need to select our password.So, I'm going to put my password in right here.There we go.Let's go ahead and click continue.Now, within this free tier, we get a few different things.one uh the free services that were within AWS, they're never going to expire.You'll get them free always, which is really great.Um we also get 12 months free for certain services, and we'll look at that in just a little bit.And these things activate from when our trial actually starts.So, let's go ahead and fill out all this information, and then we will continue.Now, if we do use any services, we have to have billing on hand in case we use something that is not free or we go above the free tier.
And so you have to input some type of credit or debit card number just in case you do that.Within what we're doing, we shouldn't be doing that or if we do, it'll cost like 10 cents.And so it should be super super cheap.So go ahead and fill in your information here.Next, we need to confirm our identity.I'm going to have it send me a text message so that I can uh fill this out.So go ahead and do that as well.All right, we're going to go ahead and select continue.And now we need to sign up for a support plan.Now, we're using a free account, so we don't really need support.Now, if you are just you're feeling wild, uh, and you want to get something like developer support, you can.If you're encountering issues, um, or if you're using AWS for business, maybe you want business support.
Uh, you know what?Go for it.I'm not going to stop you.But we're going to be using, uh, the free support because, uh, I don't want to pay for it.So, let's go ahead and complete our sign up.And just like that, we have created our AWS account.Let's go to the AWS management console.Now, we are actually going to sign in with our account.Now, we are a root user.So, we're going to come in here.We're going to put in our email address and sign in.All right, we are all signed in.Let's go ahead and click next.Done and done and done and get rid of all this stuff.Now, this is our console home.You'll notice that it's very, very blank.We don't have anything that we've recently visited.We don't have any applications running.We don't have any cost uh going either.
And so once we actually start using some of these services when we get into glue and start automating things you know you might have a cost but it should be under the free tier but you will have acost when we start using databases and instances and all these different things.These things are compute and resources that AWS offers.So we'll be able to see and monitor a lot of those things within this home console right here.You can also customize this console home if you want to.So, if you want to come in here and add widgets, you can add different metrics or different things that you want in here, but we're not going to be doing that in this lesson.So, let's take a look at this UI really quick.On this lefth hand side, we have services.If we come here, this is all the services that AWS offers.
And I'm just going to kind of slowly scroll down.We have compute, containers, storage, databases, machine learning.Let's keep going down a little bit.We have analytics.For this series, we're going to be focusing on things in this analytics tab.So, right in here, we're also going to be looking at some stuff in the databases and then of course S3 for S3 buckets.And this is where you can access all the resources and all the services within AWS.Another thing to note is this right up here, which is our region.Now, I'm in US East, but make sure you have the appropriate one that you're using.the region actually is uh pretty important if you choose one that's really far away.You're going to have some latency and some delays on retrieving data or using different services.And so make sure this is the correct one for you.
Lastly, if we come over here, you can notice in your account we have account organization service quotas, billing and cost management and security credentials.The two that I think are really important is account and billing and cost management.If we go over to billing, this is an actual service uh within AWS.You can look at all of your costs.And so, as you start using these different services, you're going to want to come in here and make sure you're not, you know, spending too much money.Just as an example, we use AWS for Analyst Builder.And so, in here, we track all of our costs, all of our bills, everything associated with AWS for our platform.And so in here we track a lot of stuff and we have different metrics and different flags that we uh have in case we go over a certain amount or if something isn't working.
And so we monitor uh you can create monitoring stuff.You can monitor a lot of stuff in this billing and cost management home uh which also was really important when I was a manager and we were using AWS.And then lastly, of course, we have our account within here.There's a ton of stuff like bills, payments, you know, if you want to change your credit card and all these different things.This is a really good place to come and just be familiar with.So, let's just go back to the services real quick while we close out and we'll go to all services and view all services.So, this is what we're going to be focusing on in the next several lessons.We're going to be looking at things like S3 storage.Let's come down here.I think we're going to be looking at Athena, AWS Glue, Data Brew, AWS Glue, and a few others as well.
So, we're going to be in here.We're going to be learning a ton of stuff about AWS.And hopefully by the end of the series, you'll be really familiar with AWS, feel really confident putting it on your resume and actually knowing how to use it.So, I hope that this was helpful getting everything set up.If you have not already, be sure to check out my full AWS and Azure course on analystbuilder.com.And if you like this video, be sure to like and subscribe.I will see you in the next video.
22:18:24 - 22:18:30
What's going on everybody?Welcome back to another video.Today we're going to be taking a look at S3 buckets in AWS.
Now S3 buckets are super flexible ways of storing your data within AWS and they kind of connect to all the other data aspects of AWS as well.So, if you have data sitting in an S3 bucket, you can connect it to a SQL database, you can connect it to a data visualization tool or an ETL tool or a ton of other things.So, we're going to be diving into how to set up your S3 bucket, how you can actually use it.We're going to upload some data and we'll talk about little tips and little nuances of using S3 buckets that I've learned over the years.So, with that being said, let's jump onto my screen and take a look.All right, so let's get started by coming into our services.We're going to go down to storage and we're going to click on S3.Now, you'll notice we have S3 Glacier over here.
And I'll briefly mention this uh a little bit in this video because it is worth noting.But let's come over here to S3.So this is kind of the homepage for Amazon S3.We'll take a look at a few things in here really quickly.They do have this little video here which if you're just using S3, you should look at.Now you may be wondering what does S3 stand for?It stands for simple storage service.It's meant to be a really simple way to store just about anything in the cloud.You can store essentially any type of file whether it's structured, semi-structured, unstructured, it could be almost anything.And so let's take a look at some of the things in here.It says store and retrieve any amount of data from anywhere.Amazon S3 is an object storage service that offers industryleading scalability, data availability, security, and performance.
Let's come down here and take a look at some of the benefits and features.You can read through all of these things, and they're all really good.I'll read through this one in a little bit, but it says data performance and durability, security compliance and auditing, granular data control, and flexible storage options.So, right down here, it says save cost without sacrificing performance.Store data across a wide range of cost-effective storage classes and support different data access levels that are all designed for specific use cases.Now, in this lesson, we're going to be taking a look at some of this, which is their storage classes, cuz these are quite important and they do affect the cost that it's going to take in order to storeyour data because uh it's not free.Uh storing your data in the cloud is not free.You can also look at some of their use cases as well as some of their case studies if you would like.
Now, let's actually get into it.We're going to come in here and we are going to create our very first S3 bucket.So, I'll click on create bucket.The first thing that we need to do is do some more of our general configuration.We're going to keep this a general purpose.And we need to give it a name.So, I'm just going to call this one Alex the analyst bucket.And if we had a pre-existing bucket, we've already configured it with uh different configurations.We can just select that bucket and it'll copy over all the uh things that we want.The next thing we need to do is need to come right down here for object ownership.You can have ACL's disabled or ACL's enabled.If we go with the recommended route, it means that all the objects in this bucket are owned by this account, your account that you created.
But if you do it where it's enabled, it says objects in this bucket can be owned by other AWS accounts.So with this one, it's just a little bit more secure because you're not saying other people can own it, which means they can delete it or change it in any way.Next, we're going to come down here to block public access for this bucket.Now, this part is actually very interesting because I've had a lot of use cases where you just want to block all public access, but if you start really getting into AWS and you start using a bunch of differenttools and things, sometimes you need to get rid of it.Um, and you need to come in and not only that, there's much more advanced things in order to grant different bucket policies or create different bucket policies.And, um, we most likely won't get into all that in this lesson, but it can get quite advanced.
And so this piece is pretty deceivingly simple.Um, but we're just going to keep it as we block all public access, but as you uh start opening it up to different services within AWS, you may want to turn this off so that you can have differentservices hitting off of your S3 bucket or the data within your S3 bucket.So, we're just going to keep this as uh all public access off.I'm just giving you lots of extra information while we're in here.Some of my thoughts.Next, we're going to do bucket versioning.We don't need to have any type of versioning or version control within our bucket.What this means is keeping multiple variants of an object in the same bucket.It's used to preserve, retrieve, and restore every version of every object stored in your S3 bucket.And that is of course going to cost a little bit extra.
So we don't uh need that at all.Next, you can add tags.And tags are helpful if you have a lot of different buckets and you maybe it's per client.You have some type of tag for a specific client.Perfectly normal.Uh next we have default encryption.Now encryption in general is really interesting within the cloud.I've run into lots of use cases where it's been really difficult to work with.If you want to pull data into certain services, you have to decrypt it uh because you've encrypted it in one area.And so if it's in the S3 bucket and it's encrypted, uh especially with kind of more advanced options, it can be somewhat difficult.And so just something to take into consideration if you want to kind of up your encryption.But for most use cases, you're just going to use the server side encryption with Amazon S3 managed keys with the bucket key enabled.
Next, let's come down here to advanced settings.There's only one thing in here that we need to look at, which is the object lock.And remember, everything that you put inside of an S3 bucket is an object.Now, if we just read this right here, it says storage objects use a write once, read many, which is a worm model.And this helps prevent objects from being deleted or overwritten for a fixed amount of time or indefinitely.So, if you want to drop a file in there and you know you're going to need it, you don't want it to be deleted for any amount of time, you can lock that and you can have an objectlock on that object.It can never be deleted.We of course do not need that.So, we're going to keep that disabled.And now we're ready to create our very first bucket.
I clicked on create bucket.Uh looks like we can't use uppercase and I actually knew that.Uh let's fix this.Now, this does have to be unique.This is global.So, it says right here you have to use a unique name.You can't just use like Alex.Uh, someone's probably already chosen that.Let's go ahead and create our bucket.And now you can see right in here we have our very first bucket.Very exciting.Let's click into our first bucket, our only bucket.Let's go ahead and click into here.And we have a few different things in here.We have our objects, and that's going to be any files that we upload into this bucket.And within this, we can create tons of folders and subfolders and sub subfolders and all these different things.We also have properties.So this gives you a little bit of information on how you actually created this.
You have permissions.So if you want to grant uh access to it.I talked a little bit about this which is a bucket policy.So if we turn off this all public access and we turn on this or we allow this bucket policy, we can create our own bucket policy and that's written in JSON and we can create our own bucket policyfor public access to this specific bucket.That gets a little bit more advanced, but it is really fun.I've uh done that quite a bit.You have metrics on this bucket.You can manage this bucket and you can create access points to this bucket.So, there's a lot of things just within a single S3 bucket that you can do.But the most popular one that you're going to be using is this one right here, which is just adding, creating, and deleting, and using objects in general.
So, let's go ahead and upload our very first file.We're going to go over here to add files, but you could add a folder if you have a whole folder, but we're just going to add one file.And within my sample files here, we have a bunch of very real healthcare data.It's not real.Uh it's just completely fake data.Now, what we're going to do is we're going to upload one.Then we're going to come back.We're upload another one in a different way.And I'm going to demonstrate that and uh explain that in a little bit.Now, what we're going to do is we're going to select this file.We're going to open this up.And now we have this real healthcare data 1.csv.And that's what we're going to be uploading.Now, let's come down here.We have our destination.This is telling us where we're actually placing this.
We have our permissions and of course we have uh bucket enforced and so if we wanted to grant access to other accounts we need to change some of our access policies.But lastly we have properties and this piece is really interesting.This is our storage class.This is how uh Amazon S3 is actually going to store your data.Now I highly recommend going in to learn more and looking at their Amazon S3 pricing because it's very fascinating how they do this.Um, and it's also really important that you understand the differences between these different options that we have.By default, we have standard, and it's designed for frequently accessed data within milliseconds for access.So, if you're going to be using this data, you're going to be hitting off of it for different applications, services, uh, visualizations, whatever you're using it for, you're going to want to be able to access that pretty quickly.
And so, this is a great option.If you need it even faster, you have S3 Express one zone, which is singledigit millisecond response times for the most frequent access data.Now, I don't think it talks about cost in here, uh, but you can use a calculator, and this is going to be costly, right?It's going to cost more to get faster and lower latency responses to your data.Now, if we come down here, you'll notice we have this glacier tier.Now, if we went back to our resources, remember we talked about S3 Glacier.I was going to mention that.Well, you can use these different glaciers which allows you to store it for long periods of time at a much lower cost, but it stores it a little bit differently.This one specifically is instant retrieval.It's very similar to almost standard, but you're kind of storing it for a long long time.
You may not need it for 10 years, but when you do need it, you need it right away, which is not a lot of use cases if you're using Glacier.But then you have something like Glacier Deep Archive.This is longived archive data accessed less than once a year with retrieval of hours.And so this is going to be data that you don't need it right away.Uh you just want to be able to store it and have the security of putting it in the cloud, but you may not use that for years.And when you do need it, you know, you're just you're okay with waiting a little bit.It's going to cost almost nothing to store.It's very very very little.And oftent times if you're doing something like this, you may even put backups of databases.You may put backups of entire code bases in here.
things that you may never use again.Um, and there's lots of different use cases as well.So, I just wanted to walk through that with this file.We're going to do standard.And on the next file we do, we're going to do Glacier deep archive.And just look at the difference here.Now, let's come down.Uh, we don't need encryption.We don't need any type of check sums, tags, or metadata.That stuff is almost uh never used or very very infrequently.So, we've uploaded this file.Let's go ahead and go to our destination.You can see that now we have an object in our bucket which is fantastic.You can even come over here and you can see the storage class is standard.Now let's go in.We're going to upload one more but now we're going to upload it as a different storage class.
So let's go to upload.Let's go to add files.Let's go to healthcare data 2.We're going to open that up.The only thing we're going to change is now we're going to go down to the deep archive and we're going to go ahead and upload this.Easy peasy.And there we have two files.Now we have one in standard, one in Glacier deep archive.Let's go into the first one.If we want to use this in any way, it's almost instantly retrievable.We can download this.Uh we have a bunch of object options.So we can download it.We can copy it.We can move it.We can change the storage class.We do a bunch of different things.But let's come back and we're going to go to that file too.Let's go ahead in here.Notice right here we're getting a totally different uh message.
It says the object is starting Glacier deep archive storage class.In order to access it, you must first restore it.So you have to initiate a restore right over here.And it can take 30 minutes to several hours.Notice we cannot download this.We also can't really do anything with it until we actually initiate that restore and it is restored for us to be able to access it.And that's just something that I think is worth noting about storing things in S3.There are different storage classes depending on your use case and what you're using.That's ADA 4.And of course, you should look at the S3 pricing for both of these cuz this one is going to cost more than this one.Now, there are costs associated with restoring it, but if you're restoring it once per year or maybe once every 5 years, it's going to be significantly less than your standard storage class.
Now, this is kind of the meat and potatoes of using S3.Of course, you can create folders and subfolders.And in fact, when we get into some other lessons, especially things like glue, uh having folders, subfolders, and different things like that is actually really important because we have something called a glue crawler.You know, a crawl through your folders and subfolders and retrieve certain data.And so having a folder structure actually becomes more important in those lessons, but we'll of course get to that when we actually start looking at it.One other thing to mention, and this is just uh kind of a neat addition that they have in here.If we go into this file and we go down to query with S3 select, you can access this data and take a look at it.And so, uh, let's say we have, uh, our CSV here.
It's comma separated.We can query this data using SQL.And so, let's just run this with the limit five on there.We'll run our SQL query.We have our query results right down here.We can have it formatted and it looks like a little table.So, we can come in here.we can look at uh this data down here and just see what's in there.And so that might be useful to you.Now, in the next lesson that we're going to be having, we're going to use Amazon Athena, which is basically a tool to query off of S3 buckets.That's its primary use.And so, most of the time, I honestly am not using this almost ever, but you can even see right here it says Amazon Athena.That's what we're going to be looking at in the next lesson.We'll be seeing how Amazon Athena works, how you can query data, kind of set up a pseudo database like structure.
I'll talk about the pros and cons of Amazon Athena versus other tools because Amazon Athena is not for every use case.So, I hope that that was helpful.I hope you enjoyed it.If you have not, I have a full AWS and Azure course on analystbuilder.com.Be sure to check it out.If you like this video, be sure to like and subscribe below.I will see you in the next video.
22:33:02 - 22:33:08
What's going on everybody?Welcome back to another video.Today we're going to be taking a look at Amazon Athena in AWS.
Now Athena is a tool that allows you to query data in your S3 bucket without having to put that data into some type of database.you're just querying it directly.So let's say you just got a big file from a client, you put it in an S3 bucket, but you don't want to actually create a table and take the time to do all that whole process.You just want to take a look at the data.You just want to query it really quickly.Well, Athena allows you to do that.And so if that's the case, it can save you a lot of time and money.And so this is a really great tool that a lot of companies use.We'll talk a lot more about Athena in just a second.So let's jump on my screen and take a look.All right, so let's come into services and we're going to go all the way down to the analytics tab and we're going to go into Athena.
Now, before we jump into actually querying data and setting everything up, let's take a look at some of the information they have on Amazon Athena.This right here, this start quering data instantly is probably one of the uh biggest pieces of why you would use Amazon Athena.And I'll talk a little bit about a little later on about who this is for, why you'd want to use this versus other tools uh within AWS.But Amazon Athena is an interactive query service that makes it easy to analyze data in Amazon S3 and other federated data sources using standard SQL.So primarily though for you and I most likely you're going to be using this just to hit off of an Amazon S3 bucket.You can even see how it works right down here.It says point to your data source.You're going to use Amazon Athena.
You're going to query it and you can analyze those results down here in the benefits that are right here.You have start querying now.Oh, it's powerful, cost effective, fast.All of these things are great.Honestly, powerful, cost effective, and fast could be a ton of different tools in AWS.But this piece right here is quite unique to it in the fact that you can query it as it just sits in an S3.You don't have to bring that data over into a database and actually store it in the database.You can keep it in your S3 bucket and still query off of it.And so that is uh kind of the real use case and the real reason why you would want Amazon Athena just to look at data uh within an S3 bucket.Now we do have two options here.Query your data with Trino SQL or analyze your data using PIS spark and spark SQL.
We are just going to be looking at the Trino SQL in this lesson but of course you can use PIS spark and spark SQL as well.Let's go ahead and launch our query editor.And this is what you should see.Now it says uh we need to edit some of our settings.And I'll explain that in just a little bit.Um, but over here on the lefth hand side, we have our data.So we have our data source, we have our database, we have tables and views, and then we have where we query our data, and then down here where our results will be.So there's a lot of stuff just in here, but this is um not super crazy advanced.Uh if you've used anything like MySQL or if you've used Microsoft SQL Server or anything like that, this is like a really I don't want to say dumbed down version that's not super uh kind to say, but it's
it's a really simplified version of it.It's not very uh difficult to understand.You can also save your queries in recent and saved queries.And of course, we have some settings over here.Now, we're going to see how we can set up our database, create a table or two, see how all that works with actually hitting off of data within our S3 bucket and we will have to fix this piecewhich is you have to set up a query result location in Amazon S3.That's for your results or your metadata and uh that piece becomes quite important later on.So, let's come down here.We have our data source.This is going to be our AWS data catalog.Now, we haven't covered this in a previous lesson, but you have something called a data catalog, and we're going to look a lot at that actually in either the next lesson or the lesson after that when we look
at uh AWS Glue and Glue Data Brew.But that's how they kind of organize it.And so, we're not going to be messing with that uh here.But we have to choose a database.And notice we don't have any database.So, what we need to do is we need to start pulling in data.And when we're pulling in that data, we'll be able to create a database.Now, right here we have create.You can create a table from a data source or create with SQL.So, if you want to go the oldfashioned way where you're creating a table like this and you can and you can specify the column, the column types or data types, the location, all these things, you can do that.Uh, but we're not going to be doing that.We are going to be doing it with S3 bucket data.Now, we also have AWS Glue Crawler.
Now, I'm just going to open this up really quick.We will be doing this when we get to glue.Uh when we start looking at glue because crawlers are great.Crawlers allow you to specify the data source and it pulls it in and infers based off of the column names and and the data types that are in there.It builds the table for you and it's very helpful and it kind of helps automate it as well.We're not going to be doing that.Uh you can look at crawlers here, but we're not going to be doing that in this lesson.So this is what crawlers are and that's within AWS Glue, but we're not we're not going to be looking at that in this lesson.So what we are going to be doing is just creating it from an S3 bucket data.Now we need to call this table something.
So let's call this healthcare and I need to spell health right.Uh healthcare data.I I'm having trouble spelling.Let's go down to the database configuration.Now we don't have a database.So we need to create a database.And this is super easy.Um this is actually the table name.Let's call this um patient data because I want to call the uh the database healthcare data.So I'll call this one healthcare data.I spelled that much better that time.So we've specified here's what our table is going to be called.Here's what our database is going to be called.Now we need to specify our data set.And this is a kind of an odd part and you'll see that in just a little bit.Let's come in here and we have our Alex the analyst bucket.Let's go ahead and click into it.Notice though within this bucket we have two data sets.
I I really only want this one if I'm being honest.I just want this one.But you can't do that.Uh not within Athena and within other parts of AWS as well.This is just a a kind of one of those nuances uh within it.We have to specify a file path, not a file itself.So we have to choose the entire folder.Let's choose this.Let's come down here to the data format.Now this data format that's in here is a CSV.So we're going to come in here with an Apache Hive and we're going to specify that is a CSV file.Of course, we want the delimiter which is right down here to be a comma.So we should be good to go.But because we are not using a crawler, we have to manually enter these column details.So I'm going to come down here.
We are going to pull up this file.Let's zoom in a little bit.These are uh everything that we have.Now we can there is an option in here actually.We can copy all of this and we'll come in here to add bulk columns and you can do it like this and then you can put in the data type and that's perfectly fine if you want to dothat.Uh but we're not going to be doing that.I'm going to actually pull this up.We will bring this over to the side right here.And there we go.So now we can see it.So we have our first column.It's going to be uh patient ID.It doesn't have to be the exact same as over here in the file.Now, this file type is just numeric.So, we can come in here and we'll choose integer right here.
And that's all we need to specify.Now, we have several other columns.So, let's just kind of bulk place them in here.We have name, we have age, we have diagnosis, and we have treatment.Let's see if there's anything else in here.I think we have files.Yeah, one more.So let's add in files.And just to show you, we can do name underscore.Is this their full name?Yeah, full name.So we'll do full underscore name.And we're doing that just to demonstrate that doesn't have to copy this exactly.Um but for the full name, this should be string or text.So we could use char.We could use uh string.See if there's any other ones that we could use.Probably those two.We'll call this one string.For age, it should be integer as well.for diagnosis treatment those are both string so we'll do string and string and then for files this one is integer as well we can make this a little bit larger now there's a bunch of different things that we
can specify different types of compression if you have compression so if you're using a zip file or anything like that you can specify uh that it's sitting in it there is partitioning as well and this is a littlebit more advanced this is a way that you can group specific information together, but this is not something that we need to worry about, especially with our simple data set.There also is bucketing.This is a way to bucket multiple columns together.And then it's stored in a way that when you try to retrieve it, it's retrieved a lot faster and easier.Again, this is a bit more complicated and a little bit advanced.So, we're not going to be taking a look at that at the moment.Let's go ahead and create this table.Now, we're getting this error that says no output location provided.Now, output location is required either through the work group result configuration setting or as an API input.
So, let's go fix this really quickly.We're going to actually I don't want to have to redo all this.So, let's actually duplicate this.Let's go into our query editor and we need to go into this work group.So, let's come over here.Let's go into our workg groupoups and this is our primary work group.Let's come in here and we need to come over to edit.Now within this we had chosen uh Athena SQL and if we come down we have this query result configuration.We have to specify this so that our output and our metadata is put somewhere.So let's go ahead and browse this.Now just like when we chose our file we cannot specify like a file to put it in.We have to specify a file path.Now we're going to specify that this is our path but this is not the best way to do it.
I'm doing this for demonstration purposes only.Uh we'll go back and do it the right way in a little bit.So this is where we're going to put our output, our results, metadata, all that stuff.Let's go ahead and choose this.And uh you can add life cycle uh configuration as well as assign a bucket owner and some encryption, but we don't need to do that.Let's save these changes and let's go back and let's go and create this table.So, it created this for us.The query was successful.Let's refresh this.And it's giving us a default database.That's actually not the one that we put it in.We put it into healthcare.So, let's go over to healthcare.And there is our patient data.You can see we have patient ID, full name, age, diagnosis, treatment, files with the associated data types.And what we can do, whoops.
What we can do is we can come right over here and let's say we want to preview this table.So that is completed.Let's go down here.And the data looks pretty good.We have this one file uh because we have two files.It's reading in that second file uh column names, but we have some data in there.And that's really really good.Now, we're limiting this to 10.And let's get rid of this.But actually uh before we do that, I'm going to keep it the same because before we do that, we need to go look at the ramifications of what we actually did because uh unfortunately it's not a good thingwhat we did.Let's go to our S3 bucket and let's see what data is in this Alexi Analyst bucket here.Now you can see we have a bunch of stuff.It's not just our two files anymore.
Now we have a text file, a text file, metadata, CSV.This is our output and some extra stuff as well as the metadata.And what's going to happen if we come over here and we try to query all of our data.Let's go ahead and run this.Now, you'll notice that we're pulling in a lot of bad bad data.This has completely ruined our query and this is kind of defeated the purpose of setting up using Amazon Athena.What we need is we need a separate folder location within our S3 bucket to dump all this stuff.Otherwise, you'll notice it's just going to keep growing.We're just going to have more metadata, more CSV, more text files.That is not a good thing.So, here's what we're going to do.We're going to create a folder.We're going to call this one uh metadata healthcare.
I think I spelled that right.And we're going to create this folder.Now, I'm going to take all of these things and I'm going to delete them.So, let's go ahead and delete all these files.And we have to specify this.I'm going to do a little cheat.I'm going to copy and paste this.There we go.Let's delete our objects.And those were deleted.And now you can see we just have our uh real healthcare data here.And we have our metadata healthcare up here.Now what we need to do is we have to go back.We're going to go over to our work group and we're going to specify the new metadata folder that we're going to be placing this in.So let's go back down to settings.Actually, it's in the query result configuration.Let's go to browse.We're going to go in here and we're now we're going to specify the metadata healthcare folder.
So, let's go ahead and specify that.Let's save our changes and we'll go back to our query editor.Now, when we run this, let's go ahead and run this again.Now, we have our output.Our data is in there.Let's come up here.Let's refresh this.The data is not in here anymore.Now, it's in this metadata healthcare.And that's great, right?Let's come back here and let's run this once again.Let's come down and you're going to notice something uh peculiar is what I'll call it.What's peculiar is the fact that now we have the same metadata.Now, why is this why is this happening?And why am I showing you this in the first place?It's because when you are specifying a file path, you are not only specifying a file path, you're specifying the folders and the subfolders.So when we come in here and we look at this bucket, if we just specify that we're pulling all the data out of this bucket, then we're pulling not just this data, we're pulling a folder within a subfolder.
And so now we're pulling this data as well.So we need to if we want to keep it all in one bucket, which we can, we need to create a new folder called our patient data.So we're going to click on our file.We're going to click move and we need to specify our destination.So, we're just going to put this in the patient data.So, let's go ahead and choose this and let's move it.And we're going to close this out.Now, uh you'll notice that this data is a Glacier deep archive.So, we cannot move this and we cannot query it.And that's also something that I wanted to mention while we were here.I somewhat forgot this.The data that we are pulling in uh this data down here is only from one file.We don't have two files of data in here.
The only data that we have or that we were pulling in was from this real healthcare data one.We were able to hit off of that data cuz the storage class is standard.But because when we set this up, this was a Glacier deep archive, we cannot query off of that data.And so what we're going to do is I'm going to come back up here to patient data.I'm going to go to upload.So, we have more than one file in here.Let's go ahead and add a file.I'm going to specify this number two, but now we're just going to keep it as is.We're not going to Oh, if we go to down to properties, we're just going to keep it as standard.So, let's go ahead and upload this.There we go.Let's close this out.Now, the data that we're hitting off of is right here.
So, we're not hitting off of this file path.Now, we're going to be hitting off of this patient data.So let's go back.What we need to do now is we need to come back up here and we need to create a new table.So this new one, we're going to do create new table.This is going to be uh patient data 2 and we're going to choose our healthcare data.Now our data set is going to be different.So we're going to go into the Alex analyst bucket, but now we're going to specify patient data.Now, this is important because there are no folders and subfolders underneath patient data.It's just this one folder with our two files in it.When we actually run this and we query off of this data, it's going to go all the metadata is going to go into here, but will not mess up our data source.
And that is very important to understand.Now, often times, just as you know, a little bit of side note, often times when you're working with this, you can either set it up like this or sometimes people and departments will create entire separate buckets just fortheir metadata.So, they can store all their metadata in it and then they can often they just delete it or whatever.So, let's go back here.We're going to recreate this.We're going to go to Apache Hive and we'll do uh CSV.Note, if you do iceberg or delta lake or lake formation governed table, these ones don't have options for a CSV anyways.So that's why we're not looking at it.Um, but for Apache Hive, they do have our CSV option, which is common delimited.Now, we need to go through and we need to specify our columns.Again, I'm going to skip this because you can just do this yourself.
But we're just going to do this and then we're going to create our table.All right, let's go down.We're going to go ahead and create this table.Query was successful.Let's go back to our healthcare data and let's refresh this.So now we have our patient data 2.Let's go ahead and preview this table.And this is looking good.Let's get rid of this limiter.So let's come over here.Let's run this.Now you notice we have 42 results which is because we have uh one right here.This is from file.It's actually file two and this is file one but I got that wrong.Uh, but we have both files in here that we're hitting off of.So, within our S3 bucket, we have two files of exact data and it's creating a union between these.It's reading in both of these files and it's giving us our output.
And of course, we have this right here, which we don't want.So, we can always filter that out.Uh, whoops.Let's come up here.Let's say uh where let's do patient ID.There we go.We'll do is not null.And we'll run this.And now this looks really good.And so now we're querying off of our data and we're not getting any of that metadata issues that we were experiencing.We come back here in our metadata.It's storing all of this.And most of this is going to be pretty useless to most people.And so often times you'll have uh some type of event or something in place to delete this because you don't want to store this long term or most people won't.There may be some use cases too, but most of the time you're going to get rid of this.And so this is Amazon Athena.
Now you can also create views.If you want to tie a bunch of tables together and create a view, you can do that.And of course this is SQL.So you can write uh you know SQL statements like you normally would with any SQL environment or SQL editor.And so if we want to filter, if we want to join uh we can do a lot of those things.And so this is a fully functioning uh quer editor.Now if we come down there are some other things that we have.We can copy this data.We can download these results.We can clear this whole thing.We can also create a table from this query or a view from this query which is really useful.We can also come up here if we want to save one of our queries.We'll come over here to query five and we're going to save as.
And we'll call this one uh filter on nullles.It's a terrible description.We're just going to save that.So we have this filter on nulls.And if we ever want to reference this again, we can uh come back here and we can pull up this query and we'll have it available.Now, if we come over here on this left-hand side, you'll notice we have a notebook editor and a notebook explorer.So, there are options to create notebooks and run notebooks as well.That's something I would create a whole another lesson on because it's not as straightforward as using the SQL option.But another thing we can do which is within jobs right here is we have something called workflows.Now workflows are how you can create different pipelines and different orchestrations with your data and with a bunch of different tools within AWS.This is definitely a little bit more advanced and not something that most people are going to use within Athena.
For a lot of orchestration data flows, data pipelines, you're going to be using Glue.And so within Glue, we'll be taking a look at how we can, you know, set everything like this up.But you can come in here and you can take a look at a bunch of different ones.You can, you know, these are different options.You can execute multiple queries, query large data sets, keep data uh up to date, and you can come in here and there's lots of different uh things that you can do, but again, we're not going to be coveringit, but go ahead and take a look and see if you want to try it out.It can get a little bit complicated, a little bit complex.These are things that people do all the time in AWS, especially people like data engineers, database developers, analytics engineers, people like that.
And so when we get to Glue, we'll look at how to create different workflows, data pipelines, uh, and all that stuff.So with all that being said, this is the meat and potatoes of Athena.Now, who is this for exactly?When I was using Amazon Athena, it was mostly to query data really quickly.A client was giving me a file, put it into an S3 bucket so I could start querying off of it, and that was it.uh most of the time we didn't have a full scale production environment over on this lefth hand side here with tables and views and databases um we kept the data separate of course for different clients and different projectsbut this was not our primary place to go I have consulted and worked with other teams where I come in and they're like hey here's where we're trying to get we're trying to get to this place and I'm
like okay show me your current you know setup how you're working with your data how your data flows work and everything like that and they'll come in and they're like we're only using Amazon Athena for quering data andcreating workflows and automations.If you want to be able to scale to a much larger scale, this won't work.There are several limitations within Amazon Athena.As you try to scale, as you try to add more data sources, as you try to automate all these things, it gets very difficult to do within Amazon Athena.And so that's when you need to start creating different databases like using something like RDS or another type of SQL server where you can store your data, just not within Amazon Athena.hitting off of S3 buckets as your main uh main way to create kind of your database is not optimal by any means.
And so they might work for kind of a smaller company who's just trying to hit off some data, but it doesn't work at scale very well.So Amazon Athena is really good for getting quick insights into your data.It's really good when you have a ton of data stored in S3 and you just want to get simple insights into it, want to do simple joins, aggregations, and you're not trying to do anything too complex with it.This is a great place to go because it's actually very cheap compared to other resources and tools within AWS.This really shouldn't be used as a full-scale database, especially as your company gets larger.You run into a lot of roadblocks, a lot of issues, and I've seen that firsthand.And so, it's just not something I'm going to recommend.But Amazon Athena definitely has its place and that's why we're looking at it because you most likely if you're using AWS, you're working as a data scientist, data analyst, business analyst, you'll use Amazon Athena.
A lot of companies have it.A lot of companies will use it.And so I hope that this was helpful.I hope you're able to get up and running, understand some of the nuances, especially with the folder paths.I always found that a little bit confusing until I just used it more.but understanding how to uh put your tables in to the healthcare in here um and actually get that uh metadata folders working as well.If you liked it, be sure to check out my full AWS and Azure course on analyst builder.com.And if you like the video, be sure to like and subscribe.And I will see you in the next video.
What's going on everybody?Welcome back to another video.Today we're goingto be taking a look at Glue and Glue datab.
Now, within the Glue umbrella, which includes Glue data brew, it's mostly for building pipelines and creating ETL processes.This is how you get data from one place to another.You can extract data, transform data, load the data, and do a ton of other things with it.So, in this video, we're going to take a look at both Glue and Glue Data Brew because they're slightly different and they have different purposes.So, without further ado, let's jump on my screen and take a look.All right, let's go down here.We're go down to analytics.Now, we're going to be taking a look at both AWS Glue Data Brew and AWS Glue.Now, we're going to start with Data Brew because I think it's a little bit more userfriendly.There's some nice animations.The UI is really uh a little bit, I would say, easier to understand.
And this is often a place where you'll come for a lot of your transformations.So, let's come in here and you can go ahead and take a look at a lot of stuff in here.On this right hand side, we have data sets, projects, recipes, uh jobs, and we'll take a look at a few of those while we're in here.And you can look at some of the benefits as well.And uh Glue Data Brew is awesome.It's very much a more visual way to prepare your data.It even says it's a visual data preparation tool.And so it's a way to visualize how your data is changing and you can see how it's changing.We are not going to just create a project.We're going to create a sample project.And this is going to give us some sample data.We're going to work with it.
We're going to be cleaning it up, transforming it a little bit, and then we'll see how we can automate that as well.So let's go ahead and create our sample project.Let's go ahead and select popular baby names in 2020.And then we have to go down here and choose a RO name.Now we haven't talked a lot about IM roles uh within AWS, but for certain things like glue data brew glue and a few other things you need IM access.So you can say create new IM ro and that's what we're going to do.Let's go down here and we need to actually create um a new role for AWS Glue Brew Service.So, it's going to create and I'll explain that in just a little bit.We'll call this one Alex the analyst and I'll call it data brew.Let's go ahead and create this project.
Now, this needs to set up our session.It's provisioning some compute and getting our session ready, getting our data ready, all of these things in order to use data brew.But while we're in here and while we're waiting for this to uh be ready, I want to talk a little bit about the UI.So over here we have something called a recipe.Now the recipe is for when we actually use all of these things and we apply different changes to the data set, we make any transformations, whether we join the data, we group the data, we pivot the data, it'sgoing to say, okay, you did this and then this and then this and then this.And you can come in here and you can edit this.And so you can say, oh, I don't want to actually group it.Let me get rid of that.
And that'll be really easy to do and I'll show you that in a little bit.But then we can also save this recipe.We can just say, "Oh, I want to save this for a future data set."Or if you want to use that recipe on, you know, if you're bringing in multiple uh data sets of the same exact data or you have multiple uh data sets coming in that are all the same, then youmay use the same recipe on all of them to transform that data consistently every single time.Looks like our data is done or our session is ready.But let's look at this top area.So, this is where we can make all of our transformations.We can filter, we can sort, we can come in here and we can click on the clean.And you'll notice there are tons of different options in here.
A lot of ones that you should be pretty familiar with if you've ever cleaned data before or if you've ever done any of my projects in my SQL or Excel or Tableau or uh you know, Python and allthese different ones on data cleaning.And these are a lot of really popular things in order to clean the data.So there's clean, extract, uh you can look at duplicates, outliers, you can merge your data, you can perform functions, you can apply different functions to your data.We also have things like pivot, group, join, union, and others.And there's just a ton in here.Now, what we're going to do is first we're going to look at our data, and then we're going to go through and we're going to do a few changes to it so you can see how the recipes workand then we'll save our recipe.
So let's come in here.This is a new data set to both of us.This is our uh baby names data.So we have count, we have gender, we have the ID, we have the name, and then the year.And so this is pretty interesting information.Let's see if it's all uh 1880.This looks like just a small sample of the data.And we can come in here and we can also uh take a look at what kind of data types they assigned to this data as well.Now, what we're going to do is something quite simple.We just want to look at the male names and we want to take a look at the most popular male names per year.So that's going to require a bit of grouping.So we're going to have to group on both the year and the name and then we're have to filter based off of the gender.
Now one other thing to note is that right now we're just working with a sample of the data.when we actually get to the final process and we actually create this data cleaning process.We can apply this to the entire data set or we can apply it to the sample.So right now we're just going to be working with this sample, but we'll of course be using the full data set later on.And you can even come up here and you can look at this.You can say first n rows, last n rows, and random.Now, right now we're just looking at the first n rows, the first 500 rows of our data set.And that may not be a perfect sample size.It actually may be better to pull random rows because what if we have male or female or other things.Right now it just looks like we have female in our sample and that may not be representative of the entire data set.
So let's come here to random rows.Let's choose 500.We're going to load this sample.And as you can see we do we do have males in here.And so I'm really glad we did that because now we kind of have a better representation of our data.And so I think what we need to do let's bring over our recipe.I think what we need to do or what we're going to do is one, I want to filter where the gender is equal to male.Then we're going to come over here and we're going to try to find the most common name per year.Or maybe we'll just group by the year and the name and do a count on the name.I think that would be really interesting.So we're really transforming it quite a bit.So what we're going to do is we're going to filter on this gender.
So we're going to go over here to filter and we're going to go down to by condition.Now we want to say where gender is equal to male.So you can either do contains and we can do contains an M or we can say it is exactly.Either one of these will be perfectly fine.We're going to do that on gender right here.So we have 300 females, 200 males.We don't want the females, so we can get rid of that one.We're going to only keep the males.We can also enter a value in here.Uh but we don't need to do that.And so now this is ready to go.We're going to go down and we can either preview changes, but we're just going to go ahead and apply this.And as you can see right here in our recipe, it says under our applied steps, we have filter values by gender.
We can either edit this or we can delete this.So, at any time if we want to change any of this, uh, we can do that.But, as you can see in our preview in our sample, we now only have 200 rows and it's all filtered by males.Now, what we can do is we're going to group this data.We want to do it based off of the year and the name.So, let's come up here.We're going to group and we need to select our columns.So, we're going to start with the year and we're going to group by the year.And then we're going to select the name as well.And we'll come down here and we'll say group by.But we also wanted and you'll notice we also wanted to aggregate these values.So, we want the count.So, what we're going to do is we're going to come in here and we're going to say based off of the name, we want a count of the names for that year and name.
So, we're going to do a count here.And so, for this new column, you can call it the name count, and that'll be perfectly fine.This is uh just like an example down here.But it shouldn't be a string.This should be an integer.And so, if we come down here, let's see.There should be some that have multiple um higher than one, at least not in our preview.But still, we're working on a sample here.So, let's go ahead and finish this.And now we have our data right here.Now, again, this is only working off the 200 rows.We could have 100,000, 50,000 uh in our data.But we grouped off of the year and then we grouped off of the name and then we got a count of the name.Now, what we need to do is I also want to filter or sorry, sort on this year and we can do that uh just by sorting here manually.
So we can come over here and it's just going to do this within our uh window.But I actually want to apply a sort to here.So I want to do this ascending.So the smallest year to the largest year.We'll do this based off of the year.Then we'll come down here.We'll click apply.And now we have our years over here in ascending from smallest all the way down to largest.So now that we've applied all of our steps and really transform our data on our sample data set, let's go ahead and save this recipe.We're going to go ahead and publish this.So you can add some notes if you would like.We're going to publish this.And so now we've saved that recipe.And in fact, if we come over here to recipes, you can see that we've saved this.So we have that available.
If we go back to our projects, we can come up here and we can create this job.So we're going to call this one the uh name aggregator.This is the data set associated with it.And we can choose our output.So, where do we want this output to be?Let's put it in S3.Uh, we can keep it right here.Let's go to our S3 location.And let's just put it in the Alex the analyst bucket.Let's select that.And we have some additional options down here.So, we have some advanced settings.One, the maximum number of units.So, that's to do with how many nodes you want on this job when it actually runs.You can specify if it times out or how many times you want it to retry it.This one is probably the more important one is if you want to schedule this right here.
So you can come in here and you can create a new schedule and you can specify I want this recurring every and this says 1 hour but maybe you want it recurring or doing on a specific time ofthe month and you want to automate this and run this maybe every week or every month and get an output of the data that you have.So this can be really really useful.You can add tags for permissions.We just need to specify our role and we can create and run this job.This is going to take a little bit to run because it's going to be working in a much larger data set.But in a little bit, it's going to run this entire job.It's going to output our CSV into our S3 bucket.And then we're going to go and take a look at it.
So, let's go over here to jobs and see its status is still running.Let's wait for just a little bit.And it's going to be doing that on the entire uh project.that's not just going to be doing that on the sample.It's using the uh full data set.And so let's wait for this to be done and then let's go look at our output.As you can see, it succeeded.It took about 2 minutes.It finished up very quickly or just a second ago.Let's come up here to our S3 bucket and it should be right in here.So let's go ahead and refresh this.And now you can see we have this new folder name aggregator.Let's click in it.And now we have all of these CSVs.Now, this is to be expected because this is the default option within Glue Data Brew.
I personally do not like this.I want a single CSV output as I'm sure most of you do.Let's come back up here to our jobs and let's go into this name aggregator.Let's come over here and we're going to select edit job.And now we have right here.This is our uh job that we just created.Now, what we need to do is get rid of this.So we need to go to settings because right now for file partitioning we have file output options autogenerate files default file output setting that generates multiple files.This usually results in the fastest job runtime which can be important uh for some use cases especially as you scale your company or your business or your department.You know these things do matter a lot but for what we're doing we want a single file output.We also have an option out here for our file storage where we can create a new folder for each run or replace output files for each job run.
We'll keep it the create, but depending on what you're doing, uh you may want to replace it as well.Let's go ahead and save this.Then we're going to come down here and we're going to save it as well.And now we need to actually run this.So now we're going to click run job and we're going to run the same one except as a single file output.Let's go ahead and run this.Now it's going to be running.It's going to take a little bit longer than the minute 37 seconds, but hopefully not by a lot.So, let's wait just a little bit and then we will see what it looks like in our S3 bucket.All right, this succeeded and somehow took less time.Uh, so AWS is just messing with us right now.They're lying to us completely.Let's go back to our bucket.
We're going to come back just to the bucket.Let's go ahead and refresh this.There's our next one.I think this is the second one.Uh they have different names obviously because we didn't overwrite.Let's come into here.And now we have our CSV.You can go ahead and download that.And in fact, I'm not just going to tell you to download it.I'll download it, too.So, let's come in here.Let's go and download this.All right.Let's open this up.And let's take a look.So, let's come over here.Let's filter this real quick cuz there's a lot in here, I'm assuming.Let's come over.And it looks like there's only one only most common name per year.Uh, apparently I completely misunderstood the data.Uh, this is probably what they did was they took they told us the most common year or the most common name per year.
Um, and I just wasn't thinking about it.So, I think we misunderstood the assignment.Actually, you know what?I'll take the blame.I'll take the blame.I misunderstood the assignment.But, we do have 25,779 rows.Uh, and so, you know, just a little example of how to use it.Although I'm not an expert on that data set.So, uh I take full blame for that.But you can see the process that we took on how to clean the data, change the data, and get a correct CSV output.Let's go back over to AWS.Let's go back to our analyst bucket, and we'll stick right here for just a second.Now, one thing to note, and this is something that you may, some people may have encountered when they were trying to run this job.It's it may say, oh, you don't have access or the ability to do that.
You may have gotten an error in some way.What you may need to do, and this is something that uh my friend Cassoon over at Analyst Builder, he helped me understand, is that sometimes AWS doesn't give you full functionality until you have certain services running like anEC2 instance.Now, we're not covering EC2 instances in this series, but you may need to come in here into the EC2 and you can just go to services, go make sure to go to EC2, you may need to just launchan instance and just launch it.And what happened after I launched it was it sent me an email and said, "Hey, you now have full functionality for different things.It's super easy.You just come in here, make sure you select your uh pair.You can just say you don't want one, and then you launch an instance."
And that's it.And after that, you'll hopefully within a few minutes or, you know, within the day, you'll get an email saying you have full functionality.You may need to do this.That's just something I want to make mention of because I know I encountered that when I first did it.Now, I had never encountered this before because I've used it in a workplace where somebody already had all this stuff set up, right?We this was a fully functioning production and development environment and so I didn't have to worry about this.But this is a completely new account.And so this is a free instance.You know, you don't have to spend money on this because you get two EC2 free tier offers and you can use those and it should uh be good to go.And you need to do that for what we're about to do in just a second.
Um, but just wanted to mention this.So that is how you can use glue datab.Uh and of course I want you to get in here.I want you to take a look at a bunch of this other stuff.You can create rules as well for invalidating your data and you can send yourself emails.Uh if you know it doesn't look good.You can come in here and look at all your data sets that you have.This is the one that we were using the data set national baby names.And of course you can always connect to new data sets.So if you want to come in here, you want to pull data out of an S3 bucket or from Redshift or you know other options within AWS, you can do that.So all really really good stuff.Now let's go back.We're going to go to all services and let's click up here.
We are going to go all the way down to Glue.Now here's what I'll say about Glue before we even click into it.Glue data brew is very visual.I think it's actually fairly easy to use uh compared to glue.Glue, I think, is a little bit more complicated.Um, not entirely, but it is.Um, and so let's look at glue really quickly.Now, over on this lefth hand side, we have a ton of different stuff.Um, and we're not going to be looking at everything in here.I'm going to look at kind of the more important things, but we have something like a data catalog.And this we looked at in our lesson with Amazon Athena.They have the data catalog to set up your databases and tables and your schemas.And we had crawlers.Now, this is the first thing that we're going to look at within Glue because this is how you can kind of automate pulling in data, getting the data types, and pulling in that data.
And so, it's really useful.The next is creating ETL jobs.So, those are the two things that we'll be looking at in this lesson.There's a ton of other things that it does.So, be sure to get in here and just check everything out because uh Glue does a lot of different stuff, and I'm just not covering everything, of course, because, you know, this would be a 10-hour uh lesson.So we have a few different things.One, you can prepare your account for AWS Glue.Here's your catalog for your data sets.And then here's how you move and transform your data.And so what we're going to do is we will need to set up ROS and users.We're just not going to do it right now, but we will need to set that up.And I'm actually going to show you some of the IM uh you know on the back in the IM uh resource how that actually looks.
But let's come over here to crawlers.And we don't have any crawlers created, but we need to.Let's create a crawler.And let's create this.And we'll call this the uh Alex the analyst crawler example.Let's go ahead and click next.Now, we need to specify our data source.Now, just let me back up one second.You know, we want to pull in data to be able to use it in different services, and we want to do it kind of automatically, like I mentioned.And so let's say we're pulling in data and we want to put it into a database or we want to pull in data and we want to put it into Athena.These are things that we can automate.And so uh we want to specify a data source here.So let's go ahead and add a data source.We have our S3 bucket.
That's what we want to do.And this is data that we used in previous lessons.So if you didn't take those lessons, be sure to go and do that.So we're going to browse this data.Let's go into the Alex analyst bucket.We're going to go into patient data.We can specify single files but let me just tell you it won't work.Um and you know that's just because of how the folder system works within glue.So we need to specify the entire patient data folder.Let's go ahead and choose this.And now we have on subsequent crawler runs crawl all subfolders subfolders only.If you add new subfolders to your folder then based off of an event.So an event would be like something triggering and then you uh it runs based off of that.So, we're just going to do crawl all subfolders.
Let's add this data source.Let's go ahead and click next.Now, this is the part where we need to select an IM RO.We don't have one.So, let's go ahead and create a new IM roll.I'm going to call this Alex glue crawler roll.You can call this anything.Let's go ahead and create this.And it says it successfully created it.Let's go ahead and view this.
So now we're in a totally different part of AWS.This is the identity and access management.That's our IM.So right here we created an IM role.This is the Alex group.This is the Alex Glue crawler role.And then down here we have the permissions policies.So right here this is going to be giving us access to I believe the S3 bucket.We can come in here and actually look at the policy.So the permissions are read and write on a specific uh data source and that's going to be our bucket with the patient data and I think we can come up here to policy versions.Look right here and so this is what it looks like inside of it.Now this is in JSON and you can actually customize these and I'm not going to go into all how to do that but sometimes you need to depending on the data the data source if it's encrypted if it's
not um what permissions you want it to do.But what this is doing is it's allowing us to get an object and put an object in this specific resource.So that's our patient data and that star is just a wild card to say anything in that file path.So if we go back and let's come back to this role.We also have this AWS glue service role.Now this one right here we created when we created the crawler to specify the file path of the data set.This is AWS manage.This is one that AWS creates themselves and we can look at all the things.Let me scroll down.We can look at all the things that it does uh for that AWS Glue service role.Gives us access to a ton of things for EC2 instances, S3, everything within Glue.And we can come down here and take a look at the buckets, the access to S3 as well as a bunch of other stuff.
And so this is what the IM roles look like.And you can create custom policies uh if you want to.And you can give access to different things.And so again, we're not covering this entirely in this lesson because this is not a lesson on IM roles, but I think it is interesting and worth uh worth knowing.So we've created our role.Let's go down over here.Let's click next.And now we need to specify where we're going to be putting this.So we're going to put this data in our healthcare data.So this is our healthcare data.Again, we already had created this database back in our Amazon Athena.And we have the option to uh create a table name prefix or use the maximum table threshold for the prefix.Let's just say uh crawler.There we go.And now we have this crawler schedule down here.
Now you can do it on demand or you can specify whether you want a specific day of the month, whether weekly, daily, monthly, whatever you need.You can create this uh scheduleuler in order to run this crawler.Let's go ahead and click next.And let's just review this real quick.This is everything that we chose.We're going to go ahead and create our crawler.So now it says one crawler was successfully created.It's this one right here, Alex Analyst crawler example.And uh it has not run yet.So we've have no crawler runs.But let's go ahead and run this crawler.So now we're going to start the crawler.It's going to start up this that we just created to pull in that patient data.And once it is completed, we're going to go take a look at it in Amazon Athena like we looked at in a previous lesson.
So right down here it says it's running.So once that's done running, we're going to take a look at that data.All right, it says that was completed.Now we can come back here to the data catalog connections.Let's go ahead and refresh this.You can see we have our crawler that's our uh prefix that we used and we have patient data.This patient data and patient data 2 were data cataloges and part of our data catalog are tables that we created in Amazon Athena.Now let's come up here.Let's just duplicate this really quickly.We're going to go back to Amazon Athena.Let's see if it's right here.So, here we go.We have Athena.And now we can access that data right here.So, now if we want to, I can say, uh, let's just preview the table.It's running.And we have our data in here.
And so, this is perfect.Um, if you remember, we had our patient data and patient data 2.We manually entered that data to pull that in.And that was not super fun.So when we created it, we did it from an S3 uh bucket data.But with the AWS glue crawler, we can do this automatically and then it'll refresh our data and we can create this uh without having to manually do this every time we get a new data source, which let metell you, when you start getting into a production environment or a development environment, whichever one you're in, when you have to start bringing in lots of data and the data is coming in daily or weekly or monthly, youdo not want to have to manually do this.It takes up so much time.It is much better to automate this with an AWS glue crawler.
So that's during that scheduling part right in here and we come over to crawlers.We come in here.This is just on demand, but we can edit this and we come down here and we can schedule it down here if we want to.But you can also now we have it on demand.So anytime we want to run it, we can also just run it on demand.Um so it's, you know, really really great to have and use.So that's how we use crawlers.And crawlers are amazing.Oftentimes, if you're using this in your work, you're going to have tons of them, like 50 to 100 of them um running, and you'll be scheduling them, and some of them will break because a data set changed orwhatever.Um and so this is a really great thing to test out, try with different data sets, uh and really get familiar with it because crawlers are amazing.
Let's go down here.Let's go to ETL jobs.So, this is the last thing that we're going to be taking a look at in this lesson.There is of course more to AWS glue, but this is kind of like the two most important things I would say.So, let's go over here to a visual ETL.And what we're going to do is we're going to build out I don't think I have an unsaved job.We're going to build out um our very first ETL job within AWS Glue.Now, what we have here, and I'll talk a little bit more about this in a little bit.We have parent node, and we have uh the child node.I think it's node if that's the right term, but we have parent and child uh different nodes that we have in here and we need to make sure we chain them properly.
Now, luckily we have this ETL visual tool and that's what we're in right now is be able to see what we're doing when we're in here.Now, let's come over here and let's go back to our sources because we have to have a source to start out with.So, let's go to Amazon S3 and we're going to click into this Amazon S3.So, we're going to pull data from our Amazon S3 bucket.We need to specify our location and we can either make it recursive or not recursive and I'll explain that in just a second.Now, let's come in here.We'll go into our bucket.We'll go into our patient data.Now, let's specify just this first file here.We really don't need recursive because I don't have any sub directories.So, we can turn that off or you can keep it on.We also have a data format.
The our data format is not uh no format.We have a CSV format which is commaepparated.Now what it's kind of prompting us to do down here and I highly recommend doing it is getting a data preview.So we can see the data as we're transforming it and changing it.So I am going to come in here and I am going to specify this role that we had created earlier.And we're going to start this session.This could take just a little bit of time but we're going to get a data preview down right here at the bottom.And now our data preview is ready.We're looking at uh this file right here.Next, what we're going to do is we're going to come over here to add a node and we're going to go to transform and we're going to join.Now, we have to specify uh a few things here.
One, we can name this.So, it's just called a join.Next, our node parent, and this is what I was talking about before with the parents.So, this parent is our first data source, which is just called Amazon S3, which we could change.We can come in here.We can call this uh patient data one.We can call this patient data 1.Then we'll come down here and go to the join.And notice if you come in in here, we only have one data source.So we need to specify a second data source.So let's come back out here.Let's come up.Let's go back to our sources and we'll pull in our second one.I'm actually going to change uh this view really quickly.I like it going left to right, but some people like it going up to down.Um, you can just do that using this button right here, which is the direction, but I like this direction a little better.
So, we're going to come into this bucket.Let's call this patient data 2.And let's specify our other patient data, which is our second, which is number two, which actually says file one in it, but you know, just ignore that.Okay.Um, we are going to do that right there.We already have our preview.And now we need to go back to our join and specify these are the two things that we are joining together.Now if we do uh an inner join, it's not going to work cuz these data sets are extremely uh familiar.In fact, if we come in here and look at the data, there aren't any patient datas to join on or patient IDs to join on.Um they're all unique.And so what we're going to do is we should actually be doing a union here.Let's actually get rid of this.
You know what?That was my mistake.Let's go to transform.Let's come down.Let's find a union or let me search for it.So, I'm going to do a union.So, we're going to do a union right here.There we go.And let's go into our union.And we're going to specify our parent nodes.We have boom and boom.That's one and two.And it's going to be working on this data preview.There we go.Let's scroll down a little bit.And now they're all in there, which is perfect.That's exactly what we want.File one and file two, which is actually file one and file two.So, we are good to go.This is looking really, really good.Let's come back here and let's take a look at what comes next.So, we've uh created our sources.We had two data sources.Let me pull this over here.
And I can't pull this over anymore.Um, but we have our data sources.And again, you can pull this data in from anywhere.We've done one transformation.Now, we can do other transformations as well.We can even write a SQL query.We can look at uh filling in missing values if we need to.We can aggregate our data, drop duplicates.These are a lot of the different things that we looked at in Glue Data Brew.Um, and there's even more options uh in here as well that are kind of unique to Glue.But lastly, what we need to do is then we need to specify our target location.Where do we actually want this data to go?And so we can put it into things like an Azure uh SQL database.It could go into Snowflake.and go into a SQL server, Postgrace, MySQL, Redshift, or we can just put it back in an S3 bucket, which is by far uh the most simplest thing you can do.
We could also take this data and put into the glue data catalog.And so, if we want to use this in Athena, we have a much, you know, bigger process and then we want to put it into or query that data in Athena, we can do that.So, there's a lot of different places and things that we can do.Let's just come back and put it into an S3 bucket because that is going to be the simplest thing to do.So we have our process and there at the very end we're going to put it into a CSV file.We don't need any type of compression here but uh we do have an option data catalog update options.Let me zoom in while we're here.We have our data catalog update options.So we can create a table in the data catalog on subsequent runs update the schema and add new partitions or we can create a table in data catalog and on subsequent runs keep existing schema and add new partitions.
So, I'm going to click on this one right here.And we'll specify our database.That's going to be our healthcare data.Our table name, we'll call this one uh the ETL.I'll do underscore patient data.And then we'll come up here for our S3 target location.So, we're going to come back.We'll just place it in the Alex the analyst bucket.Let's go ahead and choose this.And we have a fully functioning ETL process.We took two data sets, we union them together, and then we have our output.And of course, we can see every step of the way what we're doing here.Now, if we wanted to uh because we already have this full process, right?If we wanted to, what if we wanted to add in an extra part?Let's say we wanted to come in here and we wanted to transform this union.
Let's do an aggregation.So, we wanted to perform an aggregation on this.So, let's go to aggregation.Now, this doesn't look right.Right.We can't union it and then aggregate it and also send it out.Well, we can, but it doesn't really make sense for what we're doing.So, what we're going to do is let's say we want to union on maybe a diagnosis and look at the average age or maybe a treatment.Uh, could be anything.But let's come down here.Let's click on this aggregate.What we want to do is we want to put it where this is its parent.And then for the S3, the new parent for this is going to be the aggregation.So, this is correct because you can see we have this line flowing here.This part is correct.we will need to aggregate it in just a second.
But we need to come up here and we need to change this parent node to the aggregate and then get rid of the union.And so now we've changed our workflow here.We've changed the ETL process.So now we need to go to aggregate.Now we're going to come over here and we need to be able to aggregate our data.So we have to uh select the fields to group by and we have to perform our aggregation on a specific column.But when we come in here, notice all of these are string.We have string, string, string, string, and string.And that's not correct.Uh that's actually incorrect.What we need to do is we need to come in here and after this union, we need to add an additional step.That's going to be our change schema.And then we'll select this aggregate real quick.
And we're going to put it on the change schema.There we go.So we're just adding multiple steps here, but we need to specify what our data actually is.And we can see when we make the change what'll happen.So we can keep this or we can make this an integer.The uh name is going to be a string.The age needs to be an integer as well.We have string for both of these.And then a file needs to be an integer.And so this is looking really really good.Everything should be working properly.We shouldn't have any mistakes.Um, often times it'll, you know, show all blanks if you're doing something wrong.So now we can come over here to our aggregation and say we wanted to do this based off of the diagnosis.Then we come down to here.This is the um aggregation.
Which field do we want to aggregate on?It's going to be on age.And we'll just do let's do an average.Just keeping it simple.So now this is good.And we can even take a look at this right here.So this is our data that we're going to be outputting into a CSV file.And then for our data target, we've already specified everything that we need.And of course creating the data catalog as well.So this is ready to go.Let's go ahead and uh let's go over to job details just really quick.We want to change this.We're going to say uh first ETL.There we go.We can come down here and there's a few different things that you can change if you want.You can change the type of job that it's going to be.You can change the glue version, the language, the worker type, bunch of different stuff in here, but I don't recommend uh you doing any of that if I'm being honest.
The other thing while we're in here, and I'm just going to mention this, although I'm not going to show this to you uh because this gets quite complicated.I do cover this in the AWS and Azure course on Analyst Builder, but it gets a little bit complicated in here.But this is the code that's being generated from your visual.So this visual is actually writing uh to AP py file.Now you can get in here and change a lot of things.Um and actually it's helpful if you want certain functionalities to get in here and change these things, but we're not going to be doing that in this lesson.I just wanted to show this to you.If you want to edit the script, you won't be able to use the visual ETL anymore cuz that's for kind of simpler visual things where you're doing it exactly how they have it kind of made for you.
But if you want to go and start doing custom things, which you can do, and it's pretty awesome, you're just going to have to confirm this, and then you won't be able to use the visual anymore.So, just be warned.Uh that is uh that is something.So, job has not been saved.Let's go ahead and save this.This is our first ETL.We successfully created this.And now, we need to run this.So, let's go ahead and run this.Let's go to our run details.This process is running, and we had multiple steps of our first ETL uh job that we created.Now we're going to let it run and then when it's done running we'll take a look at the output.It looks like our run failed this happens.Let's see what actually occurs.It says an error occurred when calling the py write dynamic frame access denied.
Um so let's go back.Uh let's go to visual.Let's go see which role we actually took.Or maybe uh that's in a different place cuz maybe we need to go to the im and give uh different uh different options here.And here we go.So now we have this AWS uh glue service ro.Let's come over here.Let's go in and actually look at this glue crawler ro.Maybe we'll give it admin privileges uh just for this example, though you probably wouldn't do that in real life.But let's go over to uh let's go let's go to the EC2 cuz we don't need that one.Let's go to the IM.So let's go back to all services.It should be right over here.Yep.In the security identity compliance.Let's click into here.Let's go to our rolls.And it should be this Alex glue crawler roll.
Let's make sure that's the right one.Alex glue crawler roll.So, let's go into this Alex glue craw crawler roll.It's tough to say.Um, it is possible that we didn't have the correct access.So, let's go into I guess we we are getting um we're getting a lesson in a little bit in IM.We're going to attach a policy to this.We're just going to give our guy straight up admin access.So, we're going to say uh admin.Now, there's a bunch of different admins in here.There should be one just says admin full access.Maybe it's this one.Yeah, it's allow everything.So, this is the one we're looking for.So, we're just going to attach this policy to this person.I think it was an S3 uh thing.I think we just didn't have access to the correct bucket or something.Um I'm not 100% sure, but this is saved.
It was attached to the RO.Let's go and try to run this again.So, let's go.Um there's our visual, but we can just run this again.Then we'll go to runs and hopefully this will not fail again.If it does, we'll try to work through it, right?These things happen.This is very common.So, let's go ahead and give it a go and see if this one works this time.And just like that, we figured it out.We always do.It succeeded.Um so, it's just a permission issue.And uh believe it or not, that is extremely extremely common.Um so, that succeeded.Let's go over here to our query editor.Let's go ahead and refresh this.We have our ETL patient data.Let's go ahead and preview this table.Now, it's being separated by commas.It didn't uh doesn't look like it separated out exactly how we wanted or maybe we did it wrong.
Uh I'm not sure, but it's in there.It's just not in the right format.So, that's something you can definitely fix.Let's go over to our bucket.Let's go right here and refresh this.If we come down here, we have a ton of these really tiny files, like 21 bytes.Uh, really, really tiny.Let's go down to the bottom.This unsave.Let's see what this is.We have these CSVs in here.Let me let's go into this really quick and let's download this and let's open this up.And so, this is our original data its.So, this is part of the original uh data set.This is not part of our actual output.Let's go back.
If we come down here, let's take a look at any of these.This is just part of the run object.And so that is not a file.And let's scroll down.So we're getting this really weird output.Let's actually go back.Let's go back to our visual.And so for the format, we chose CSV, which should be fine.uh we have compression type as none but maybe we need a compression type and then we putting this in the healthcare data and so maybe we don't want the CSV type or maybe we need some type of compressionmaybe we need to zip this up so let's try doing this in something like a parquet file really great file maybe we want to put in a snappy compression feeling wild um I'm going to keep it like thisjust for now let's try it but it looks like we need to aggregate this properly and so let's Go back in here.
Let's choose diagnosis.I guess it forgot what we were doing over here.We'll do age aggregate function is average.And now that's working again.So let's go over here.Let's uh try a parquet file.Let's save this.And then we are going to run this.Let's come over here to run details and let's let that run and see what happens.It looks like this one failed.Let's come back over here.Looks like we may need some compression.Let's go back to our visual.Let's add snappy compression.Although I'm not a fan.Let's go ahead and save this and let's run this and let's try again.All right, this one succeeded.Let's go down here.Let's click refresh really quick.Go down to our patient data.Actually, we have it right here.Let's go ahead and run again.Let's go down.Still doing the same thing.
Let's go to our S3 bucket.I should have cleaned this up first because that's just going to keep getting messy.But if we scroll down, now we have all these parquet files.Now, this is still a lot better than what we had because now we can pull in these parquet files and we can join them together.And that's just kind of a typical run with an ETL job.Um, and so this is actually a lot lot better.If we want it all in one file, unfortunately, there is not a very easy way to do this.We can come in here and go to Amazon S3.There's not really a great way or an easy way to be able to do this.And so what you need to do if if you want it all in one file or you want it in a specific format, you have to script it out yourself.
Um, again, it's not crazy hard to do once you've gotten in here and you kind of understand a little bit.But if you want to be able to do some of these custom things within using ETL, this is how you do it.Um, within the visual, it kind of limits you.So this would still be good.this type of ETL process um would still be perfectly fine because it's just going to append all of this uh data if you're putting into a database or something like that.That'd be perfectly fine.And so not as clean of an output as data brew was when we were working with these ones up here, but we are able to do different things that data brew isn't able to do within Glue Studio.And so this is how you use it.This is how you create these ETL jobs.
Sometimes you got to get in and you have to customize a little bit to get the exact output that you want or are looking for.Um, but I'm going to have to come in here.I'm going to clean this up.Uh, because this is a mess now, but this is how you use uh, glue and glue data brew.Once you get in here and start trying it out and messing with all this stuff, you'll understand, right?As you start using it more, this is not uncommon.This actually happens all the time and is not a bad thing if you know how to use the data correctly.Now, like I said, there is a ton more to AWS Glue than just these two things, although those are kind of uh some of the bigger things that I wanted you to know how to use, but there are
things like workflows and triggers and things like schemas.And these are of course the most popular ones.So, make sure to know these ones and we covered some of them in this lesson.But Glue is very expansive and you're going to use it for a lot of different things.Now, if you're a data analyst and you're working on something like a data collection team, uh, which is something that I worked on for many years, then you might be getting in here and using this quite a bit.But if you're just a data analyst and you're waiting for the data engineer or database developer or whoever's, you know, bringing in this data, if you're waiting for them to bring in the data, most likely you're not goingto get in here that much.You might inform them.You might say, "Hey, I was looking at the data.
Uh, the data looks bad or there was something wrong with it."So, you're looking for quality issues immediately.Then you'd relay that to a data engineer and say, "Hey, could you go and check out that job that brought in that data and then they would go and check it."That's typically how you know that would actually work.So, just something to be aware of uh with Glue.But, uh, Glue, Glue datab crawlers, as well as ETL, all stuff that I recommend you testing out, trying out, figuring out how it all fits together and works.With all that being said, that is the end of the lesson.If you haven't already, be sure to check out my AWS and Azure course on Analyst Builder.I go a lot more in depth into Glue and everything in it.We even create some custom scripts in here to put it all in one file, which is really uh useful to know how to do.
So, if you're curious about how to do that, be sure to check out that course.If you have not, be sure to like and subscribe below, and I will see you in the next video.
23:43:05 - 23:43:11
What's going on everybody?Welcome back to another video.Today we're going to be taking a look at Quicksite in AWS.
Now Quicksite is AWS's data visualization tool.And so a lot of companies when they get into AWS's ecosystem, they have really simple needs for their data visualization and they just use the internal tool which is QuickSite.It's not the most robust tool you've ever seen in your life, but we're going to take a look and see how it actually works and I'll make a lot of comparisons to things like PowerBI and Tableau which arereally popular data visualization tools.So without further ado, let's jump on my screen and take a look.I'll scroll down.Let's go to analytics.And under the analytics, we have Quicksite right here.Now, in order to get started with Quicksite, we actually have to create an account.So, we have to sign up for Quicksite.So, let's go ahead and say sign up for Quicksite.For the authentication method, we just want to use the IM federated identities.
You can uh use some of these other ones if you'd like.Be sure to specify your region.Make sure you fill out your account info.And then down here, you can uh use an existing role or you can just use the quicksite manage role.Highly recommend just using default, much easier.and allow access and autodiscocovery for these resources.So, if you want them to be able to use your S3 buckets, be sure to click on your S3 bucket and we can say uh here's the bucket we want.Uh, you know, maybe I'll just choose both of them, but here are the buckets that we want you to be able to access as well as all these other things as well.And then we'll come down here and we don't want pageionated reports.And then we'll click finish.So, now it's creating our account and then we'll get access in just a second.
All right, that took about 10 seconds.This is the name that I gave uh our account for Quicksite.And let's go ahead and go to Quicksite.This is what's new in Quicksite.Let's go ahead and close out of that.Now, this is the UI for Quicksite.Now, just before we get into, you know, creating stuff and building stuff and all these different things.I just want to talk about Quicksite in general.This is AWS's tool for data visualization.And of course, there are other options.There's PowerBI, there's Looker, there's uh Tableau, there's lots of different options and all those are perfectly acceptable.And in fact, in some instances, they may be better for some things, but within AWS's ecosystem, this is their BI data visualization tool.And so, because it's already integrated into all their services, it does make it a little bit easier to use than some of the other ones.
Um, and that's what they're hoping for.They're hoping you use their services and stay in their ecosystem.So you don't have to go anywhere else for any service ever because AWS wants your money and your business of course.Now within Quicksite you can share reports, you can create folders that you can uh share with customers and clients.You can create dashboards.You can of course create stories.We have analysis data sets and topics.And then over here we have some sample analysis.So these are different um things that they've already created visualizations for.But the first thing I want to show you is right over here in data sets.Now these are the data sets that we already have access to.Sales pipeline.Uh let's just click in on one.We get a very slight overview of kind of what this data looks like.We can refresh this data.
And so if we're connected to a data source, we can refresh this or we can schedule this.And then we can look at permissions and usage for people who have access uh to this data and how they can use it as well.So just some interesting things within data sets.If we want a new data set, we just come in here and we specify where we want to pull in our data.Whether it's an S3 bucket or we want to upload a file or it's coming in from Athena.There's a lot of different places uh that we can pull it in.There is something up here I just want to note.We're not actually going to be pulling in any data for this.We're going to be using one of their samples just for demonstration purposes.But there's something called SPICE in here.Spice actually stands for superfast parallel in-memory calculation engine.
and it's used to do things really quickly in Quicksite.But for example, let's just say we were uh uploading a file.We can choose uh SQL database output.I don't even know what's in that file.Let's see what the preview says.Okay, we have some products.This is our products file.But let's say we select next.We want to bring in uh this file.It's going to import it into SPICE.And so that's going to cost money.That's going to put it into their super fast parallel in-memory calculation engine.and then you were going to pay for that service.Now, that isn't always the case.We don't have to uh we're not going to do that.We're not we're going to cancel that import.But you don't always have to do that, especially if you have other types of data connections to like my SQL or Postgre SQL.
You may not need that.But just be aware of what that is cuz that does cost money.Let's go up here to quicksite.We're going to come on back and let's take a look at some of these samples that they have.Let's go into this sales pipeline analysis.So right now we're working with sample data and we're not going to be doing a full project in here in Quicksite.Really what we're doing is just seeing how it works and how everything is built out and how you can customize and build out your own dashboards analysis as well.So if you come in here you can see that we have different types of visualizations very standard types of visualizations uh for any BI tool.And if we click into one of these, let's say we're clicking into this one, you'll see we have an x-axis, a value, and a color.
On the lefth hand side, we also have all of our fields.And you can see whether it's a dimension or if it is a measure.Next, you can see that up here we have our data set.This is the data that we are using.And right over here is the type of visualization chart.Now, this should look really familiar if you're familiar with Tableau or PowerBI, both of which I have series on YouTube.These are different types of visualizations that you probably have seen.And so if we wanted to uh change this, we can click on a different type of chart and it's going to visualize that data based off of that visual type.It's not going to be extremely extremely useful.These are ones that I would use all the time is just clicking on one of these and then filling in the x-axis, the value, the color, and all of these different things that it's prompting you to provide.
Another thing you'll notice is we have different sheets up here.So within this analysis, we can add new sheets.So we'll make this uh interactive.And now we have a blank sheet here that we can build our visualizations off of.Let's say we wanted some type of doughut chart in here.We have our doughut chart.And it's going to uh prompt us to fill in what it actually needs.So we need a value.Then we need a group slashcolor.So let's say we want the uh region to be our group and color.And for the value, we'll do the weighted uh revenue right here.And we're going to do the sum.That should work.And so now you can see that this is interactive.You can go ahead and click on this.You can click into these different options.You can change these colors.Let's say we want to make this one uh black.
There we go.And there's other options up here like format this uh visualization or if we want to maximize it or minimize it.And if we want to add any more visualizations, we just click add and we can add it right over here.And so everything in here is quite customizable.And you can rename these sheets.Let's call this one uh sum by region.Call it whatever we want.This is just for this one uh visualization.But everything is in here is quite customizable.Now once we have our visualizations, we have this properties right over here.And we can change a lot of the titles, subtitles.If it's a doughnut chart, we can make it large, small, medium.We can show the total versus not showing the total.So everything in here is very, very customizable.And we can specify if we want the data labels and the legend on.
So if we don't want the legend, we can turn it off and on.Or if we don't want the data labels, we can turn those off and on as well.We also have over here an interactions tab.So if you want to customize some of these interactions or if you want to customize some of these tool tips, you can also do that as well, which happens when you hover over it.So right here on this right hand side, it's giving us the uh field for region and the weighted.And you'll notice when we hover over it, you can see it's the US with the weighted revenue.So we can specify what we want in here.Maybe we want to um add something else.Maybe we want to add the date doesn't make sense for here, but maybe the uh segment.Let's go ahead and do that.
And we hover over it.You can see there's a count of the segment which is 12,824 for this data set.So you can customize these tool tips as well.Now when we're done with our visualizations, we can come over here to file and we can publish this and save as analysis.So just saving is going to save it for you to pick up later and do whatever you want with it.But let's say we want to publish this.Publishing this dashboard, we're just going to call this uh sample dashboard is going to make it available to everyone.So let's go ahead and publish this dashboard.So now we have uh this first sheet that was created by them, but then we have the second one that was created by us.Now once we've published it, we can then come over here and we can share this.
So we can share this dashboard and we can come in here and we can choose anyone who has access to Quicksite.We can say I want to share this with my colleague or the customer or whoever it is and I want to use this.The other thing that we can do is we can copy this embed code.What you can do is you can say hey I want to embed this on my website or on this platform and I want to uh show this visualization.You can embed that using the code uh from this right here.We also can copy this link.And so we'll copy the link.Come right over here.
And now we have access to this dashboard.So anybody who has access to it can just use it as a link and that's really helpful as well.But what I thought was really interesting uh within all this is the embedding code.Because not every BI tool is embeddible but quicksite because of course it's with AWS it's all internetbased.It's not you know local to your computer.It's very embeddible into almost you know anything you want to put it into.So let's go back to our sample dashboard.We'll go back to Quicksite.So that's our different analysis, but let's go over to our dashboards.When we actually published our analysis, it went right in here to our dashboard.So now this is a completed dashboard.We would again share with our internal teams or our customers.We also can create data stories.This is something you do need to upgrade in order to receive access to this.
But this is very very similar to data stories in something like Tableau.If you've watched my Tableau series, it's very very similar.you can watch this uh video as well.But you create these little stories and you can add narrative and you know why the data is doing what it's doing and what impact that has and it's pretty good.I personally don't use data stories all that much.I mostly would create a lot of KPI metric dashboards and stuff like that but you know there are use cases for data stories of course.Lastly we have these folders.Let's go ahead and create a new folder.We call this one Alex the analyst folder.Once that folder is created, we can come back to our dashboard.We can right click on this and say add to folder.Then we need to specify our folder.So we'll go to my folders and we'll add this.
And so now within my folder, if I click in here, I have this dashboard.Now, this is really just an organizational tool for the most part.But when you start using this in a production environment, you're going to have a ton of different dashboards.And so you can come in here and create different ones for different customers, different clients, internal teams so that you can organize all these different dashboards and data stories and whatnot.So you have it all in one place.And so again, that's just super usable, really userfriendly.Now, this is really all we're going to cover in this video.We're not doing a full project in Quicksite.I'm really just demonstrating how to use it, some of the things that they have in here that I think are really interesting, and how you can publish and share and do all those things within Quicksite.
So, I hope that that was helpful and if you have not already, be sure to check out my full Azure and AWS course on analystbuilder.com.And if you like this video, 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 learning data bricks in under two hours.
Now, for the past 5 weeks, we've been diving into data bricks.And in this video, we're just putting all that together so you can follow along really easily.We're going to start by taking a quick walkthrough of data bricks and seeing everything that it has to offer.Then we're going to start importing data not just from a flat file but also connecting to a data source.Then we're going to start using their SQL editor as well as their notebooks and visualizing data.After this we'll be using their AI tools like Genie and their AI assistant.And finally we'll be building a full project at the end.The best thing about all this is it is completely free.Data bicks has something called the data bicks free edition.I will leave link in the description.You can make an account by just using your email.That is it.
So be sure to go and create your free account so you can follow along with this entire video because we have a lot of things that we are going to cover.With all that being said, I hope you learn a ton because data bicks is a fantastic platform.So let's jump right into it.Now data bicks is an amazing platform.I've been using it for many years and it's built on top of Apache Spark which means it is very good at handling large amounts of data.It's designed for entire teams of data engineers, data analysts, data scientists to work with data collaboratively.That means ingesting the data, analyzing the data and visualizing data all in one place.In this lesson, we're going to be diving into data bricks and look at some of the core functionality and features that data bricks free edition has to offer.
And then in the next several lessons, we're going to get really hands-on and start digging into these features and start building things out.With that being said, let's jump on my screen and get started.Before we jump into the platform itself, I just want to show you that this is where you sign up.So, I'm going to have this link down below.So, you can just click on it.You can create an account and you can sign in.There is no credit card information that they take.You just literally sign in and you are good to go.But on this page, you can sign up for the free edition or login, which we'll log in in just a second.But you can also learn a lot more about data bicks free edition and everything that they have to offer.You can see that they have built-in AI agents and they have AI builtin and that is something that we're going to cover in this series.
You can also visualize your data and create full dashboards.And of course, you can interact with your data with Python and SQL, either through notebooks or, you know, through a code editor.Let's go back up and let's go and sign up for the free edition.All we have to do is log in.You can do that with Google, with a Microsoft account, or just an email.I'm going to sign in with my Google account.And all I have to do is say where I'm from.So, this is Alex.We have the free edition, and I'm from the United States.Let's go ahead and click continue.And just like that, we are signed up for the Data Bricks free edition.It was about as seamless as it can possibly be.Now, there's a lot to cover.Data Bricks has so many different features.They have so many different things that you can do from building interactive dashboards to writing SQL queries and sharing that with your team and being able to work with your team.
You can even build AI agents.There is a lot of things that you can do.And some of this might be a little bit intimidating if you've never used a platform like this before.If you're used to just working something like SQL or R or Tableau, it's a little bit more advanced than that.So there's a lot of things that they have that are all combined into one place.And so we're going to walk through a lot of these things that you see on this lefth hand side to see exactly what you can do in data bricks.Now I'm going to start at the very top because this is a workspace.And a workspace is basically the place that you work and you can collaborate in as well.So you can give your teammates access to your workspace.So if you have data in here, if you have code in here, if you have visualizations, whatever it is, you can share that with them and they can get access to all of your work.
Next, let's go to catalog.You can think of catalog as like a schema.So if you have a schema in a database, you're going to have all of your tables and your views and your store procedures and everything underneath it.And this is very similar.So if I go into a workspace or if I go down here into the samples, we have different databases.And so we can click into these databases and we can look at all these different tables.And so this is where you're going to have access to view all of your data and files and tables within data bricks.Next, let's take a look at jobs and pipelines.This is where we start getting into some automation.So here we have an ingestion pipeline, an ETL pipeline, and a job.And each of these does a slightly different thing.If you create an ingestion pipeline, that's going to be like the extraction of the ETL process.
You're extracting data to bring it in.Then we have our ETL pipeline, which is the entire process of transforming it, loading, and actually putting it into a table within data bricks.And then we have our jobs that's going to orchestrate it.We're going to be able to say, here's when we actually run these pipelines so that we can time it.We can do it, you know, daily, weekly, monthly, whenever we want to run these pipelines.So, we don't have any created, but when we do, they'll be down here at the bottom.Next, let's look at compute.Now, compute is very simple in the free edition because you don't have any options here.We just have our serverless starter warehouse.This is what you get for free with the free edition.Now, if you go to the full datab bricks product, then you're going to be able to kind of customize your compute to your needs.
But for this free edition, we have uh the owner, we have the size, which is a 2x small, and then we have whether it's active or not.Now, right now, we're not running anything.We're not looking at any tables.We're not running any queries.So, it's not active at the moment, but the second that we open something up and start working with real data, it will activate the serverless compute and we'll be able to use it for free.One small nuance to this is there actually is one other type of compute, you just can't see it, and that's for when you run Python in a notebook.It's called a generic compute.It's just for that one specific use case.For the most part, you're going to be using this serverless compute, but I thought it was worth mentioning.Notice when I clicked on compute, it also took me right down here to the SQL warehouse.
This is our SQL warehouse that we are using.Next, let's go down to the marketplace.Now, the marketplace is basically just, hey, here's a lot of companies that work with us, that we partner with, we have connectors to, and we have, you know, partnerships with, and allows you to work with them a loteasier.So, here we go.Partner connect integration.So if you want to connect to Fiverr, to PowerBI, to Tableau, DBT, Prophecy, you can easily connect to these.I know at my previous job I connected it with PowerBI a lot and so these are great connectors where you can just kind of search and you can see, hey, do they connect to this tool that we useand most of the time they do have that connector.Now the marketplace has other things as well.If we come over here to products, we have things like tables or files which is data.
You can also search for models and notebooks and all sorts of other things.So you can come in here and we can search for files.And so these are all free resources and files that you can search for and use.If you can't find data here in the marketplace, you can always just go to something like Kaggle and get free data and bring that into data bricks as well.Now let's come over here and go to the SQL editor.You can see we have kind of these uh larger overarching sections up here, but then we have SQL and then we have data engineering.Then we have AI and machine learning.Right now we're in the SQL section.So, right in here, we're able to come in and we're able to write SQL just like any other platform.The neat thing about this though is that they have AI integrated into it.
It helps a lot with writing some of the base queries that you're going to write.Now, we're going to have a whole lesson on Genie.And so, we're going to dive into that and see how you can generate code and do a lot of different things with Genie, which is their AI system within Data Bricks.And Genie just allows you to get insights from your data just using natural language.But you'll be able to write SQL right here in this editor as well as have multiple tabs and choose what workspace you're working with in and choose what workspace you are working in.Right now, we're just on the default, but if you had different workspaces, you'd be able to just click on those and select where you want your queries to be pointed at.Next, let's take a look at our queries.So, once we get in and we start developing all these queries, we want to save them.
And organization is a big piece of that.I know that I used to have like 20 30 different kind of queries that I was saving on my file explorer back in my old job and then I started working in data bricks.I'm like hey I can just save those within this and then I don't have to email someone my query and then they pull it up and copy and paste like it's all here within data bricks which is reallygreat.Next let's go look at dashboards.Now these are some sample dashboards and we're going to have a whole lesson on analyzing and visualizing data within data bicks.So we'll be able to build something like this.Let's click into one of these dashboards right here.It says my warehouse is starting.That's because it's connecting to the data to be able to visualize our data.
So, let's get rid of this filter really quick.So, this is what our dashboard looks like.And you're able to create all these different visualizations.You're able to drill down into the data.And this is all connected to data that is already in data brick.So, it's all in one place.Next, let's go take a look at Genie.And they have a whole section just for this.And they also have an entire section that is just devoted to this warehouse.Now this is something that a lot of platforms are trying to build to but data bricks already has it which is they have all the data they have the ability to query and analyze and visualize data all inone place but being able to use AI with it to get a lot of those things done faster.And so you can ask it questions and it's going to prompt you because this is kind of a uh you know starter section and you can ask it questions and it's going to run these queries and it's going
to get you that information really quickly.In one of our future lessons, we're going to be diving into just Genie, focused only on what it can do, how it helps you analyze your data faster, and how it can be really useful to you as auser.The next thing that we're going to take a look at is alerts.Now, an alert is basically like a trigger.When a condition is met, it's going to do something.And so, you can customize these alerts and set these conditions, and they'll email you or they'll message you when these conditions are true.Now, in this section up here, this is where we're going to be spending the majority of our time.There are other things like the job runs which is where you can create your jobs which is part of these uh jobs and pipelines and then of course the data ingestion as well which allows you to connect to
your data.So if you have a data source that you want to point at maybe it's Google Analytics you can just click on this and connect to your data or if you just want to upload a file you can dothat as well.Down here we have our AI and machine learning section.So you can click on the playground.This is another area where you can interact with the AI within data bricks and you can select some custom parameters as well as the prompts that you are using.We can also look at experiments.This is where you can build out AI agents and machine learning models and you can actually test them out.And so this is a fantastic place where you can actually learn how to use a lot of these foundational models and you can take the data and you can deploy it and you can work through these issues and
really learn hands-on how to work with them.Naturally, they're going to have AI integrated into all this.So you can work with the data bricks assistant to get help with all of your coding.So as you're going along, if you get stuck, you can always get help with your code.As I said before though, we are going to be spending most of our time right up here.Of course, we'll need to ingest our data.But after that, we're going to be spending a lot of our time visualizing, see how we can work with our data and how we can use their integrated AI to be able to do our work faster.At the end of this entire series, we'll be building a full project using a lot of the things that we're going to be looking at in this series.I think building and getting hands-on is the best way to learn.
So, I cannot wait to get started on that.There are a lot of ways to work with data in data bricks and we're going to cover a lot of them in this lesson.We're going to upload data like a CSV and a JSON file.Then, we're going to connect to an external data source and we're going to bring that data in.Then, we're going to see how we can actually use our data working in the SQL editor as well as using a notebook.The best way to follow along is to create a data bicks account.I will leave a link in the description.It's data bicks free edition, so it is completely free.All you have to do is create an account and sign in and you'll have access to everything.You don't have to put in a credit card at all.It is completely free which is amazing.
With all that being said, let's jump on my screen and get started.We are starting out fresh.We haven't uploaded any data or ingested any data into data bicks yet.So, you are right where you need to be.Now, there's actually a lot of different ways you can bring data into databicks.Right now, we're in our workspace, but let's go over to our catalog and let's go into our workspace.Let's go into default.Right now, we have no data in our default workspace.Now, what we're going to do is let's click into this default and we're going to come right over here and we go to create.Now, we have a few different options.These two are the only ones that are really relevant to what we're doing right now.So, let's create a new volume here.And I'm just going to call this uh YouTube series.
And then I'm going to go ahead and create this.Now, you'll see right over here under default, we now have this folder called YouTube series.If I click in this YouTube series, we can upload to this volume.So, we can do that right here.We don't have to actually go outside of it or go to any of these other options.We just click on upload to this volume.So, let's go ahead and click browse.And I have all these different files.Now, I created these.They're very simple files.We're not getting crazy in this lesson, but I have a customers CSV and a customer's JSON.So, one's a CSV file, one's a JSON file.I also have orders CSV, orders JSON, product CSV, and products JSON.We're not going to use all these, although I will have all these files in a GitHub.You can just find them in a link below.
So, you can download these exact files if you want to work alongside me.But let's bring in the customers CSV.So, I'm going to click on this customer CSV.And you can see this is the destination path that we are using.Let's go ahead and upload this file.And very quickly, like in 1 second it took, we now have our customers CSV CSV.Now, I just named it that.So, you know, if the CSV wasn't there, we'll still be able to see it.Let's click into this CSV really quickly.We have our customer ID, first name, last name, country, and signup date.And then you can see our data is all separated by a comma.Now, this data is just being stored as a file.This isn't actually being stored as a table.So, you can see it just sits in here as a CSV.
So, if we go over to our files, it's going to sit there as an actual CSV file.Now, we can still query off of this data just as it is as a file.We don't actually have to have this in a table format.Let's come right over here and let's copy this path.And then we're going to go down to our SQL editor and let's come over here to a SQL query.Now, if we want to access this data, we can say select everything and then we'll say from and I'm going to put this path in here.I should be able to use back ticks just like this.And let's try running this.And actually, I need to put CSV dot right here.Now, let's try running this.And as you can see, we were able to read in our data without it actually being in a table.
A CSV file is one of the easiest files to work with.It's just values that are separated by commas.And so when we do this, when we say CSV dot and then we provide the path, we are reading in this data as if it is in a table.Now, if you come from just a SQL background, this may seem very unintuitive to you.And that's okay.Let's go back to our catalog and we're going to come over here to workspace.We're going to go to default.And instead of going into our volume right here, we're going to come back to our default.And so now we're going to create a table.When we go to create a table, we're still using our serverless starter warehouse here, but now we have the ability to connect to a data source or to upload a specific file format.
Let's go ahead and click browse.We just uploaded the customers CSV, but let's go down to the orders JSON because JSON is a totally different format.Let's go ahead and open this up.It's going to read in that JSON and make it tabular, which is fantastic because JSON by definition is not a structured format.And so being able to read in that data really easily and then put it into columns and rows is very helpful.So now we're going to do a create a new table.We can name this table anything we want.I'm just going to get rid of this JSON because once it reads it in, it's like a table anyways.So, we're going to keep it as orders here.Then, we're going to create this table.Now, you'll notice over here under our default, we have tables and we have volumes.So, they are separated out because they're two totally different things.
One is going to be storing different files in kind of a folder format and then one is the tables underneath our default workspace.So let's come down here to orders and that's actually right over here.So now under our orders we can see customer ID, order date, order ID, product ID, quantity, and total amount.We can get a little bit of metadata on this file.And if we come up here, we can come here and just create a query.So let's click on create query.It's going to open up a new query in here.And now we're just selecting everything from our orders table.It's already hitting off of our default schema in our workspace.So, we don't have to start doing, you know, workspace dot uh default.We don't have to have all that.You can uh but I'm just going to hit control-z here.
Let's go ahead and run this.And now we can see all of our data in this really pretty view.So, so far we've ingested a CSV file and we just did that as a CSV file.We were still able to read that data in which is really fantastic.But we're also able to just create tables and then read that data in like any other SQL database.But now let's come over here to data ingestion.There's a lot of different ways you can access data that is not just sitting in a file.Right off the bat we have our data bricks connectors.Things like Salesforce, Workday, Service Now, Google Analytics, Azure SQL Server.These are a lot of the things that I've used in my actual work.Almost all companies are going to have at least one of these.And so connecting to that data source, bringing it in is really common.
We can also bring in data from a file like we did before or create a table from Amazon S3.Then we have our fiverr connectors right down at the bottom.I know personally I've worked at different companies.I've consulted with companies.They use Google Drive as like their store of information.That's where they keep everything.So let's go over here to Google Drive and I'm going to actually connect this.So I'm going to say I want to put it in my workspace.Let's go ahead and click next.Really quickly, I have a file over here, orderscv.csv.It's sitting in a Google Drive.So, that's what we're going to go and try to connect to.Let's go ahead and click next.This is my email that I'm using for this Google Drive.We're going to connect this to Fiverr.Since this is a new account for Fiverr, I need to create a password.
So, I'm going to do that really quick.We're going to come right down here and we're going to go to share.And all we have to do is make sure that this is not restricted.So, we're going to say anyone with this link, which means fiverr as well.And then we're going to copy this link and put it in our folder URL.Let's go ahead and save and test this.And it looks like our connection test passed.Let's go ahead and click continue.And now what we're going to do is sync our data.We'll start the initial sync.And it should be very quick because I do not have much data in this folder.So, it looks like our connection was successful.Let's come over here to our schema.our one file that we have in our Google folder is synced up.So, we should be good to go.
Now, let's come back to our data bricks.Let's come right over here and we're going to go into our catalog.We're going to go into our workspace.And now we have default and we also have Google Drive.Let's click on our Google Drive and we have this orders CSV.And you'll notice that we now have it in here as a table.Let's go ahead and create a query for this so we can look at our data.So now we have workspace.google drive.It's connecting to a different schema.So we have select everything from orders CSV.Let's run this.And now we have our data.It also adds this in which is five transync which is a really really useful column because if you're syncing this data consistently, you really want to know when that data gets put into this table.I promise you that's really helpful that they put that in there.
And then we have all of our data that we have.And so that's how we can connect to outside data.In this case, we use Fiverr, but sometimes you'll just do a direct connection depending on your data source.Now, this SQL editor works like any other SQL editor.You're going to be able to make joins and aggregations and all sorts of different things, but there is a different way to interact with your data.Let's come right over here.Let's go to new.We can also go and use a notebook.We can add code.We can add text.You can also use an AI assistant to help you with these things.So, we have markdown file right here.And I can say uh this is my first text right here.And then I have my code down here.So I can start writing and typing my code.
Now I can specify right here whether I want it to be SQL, Scala, R or Python.So for this notebook, you can use any of these.In this cell right here, I have Python.But let's add another one.And I can use SQL in the next one.And then in the next one, I could use R.And so you don't have to just use one.You can use multiple.Now, it depends on what you're doing, whether you want to use a SQL editor or you want to come in here and use a notebook.When I'm just kind of querying data, I'm just looking at it.I'm not doing a lot of transformations.I don't need a big programming language.I'm just quering the data.I'm going to be using a SQL, you know, editor right here most of the time.And I can always save these queries and I can pass them along.
But if I'm really digging in and I need to be able to break things out and leave notes and I'm going to share this with my team, a notebook is kind of the way to go.So let's look at SQL really quick.We already have a query for this, albeit a very simple query.But let's come over here and let's run this SQL query right here.So let's go ahead and run this.And so now if we scroll down, we're going to be able to see our data just like we did in the SQL editor.But now let's go write the same thing but in Python.In order to do that, let's come up here.And this is already in Python.So, we'll just say spark.t.And we need to read in uh the appropriate table.And all that is is orders.And let's go ahead and run this.
And it is reading it in as a data frame.Let's call this uh dataf frame.And let's come right down here and we'll say display dataf frame.And let's run this.And now we're going to get our data in a table.Just like before, of course, with this, it's going to save this data, but you can always come in here and you can rename and export it and you can put it into Git.You can share this with your friends because all your friends really care about your notebooks that you are writing.Or you can create a new notebook and start from scratch.But this is a totally different way to interact with your data in data bricks.This is where most of your work is going to be done.It's right here querying data, whether it's a SQL query or over here in a notebook writing a bunch of code.
whether it's in Scola or Python or R or SQL itself.Now, I hope that was really helpful because in the next lesson, we're going to be analyzing data with SQL and then also building out visualizations in data bricks.Now, in the last lesson, we looked at the SQL editor as well as notebooks.And so, what we're going to be doing is we're going to be looking at some data.We're going to be analyzing that data and then we're going to be putting it into a dashboard and creating different visualizations.This is actually the dashboard that we're going to be creating in this lesson.And I know what you're thinking, Alex, you put the exact same visualization twice.That makes no sense.but it will make sense once we get to it in the lesson.I highly recommend following along.All you have to do is have a data bricks free edition account.
I will leave a link in the description so you can make that account and follow along.With that being said, let's jump onto my screen and get started.All right, so we're getting started right here on the dashboards.All we're going to do is we're going to come up here and we're going to create our own dashboard.So, we get started with this blank slate and it has all these little arrows and I recommend you read through these really quickly, but this is how you add filters.This is how we get our data which is right up here and I'll show you that in just a second.And this is how we actually add our visualizations to what they're calling our canvas.Let's come right up here and let's go to our data.Now within our data set, we are able to write SQL queries.
And I will say this is one of my personal favorite things about this is you can write the query and then you can use that query to then create a visualization.We're going to do that in this lesson because I like being able to visualize and kind of see my aggregations when I'm doing some type of group by in SQL.I like to see what the actual output is and you can really easily do that in here.You can also come down here and you can just come in and select some of your data.Now, we are actually going to be using a sample data set.Everyone should have this data set.It's right here called the bake house.And so, we can come in here and we can also just select one of our data sets.When we select this sales transaction, it's going to start our warehouse.
So now it's connected to our data and our serverless warehouse is running.So now we have access to this data.If I come right here, I click on these three dots and I can click add to dashboard.So I'm going to click add to dashboard.It's going to read in this as a SQL query.So if we go back up here, we now have sales transactions as one of our data sets.So we can just come in here and write it ourselves or we can also come into the catalog and just select a data set and have it run it for us.Now before we start actually diving in and kind of analyzing and visualizing this data, there are other ways you can actually analyze data.And we looked at this in a previous lesson when working with data set.But as it pertains to connecting it to a dashboard, what we can do is let's come right up here and let's click on a notebook.
Let's say we want to run that exact same query.And I'll just go back to the dashboard.I'm going to rename this really quick.I'm going to rename this as our transaction, if I can spell this right, dashboard.All right.So, if I go to my data, I could just copy this.And then I can come right over here to the SQL editor, and we'll actually have access to uh our notebook right over here.So, this is just our fresh notebook.We haven't used it.I'm just going to make this SQL just so it can you can see how easy this is.But, we're going to run this exact same thing.We're going to get our output right down here.Now, let's say this is the output that we want.It isn't, but this is the output we want.But if we come right over here to these three dots and we scroll down, I can click add to dashboard.
So, I'm going to add this to my dashboard.I'm going to say add to existing dashboard.And when I click on this, I'm going to click on the transaction dashboard and I'm going to import this.This data is then going to be imported over as an untitled data set.We can rename this.Uh I'm just going to say that this is from notebook.So this is our data from the notebook.It is the exact same query as you can see exact same data.But you don't just have to create your data from right here in the create from SQL or in this dashboard tab.Now let's start actually working on our dashboard and kind of analyzing the data as we go.Let's just start by taking a look at our data.So we're working in the sales transactions.We have transaction ID, customer ID, franchise ID.
If we scroll over to the right hand side, we have the date and time that this transaction went through, the product that was purchased, the quantity, the unit price, total price, the way that they paid, and their cardnumber.Now, this is not real data, so don't try to steal any of this card number, but we are going to be using this data to create our visualizations.Now, typically when I'm analyzing and then visualizing data, I have an end goal in mind.I know what I'm going to be doing with the data, and so I know how I need to analyze it.if I need to be use a group by or a window function, if I need to clean the data or pivot the data.These are things that I'll know ahead of time.Now, in this lesson, we're going to keep it kind of simple, just learn how to build these things.
But in the last lesson in this series, we're going to be building a full project.It's going to have really messy data that we need to dig into.But here, we're going to learn a lot of the fundamentals.Let's start with that first bar chart that we saw earlier on.So, we're going to come right here.We're going to go create from SQL.And let's call this one.Let's rename this before we actually write it.We're going to call this one product sales descending.Now, what this means is is we're going to take the product sales.So, right over here, we're going to take the product and then we're also going to look at this total price.So, we're going to calculate the sales.This is actually going to be quite easy.If you know SQL, this should be uh pretty straightforward because we're just going to be using a group by for this.
So, I'm going to come right over here and I'm going to say I want to take the product.So, let's take the product.And I use tab for autocomplete here.So, I'm going to do uh comma, then I'm going to do the sum, and then I'm going to take the sum of total price.And again, I'm just going to hit tab.So, now that we have the product and the sum of total price, all we have to do is come right down here and say group by and we're going to group by the product.And we should also order by.So, we're going to order by and we'll do total price and we'll do that descending.And so, all we're doing, and let's run this.All we're doing is we're taking the product and we're grouping it.And then we're taking the sum of all of that total price.
And I actually need to order by the sum of total price.I just took the column itself, but in this query, we're using the sum of total price.Let's try running that one more time.Listen, it happens to the best of us.So now we have the product right down here, and we're ordering it based off the sum of this total price.Now I'm going to leave this just like this.Although typically I would use an alias.I would say as and I would say total price or something like this, right?But I'm not going to do that because I want to show you in the dashboard how we can easily rename this.We don't have to use this column name.So now this data right here is ready for us to visualize.We can use this.So now let's come over to our untitled page and let's title this.
We're going to say uh dashboard.So we're just going to name this dashboard.And we can get rid of these global filters for now, but we will need that in a little bit.Now, you have all these options down here at the bottom.We have the move, we have add visualization, add a text box, add a filter, undo, and redo.Now, let's focus on adding a visualization first, and we'll worry about the text box later because we'll give it kind of a header of transaction dashboard.You don't have to, but we will for this dashboard.Now, when you first create a visualization, we're going to have this widget on this right hand side.This is where you basically build out your visualizations.We're going to come in here and we're going to select the data that we want.We just built this product sales descending.
Let's go ahead and click on this.We do want this bar chart, but let's come in here and let's look at all these different options.There is a lot of different types of visualizations that we can create, and a lot of these are the ones that you'll use 99% of the time.So, we're going to click on this bar chart.Now, we have to select the x-axis and the y-axis.In our chart, the axes are like this.We have we have two separate axes.And so, we need to select what data goes on each of those axes.So, let's select our x-axis.For this, we're going to do the sum of the total price.And then for the yaxis, we're going to select the product.Now, this looks perfectly fine, right?I'm going to uh expand this a little bit just for a second.This looks perfectly fine as is, but there's a lot of little things that we can do to make it a lot better.
The first thing that I'm noticing is that I, you know, I'm having a little tough time reading this.I'm saying, okay, how much is this one exactly?It's a little over 11,000.And if I hover over it, it'll tell me the exact number.But that's not good for a customer or somebody to see.I'm going to add these labels.And now we can see it right away.So, we don't have to kind of guesstimate.we can see the exact number.The next thing I'm noticing is that it's kind of all over the place.It looks like it's in alphabetical order here, but if you remember in our data back here, we had it in descending order based off of the sum of total price.So, highest to lowest, that's descending.And I want that in our dashboard as well.All we have to do is we're going to click on this.
We're going to go down to these three bars right above product.And then we're going to click buy Xaxis and then right here is the descending.So now we've ordered our data from highest to lowest.It's no longer alphabetical.Now there are some other things I want to highlight.We don't have to add these, but we absolutely can.First, let's add a title.So we're just going to call this total price by product.Keep it super simple.But we can also add a description.For example, let's say we wanted to add some context to this.Or maybe we wanted to highlight that this is our biggest seller.So, we can say Golden Gate Ginger is our highest selling product eight years in a row.Now, I'm just making this up.Uh, this isn't real.This is just as an example, but let's say we had some historical data and this is now showing, hey, this is still our best seller and I just wanted to add that as some context.
You can definitely do that.You don't have to, but you can.One other thing is let's take a look at these colors because we don't have to just keep these colors.We can also use a custom color.So they can be you know whatever color you think is best for your dashboard.We can also click on this plus sign and we can create some other options.Now if we click on product and this is one that I don't necessarily recommend.So each product is going to get its own color on each row.It's a little bit redundant.Now let's go back over here.Let's get rid of our product and let's select our total price.Now we have this gradient scale from blue to white.This isn't my favorite.I actually prefer if we come right up here and let's get the green blue.And so this is a great way to analyze and visualize at the same time.
Sometimes you already know what you're going to be building out and so you can work with the data while you're building your dashboard.And now I can very easily see I'm like Golden Gate Ginger Man that is our product.like we're killing it with this product.Uh but Richard Oasis, nobody likes that.It's doing okay, but it is our worst seller.Now, just remember, we use this product sales descending and let's go take a look at this.This is the only data available to us in that visualization.Let's come over here and let's look at our sales transactions.We have our sales transactions right here.This is all of our data.And so there are times where we don't even need to write a custom query for each visualization.Let's take a look at this.So let's use our sales transactions to create a visualization in our dashboard.
Let's come down here.Let's create our new visualization.And the next one that we're going to take a look at is payment type.So let's change this data set to the sales transaction.So now we're using two different data sets.Just note that for future reference because that will come into play.But we're going to come down here and let's say we wanted to create a pie chart for the angle.And I'm just going to come down here.We're going to do payment method right here.It's going to give us a count.And we don't have to do count distinct.In fact, uh we probably shouldn't because it's just going to if we hover over it, you're going to see three because there's only three options.But if we do a count and hover over it now, it's 3.33,000.So now we're going to be able to see how many transactions are using each payment method.
Now, for the color, this one is actually really important for a pie chart.Let's come in here and we want to do this based off of the payment method.We want to break it out.So, we have this payment method.We have Mastercard, AX, and Visa.Again, we can see the split based off of the color, but I really like labels.I think they're just super important.So, I'm going to add these labels in right here.Now, this is an example where it says count of payment method right here on the dashboard.I don't like that.I mean, that's just by default.It's going to take the uh name of it.But I'm going to come in here.I'm going to change this display name.So, all I'm going to do is I'm just going to call this payment method breakdown.And let's change that.
And that looks a lot better.It just doesn't seem so I just tossed it in there.Seems like you intentionally named this dashboard.So, we were able to go in to this sales transactions that has a lot of different fields, a lot of different columns, and we're able to just kind of pick out which one we want to use.So far, our dashboard is looking great.We're just going to build one last visualization and then we're going to work on filtering.So, let's come right down here and let's create one last visualization.And this is going to be our dashboard.So, we're going to come in here.We're going to use sales transactions again, but this time we want to see our transactions over time, right?We have this date column and we want to use this.Let's use a line chart.And if we go back to our data, we have this date time.
And this is really useful.We want to utilize this and see how many transactions are we having over time.Maybe there's a certain day of the week that people are just making a lot of transactions.This is really useful data for someone to know.So, let's go back to our dashboard and let's come down here to our x-axis.And for this, we want it to be our date column right down here.So, we'll choose our date time.Now, by default, it's going to select monthly, but you can come in here and you can transform this.It's going to take that datetime column.It's going to be able to automatically change it to basically anything you want.So, let's just choose daily for now, but we can change it later on.We just have to choose our y-axis.So, let's click on our plus sign in order to see our sales over time.
Let's take a look at our quantity.It's going to do the sum of quantity here.And if we go back just to check on this data, the quantity is the actual amount that we sold.So, we sold eight, we sold 36, we sold 40.And so, it's aggregating that data for us, which is really nice.If we come right over here, we can hover over this and we can kind of see each day and the sum of quantity.Now, again, we need to transform this a little bit because it's just sum of quantity, date, time, um, doesn't display the best.We want to customize this.We're going to just say date to keep it simple.And then for the sum of quantity, we're going to say quantity sold and keep it just like this.for our title because I think this one may need one.
We'll say quantity of sales over time.Right there we go.Now we have our dashboard built.It looks great.I'm super happy with this.One last thing we should add, and this is optional.You don't have to do this, but I'm going to add this title really quick.I'm going to call this our transaction.Let me spell that right.Transaction dashboard.And I'm going to format it just a little bit.I'm going to do it like this.I'm going to increase the size.Just like that.You can change it to be a different color, but it just kind of adds a little bit of finesse to it, right?We can put that up and make this smaller.Um, we can make this smaller if we want to go kind of that route.But it is up to you.The next thing that I want to show you though is adding a filter.
Now, filters are quite important.customers, clients, managers, whoever is using this dashboard are going to want to filter in some way.They're going to want to say, "Oh, I want to filter on this product or I want to filter on this month or this year or whatever it is."And so adding a filter is really important.We can add a global filter right here.Now, let's come over here to our widget because we do have the ability to change the type of filter.We can select multiple values.It could just be a single value.Could be a date picker or range picker.So, a range of dates instead of just a single date.It could be a text entry where they're searching for something.Maybe it's a product.You can also do a range slider.Let's click on this range slider and let's come in here.
We're going to go down to the sales transactions and let's go down to the quantity.Now, what this means is is we've created this global filter on quantity.Quantity is a numeric data type.So, we have this slider where we can basically say, hey, I only want to see where the quantity was over a certain amount.So we have a picker where we can select a range for the quantity.Maybe we only want to see the transactions that have a quantity greater than 30.For example, we would be able to do that in this dashboard.We can click in here and we can customize this.Maybe the minimum is zero and the maximum is let's say 100.I'm just going to set it for now.Let's come right over here and let's say we only want to look at it where it's greater than 30.
So I'm going to click on that.You'll notice that this doesn't actually change at all, but this one changed and this one changed.And let's just highlight that a little more.Let's kind of slide this around.And you'll notice that only these ones are changing, but this one is not changing.The reason for that is the data set that we chose.So, let's come back here.Right up here, we have the product sales descending.And then if you go down here, we have our sales transactions and we have our sales transactions.But what are we actually filtering on?We are filtering on the quantity.And if you remember, let's go back to our product sales description.We don't have the quantity in here at all.And so this quantity is not connected to this data set.And so when we're applying this filter to this dashboard, it is not connected to this right here.
Now, the way that we can fix that is we can replicate this exact dashboard.And this is what I was kind of talking about earlier, which is why we're going to create a second dashboard, but we're going to create the exact same thing, but we're going to use the other data set.So now we're in sales transactions.We're going to create our bar chart.For the x-axis, we're going to do the sum of total price.And for the yaxis, it's going to be the product.Let's find it right here.Let's scan this all the way over.Let's go down, add our labels, create our custom colors based off of the total price, and we'll change that coloring to be the green blue.And you can already see that this is filtered based off of our global filter right over here.So, let's get rid of this.
Let's just make it the same.And we actually need to do one more thing.We need to go like this.So now we have the exact same visualization, but this one is going to be connected to our filter.So this is a really important just thing to understand when you're building out these dashboards is people really like their filters.They want to be able to do that and this is actually going to be a big thing that people request once you build your dashboard.You're going to build it out.It's going to be great and they're like, "Hey, I want to be able to filter on this.I want to be able to filter on this."And so you're going to have to build that out and you may have to go back and connect your data in certain ways to be able to accommodate certain filters.
So that's just something to think about and something to know.But now this one is connected just like this.And so I would actually replace this one with this new visualization right down here because I want it to be connected to all of our other data for these types of global filters.Now there are of course some other things that we could do.We can come in here and change some of these uh axes.We could add some more context in here.This is our sample data set.This is as far as we're going to go in this lesson.But like I mentioned earlier in the last video in this series, we're going to be building out a full project using real raw data.So we're going to have to do some data cleaning.We're going to have to really dig in and analyze our data and visualize and create our dashboard.
The first we're going to be looking at is Genie.And Genie is built for business users to be able to get insight from their data just using natural language.Next, we're going to be using their AI assistant to help us code.So we'll be using that in the SQL editor as well as the notebooks.It's going to help us generate code, but it's also going to help us diagnose and fix issues if we run into them.Next, we're going to use their AI assistant in the dashboards tab.So, it's going to help us create visualizations.Now, what's so amazing is you're going to be able to try all these things completely for free because in Data Bricks free edition, you can use all of their AI tools completely for free.Be sure to use the link in the description to create your account so you can follow along and practice and actually use all these AI tools.
With that being said, let's jump on my screen and get started.When you first pull up data bricks, we're going to need to come right down here within the SQL section to Genie.Let's go ahead and click on this.And this about sums it up for Genie.You can ask questions about your data in natural language.And that's what it is.It's just a way to converse with your data.Ask questions about your data.Let's come over here.We're going to go to new.And we want to connect to a data source.We are going to use a sample data set.Let's actually go to all.It's within the samples right down here.this New York City uh data set.This is the data that we're going to be using for this video.Let's go ahead and create this.It's going to spin up our SQL warehouse because that is what we're going to be using to interact with this data.
Now, while this is going and while it's uh just starting up and we can get rid of this, we now have this data that sits right over here.Now, I'm just going to give you kind of an introduction to kind of this interface, but we're right here in this configure tab.We can come over here and we can create custom instructions for whatever we want this genie to be.So if this genie is supposed to be for a specific team or a specific project or whatever it is, you can give it these guidelines because then you can share this with other people and they can interact withit.So if it's people on your team who are interacting with a specific data source, then everyone can interact with that AI in the same way.That's pretty cool.If we come right over here to settings, we can also name this.
So, I'm just going to call this one uh datab bricks genie taxi.And I could add some description, but I'm not going to at the moment.Now, right over here, you'll notice in this space, we have a little bit of kind of prompting that is just, hey, here are some things that you can click on and we can give you that information.We can also add a sample question.So, if you want to add one for your team or whoever you're working with or just for yourself, you can add a question right here.Let's just go ahead and save this.and we're going to get out of here so that we have just this Genie interface right here.Now, as I mentioned before, Genie is really great for a business user, someone who's just going to be using natural language in order to ask questions about the data.
If you are a more technical user, you're most likely going to be using the AI assistant that we're going to be looking at in the SQL editor and the notebooks.You can edit and dive into the code and get into the more programming side of data bricks.Let's just go ahead and ask it to explain this data set because we haven't taken a look at this data set at all.In fact, I don't even know what it looks like.It's just a New York City taxi data set.So, it says here's where it's located.It contains taxi trips, cleaning pickup, drop off, trip distance, fair amount, and pickoff/dropoff zip codes.This is the only table in here.Now, we can actually come over here to configure and we can click on this table and we can see a very quick kind of sample of this.
But I'm going to ask it to show me a sample of the data, please.I like to be polite uh when working with AI.You just never know, right?I just want to make sure I'm I'm being uh respectful here.So, now it's going to give me a sample of our data.Now, you'll notice right over here we have this show code, and this is what it's going to do for basically anything.It's going to show us kind of what it's doing under the hood, which I really like.You can also edit in here.So, if we want to come in here and we want to say, okay, let's limit it to 20 because we only have a small sample down here.Now, we can run this again and it's going to keep all this information, but we're now rerunning and kind of changing the code as we go if you want to do that.
So, now let's take a look just at our data really quickly.This is for taxi data.So, we have a pickup time, a drop off time, how long the distance was, how much it cost, the pickup zip, and the drop off zip.So, fairly simple data.Now, there's a lot of things I could ask about this data set.I'm going to keep it pretty simple.As we go further along in this video, we're going to get a little bit more technical, a little bit more challenging to the AI to really see what it can do.So, I'm just going to say, what zip code are people being picked up at the most?So, I just want to know where are most people being picked up?Maybe there's a specific zip code that 99% of these users are getting picked up at and that would be really useful information.
So, let's see what Genie comes up with.So, it says it right here.The most common pickup zip is 10,01 with 1,227 pickups recorded.Now, you can see that right down here, but again, you have to remember that this is mostly for business users.And so, I think it is good that they include this information up here just as a narrative that you can read.Let's go and look at the code.So, it looks like uh they're looking at the pickup zip, which is exactly what we would want to do.They're doing just a count of everything, and then they're grouping on that pickup zip as well, but then ordering it, descending on the pickup count, and limiting by one.This is how I would have written it as well.This isn't anything crazy complex.But I think it did a really good job answering this question.
Now, as I've been testing and working within Genie, it is pretty good with answering a lot of the questions about the data.Let's get a little bit more difficult with this one.So, let's come down here and let's say, what time of day do most people get a ride?Now, this is kind of how I would imagine someone who's not very technical might ask this question, right?It's not very specific, and I'm curious as to how it's going to handle it.So, let's see what code it writes and the output that we get.So, it looks like it used the pickup hour.It says the highest number of rides occur at 1,800, which is 6 p.m.with,455 rides during that hour.Let's look at the code really quick.So it looks like it's using this hour right here within our datetime.It's running a count.
It's kind of filtering a little bit and grouping on this and doing kind of the same thing it did in our previous query.Now Genie does have the ability to create visualizations as well.Let's see if it can visualize this.I'm going to say uh can you visualize this?All right, it did exactly what I asked it to do.I asked it to visualize it and it literally is visualizing uh the pickup hour and the count amount.This is not exactly what I had in mind.I actually wanted to see all the pickup times over time.So, I'm going to ask it if it can show me all the pickup hours and the counts and visualize it.So, I just went ahead and wrote that.I said, "Write a SQL query to show me all the pickup times and the counts and then visualize it."
Let's see if it's able to do this one because the previous visualization was not exactly what I was hoping for.Although it gave me exactly what I asked for.So it looks like it did this properly.And let's just look at this.They really are just doing the same query, but now they're not, you know, filtering on uh it descending and then limiting it by one.Now we have all of them.And whoops, let's go right down here.And now we have a visualization of this data.As you can see right here, this is our highest one.This is our 1,800 or our 6 p.m.And so now we have this visualization.Now, the thing about Genie is it's kind of its own standalone thing.So, if we want, we can come up here and we can copy this.So, we can copy all of this and bring this over to the SQL editor.
But again, that's not really the use case here.The use case is that a business user can come in here and ask questions about the data and get their questions answered without having to go into the SQL editor or a notebook or build a dashboard.So, with that being said, let's come right over here to our SQL editor and let's go right over here and let's take a look within a new query window.Let's take a look at the AI assistant that they have.Now, they have one right here, but you can also see a button right up here.They are both the assistant, but they are used in a different way.I'm going to demonstrate that in just a little bit.We're going to generate some code, but then we can ask larger context questions about the code and the data and revisions and insight into our data with our assistant up here, but we can't really do that with this
one cuz this is purely for generating code.Let's go ahead and click on generate code.Now, we don't have this connected to our data.So, I'm just going to say, show me our New York City taxi data.And I'm going to ask it to generate this.Now, this is very generic.I don't even know if it's connected to this data.Let's just see what it does.It does not know exactly what data I'm talking about.And that's because we're in this workspace.default.I just wanted to see if it would be able to pick up on it, but it's not doing that.Let's click over here.Let's go to our samples.And for our schema, let's come down here to New York City.I'm going to accept this really quick because I want to demonstrate something.Let's go ahead and try to run this.It's not going to work.
And that's okay.But what we can do is we can come right down here and we can say let's diagnose this error.So let's click on the diagnose and the assistant in the top right is now going to be activated.It's going to do this forward/fix.And so now it's going to say okay we need to use the proper schema and even if we hadn't switched over honestly it would have picked this up.This assistant up here is slightly more contextaware I've noticed than the actual code generation right down here.So now we can try running this.And we can run this right over here.And we're going to be able to see our data at the bottom.And I'm going to click this button in.It's going to say replace active query content.And so now I'm going to paste all this code right into this window.
Let's get rid of this for now.And what we're going to do is I'm going to edit this code.So as you can see, it highlights all of our code.And I'm going to do two things.One, I'm just going to do this forward slash.And we're going to get some options here.We're going to say forward sldoc/explain.We have all these options and it tells you what they do on this right hand side.So we can explain the code, improve the formatting, optimize the code, replace parameters, fix errors in our code.There's a lot of different options and they're just kind of defaults.And these are things that you can use really easily.We just fixed our code, so we're not going to do that right now.But what I'm going to ask it to do is do something totally different.Let's actually run our code really quick because I want you to be able to see the data in here.
But we have two really useful columns, a pickup time and a drop off time.And I'm going to ask it to calculate the difference between this and give us the average of those times.What's the average length of ride?It says the trip distance, but it doesn't tell us how long the trip took.So, I'm going to go into the code.I'm going to say I want the average time it took between pickup and drop off.Now, this is a little bit more difficult.This is more difficult than anything we did in Genie.Let's see if it's able to write this code correctly.Now, we can see what it's getting rid of with the red lines and with the green lines.We can see what it's actually keeping.We can accept this either by clicking accept or clicking tab.I'm going to go ahead and click tab.
And basically, what it's doing is it's taking the drop off time and it's taking the pickup time.It's subtracting it and then it's taking the average.And so, we're just going to go ahead and run this.And in seconds, that works perfect.But I don't want it in seconds.I want it in minutes.So I'm going to edit this.I'm gonna say I want the average to be in minutes, not seconds.It's going to rewrite this and it's going to divide it by 60.And that's really uh all it needs.Let's go ahead and tap this.Let's run our code.And now we have average trip duration in minutes.It's around 15 minutes.Now, this is really great, but somebody who doesn't know what this is might be very confused.So, I'm going to come up here and I'm going to use one of these forward slashes and I'm going to say add comments to code.
So, I'm just going to hit enter.It's going to start commenting on this code and I can click accept.It's just going to say calculates the average trip duration in minutes by subtracting pickup from drop off timestamps.Very simple, very straightforward, but it is really helpful for somebody who's going to be coming behind you and reading this code.Now, as I mentioned before, this is for coding, but if you have other questions about the data, you can also come over here.So, I'm just going to say, tell me a bit about this data.Now, this is just kind of a really simple overview of the columns and kind of what's in it.It's pretty straightforward, but now let's ask it.We're going to say, give me a simple data dictionary for each column.Now, I could have said for the whole data set.I don't know why I said column, but let's see what it gives us.
And just like that, it is going to give us a data dictionary, basically a description for each column.And this is really useful.It reads in the data and just gives you a little bit of information about what is in that data, as well as the data type and the column name.So, this is really useful.Now, as I mentioned before, this isn't only in the SQL editor.We can also do this within a notebook.So let's come over here and take a look at the assistant within a notebook.You can see we have this generate.It's going to look very similar as it did before in the SQL editor.Now it can do a lot of similar things.It's going to generate code but it can do it in different languages now.So we can do markdown, Python, SQL, Scola and R.By default though it is in Python.
So let's come over here.Let's go ahead and ask it to give us the sample New York City taxi data and just see what it comes up with.It looks like this one is going to be perfect.Let's go ahead and run this.And it's going to give us exactly what we want.We have our data right here.Now, one of the things that I want to highlight is that what you can do cuz when you're working within these notebooks, you can use whatever language you'd like.You can convert it to other languages.So let's come up here to our code.I'm going to say, can you convert this to SQL?It's going to take this, which was a dataf frame, a spark.sql dataf frame, and it displayed it.It's now converting it to SQL right here.And then we're reading in just the SQL.
Let's go ahead and tab this, and we'll run it.And we should get the exact same output.So that's one of the things that you can do in notebooks that of course you're not going to do in a SQL editor because you're just using SQL.So that's how the assistant works within a SQL editor as well as a notebook.But let's head over here to our dashboards.Let's go and create a new dashboard.And what we're going to do is we're going to pull in that data that we were using before in our samples.So let's go to our catalog.Let's go to our samples New York City.And we'll click on this.And we're going to say add to dashboard.So now we have this data right up here.This is our trips data.And what we're going to do is come right over here and we're going to add a visualization.
The first thing that's going to come up right here is the assistant.It said ask the assistant to create a chart or to create anything that we want.And so let's ask it to create something really simple.I wanted to create a card with the average fair amount.And let's go ahead and run this.So, I just wanted to show us the average price for one of their fairs for the taxi.And there we go.So, super easy, super simple.Now, let's ask it a little bit more difficult question.Create a line chart with the count of pickup times.And let's go ahead and run this.Now, it did do this.And what's nice is we have it right over here.It did this based off of the month.I'm going to change this manually to the day so that we can see a little bit easier what days have a lot or have a little.
And we're just doing a simple count on the pickup dates.That's it.Now, with both of these, I didn't click the accept button, but once you do, once you click accept, and you can of course uh change it, it is going to stay there like you just created it as anormal visualization.Now, let's say I want to make a change to this.Let's come up here and say change the daily and I need to spell this right.Daily to hourly.Let's go ahead and run this.And so there going to be a lot of people they don't know how to come in here or don't want to come in here.They can do this by just writing change the daily to hourly.I'm going to accept this.Now this uh looks wild but let's uh look at it.This is looking correct to me.
Take away that global filter.And now we're looking at it hourly.And so we have a very very accurate and specific view of hourby hour the pickup times.And so this is how we can create different visualizations by just asking it.We can of course come in here because it's still using the exact things that we would use to create these.And so if we want to add labels, I'm going to say add labels.I wouldn't on this data set.That's going to look terrible.Um but it's going to turn on the labels for you.And this uh looks horrible.But it did exactly what I requested.Uh it's too granular to add labels.We would have to change this to uh probably weekly maybe um and add the labels for it to even make somewhat sense.There we go.So this looks a lot better.
But we can do a lot of the things that we can manually do just using this.Now if you already know how to create these visualizations just by memory, you won't need to use this all the time.But let's say you just can't figure out how to do it yourself.You can always ask.It is there to assist if you need it.You don't have to use it.But it can be useful if you're like, I just can't figure out how to create this.Let me just ask the assistant and see how they would create it.As you can see, there are a ton of ways that you can use AI and data bricks.You can use the genie.You can use in the SQL editor with the assistant.We can also use this assistant up here, which gives a little larger context and we can use it in the notebooks.
So, it's integrated into a lot of different places that you would use as an analyst or a scientist or a data engineer.Now, within this entire data brick series, we've learned a lot of things and we're going to apply all of that into our final project.If you've never done one of my projects on this channel before, they can be a little bit long because I leave everything in.I don't cut out a lot of stuff.So, if I make mistakes, you're going to see it so you can learn from it as well.I will leave a link in the description so you can go to the data bricks free edition and create an account so you can follow along with this project.I will also have the data set that we're going to be using in a GitHub.So all you have to do is go and download that data set and you can import it and use it just like I'm doing.
We are going to be working with real raw data.So we are going to encounter some issues and some things that we'll have to clean up along the way.But we're going to learn a lot and this is what we're going to end up with at the final project.We're creating this United States emissions breakdown dashboard.It's going to be an awesome project.So I cannot wait to do this with you.Let's go ahead and jump onto my screen and get started.Now, before we jump into data bricks and actually start building out our project, I want to take a look at the data because there's a lot of data here.And when I say a lot, I mean, you know, there's only 3,000 rows, but there's a ton of different fields.So, if we start scrolling over, we're going to see there's so many different things that we can work on.
And I don't want to focus on everything because it's going to be impossible to get everything in there.I have highlighted with yellow the ones that we're going to be working with.This is the emissions uh for megat tons of CO2.We have our population, latitude, longitude, the county name, county, state name, and state abbreviation.We're going to be focusing on emissions, although there's so many other things we could look at in this data set.But we just don't have that much time and we don't have, you know, days and weeks to comb through this and build everything out for, you know, all the different scenarios and dashboards that we could build out.So, this is the data set that we're going to be working with.Again, you can get that in the GitHub.Let's get out of this.And what we're going to do is I'm right here.
We are in our databicks free edition account.I'm going to go ahead and I'm going to create a new catalog.So, I'm going to call this one I'm going to say this is our emissions uh catalog.I'm going to go ahead and create this.And now we're going to have uh let's get out of this.We're going to have our emissions.And I'm going to go under my default and I'm going to come right over here and I'm going to create a table.So, we're going to drop this entire thing into this.Let's go ahead and browse.And we're going to come up here to emissions data 2023.Now, this data is large.May take just a second uh to bring it all in.Um but, you know, it's not like 10 gigabytes or anything.So, we should be able to create this quite well.
I'm going to rename this to just emissions data because I think it looks cleaner.You can keep the 2023 if you would like, but I'm just going to take uh emissions data.All right.So, our data is in here.This all looks good.We are not going to transform any of this, although we may need to transform some of it, right?But it's going to autodetect all of our data types.So, you know, if we need to change something, we're going to do that after the fact.We're going to take it as it is with the raw data.Now, all we have to do is come down here to create table, and it's going to create our emissions data table for us.Now, it's going to give us some of this AI suggested description.This looks good to me.I'm going to go ahead and just accept this just to have it in this data set, which was uh nice to have.
Now, what I'm going to do is just give you the scenario, right?You were hired by the EPA to create a dashboard and they want to focus specifically on emissions, but they want a breakdown of things like where it's actually coming from in the United States, where the most emissions arecoming from.They want to see what states and counties are emitting the most emissions, as well as just in general as a population, how much emissions do we have per person per area.So, these are things that we're going to have to dive into.We're going to write some SQL queries in order to do this.Let's come over here and let's go to our SQL editor.Now, this is from a previous lesson.I'm going to go ahead and get rid of all these previous queries.And we're going to get started just with a fresh new query.
And we will do this by selecting emissions and going to default.And it should be our emissions data.Let's go ahead and run this.Now, as our dashboards, that's going to be kind of our final product that we're going to hand off.I want to start with our location data because I personally am super interested in this.We of course have the state name and the county name.That's not going to be as specific as something like latitude and longitude.And so I want to use this data along with our emissions data.And let's come right over here and find that.It's right here.So it's GHD emissions M tons CO2E.It's a long name, but that is the column that we want.So, let's come right here and instead of getting all of or taking all the data, I'm going to do uh latitude.
I'm going to do tab to autocomplete, we're going to do longitude and let's see if it can find the CO2.There it is.So, I'm going to go ahead and hit tab.And I'm just going to call this as emissions.I feel like that's just going to be easier.Uh let's go ahead and run this.And there we go.Now, in terms of actually analyzing this data, latitude and longitude tends to be a little bit more difficult to work within something like a county or a state because it is so specific.So, you can't really aggregate on it.It's more of a visual thing.So, let's actually just take this over.I'm going to copy this.I'm just going to bring this over to my dashboard.And we're going to create our new dashboard.Uh, let's rename it really quickly before we get into data.
I'm going to call this our emissions dashboard.As we build things out, we will then come and add to it.We don't have to do it that way.We could get all the data up front and then uh go from there.But I'm going to create from SQL.And I'm going to run this.And we actually need to specify where this is coming from.So let me get rid of this.I'm going to call this uh emissions default emissions data.So I was just tabbing there.It got our catalog, then our schema, and then our table.I just tabbed along the way.It makes it, you know, kind of easy to work with.Let's go ahead and run this.And now we have our data right down here.Now, like I said, this isn't the easiest data to work with if you don't really know latitude and longitude data, but it's really easy to visualize.
So, let's come up here and we are going to add I'm going to get rid of our filters, but I'm going to add a visualization.And the data that we'll connect with is apparently called our untitled data set.Let me change this.So I'm going to rename this as our location data.We will use some other location data, but it's like state and county.And so we should be good.Let's use our location data.And what we need is actually a map.And we didn't do a map when we were creating and building dashboards in a previous lesson.So this is a new one for us.But let's come right down here.We're going to go to a point map.Now you can see we already have the coordinates available for us.Longitude and latitude.So this should be really easy.We're just going to do uh for the longitude we'll do longitude.
And for the latitude, believe it or not, this is going to sound insane.We're going to do latitude.Now, this is a little tricky to work with sometimes.It's kind of a double click.So I'm going to double click in.I'm going to double click in.And you can kind of scroll back.There are some things that we need to customize because this is just super blurry.I'm going to go to the size and I'm going to decrease the size a little bit.I think that makes it a lot better.We can always, you know, doubleclick and zoom out just a little just to have enough.I will say if we zoom out more, you'll see some information right here.I think this is Hawaii.Don't cancel me if I'm wrong about that.Geography is not my uh best area.Then we have Alaska up here.
So maybe we want to include all of that.Um, that would be fine if we do, but I'm going to come right in here.I think this is what I want to keep, which is mainland United States.So, we're going to keep this.This to me is really useful and it makes a lot of sense.This is some of the most densely populated areas over here in the uh kind of the Mid East and the East.And then right over here, based on emissions, right, emissions is much lower.Even in California, there's a lot of people in California and on the west coast, but not as many emissions.And so most of our emissions, just looking at our, you know, our visualization are over here on the right hand side.Kind of centralized.What is this like Ohio?Uh, Chicago's in Illinois.It's like Illinois, Ohio area.
I'm not a geography expert.Don't hate.I just I don't know geography that well.So, this is really interesting.I would not have guessed this, but this is official EPA data.So, this is, you know, pretty useful.Now, real quick, I'm just going to come in here and I'm going to create our title.We're going to call this the United States uh emissions breakdown.And I need to spell this properly.Let's put this in the middle.Let's uh make it bold.And we'll make it larger.Not going to get crazy with it.Maybe we'll do one more.Let me see.That's too big.All right.Let's go back to 24.Underneath it though, I'm going to add like some notes.Uh, make it a lot smaller.We'll say this data was collected by the EPA.I'm going to say uh Environmental.It's always tough to watch people watch me spell.
By the way, I'm not good at environmental uh protection agency.And then I'm going to say in 2023.I think this is fine for now.If we want to add something later to it, we can.Or make it larger.Uh, whatever we want to do.But I'm going to keep it just like this for now.Actually, I think I do want to make this bigger or this part at least bigger.It seems like it should be.I feel like it should be bigger.That just feels better.I don't know why.Uh, don't get onto me.Now, we can add more visualizations to this, and of course, we will.But the first one, this one is probably the easiest one because we're not really digging into the data itself.We're more just trying to visualize it because latitude longitude data is, you know, pretty specific.Now, let's come back over here to our SQL editor.
I'm going to try using some AI here on this next one because uh the next one's going to be a little bit trickier, I think.Uh let's just create a new query because I think that's perfectly fine.Uh, but I want to make sure it's in the right schema.It is not.Let's go to emissions.Let's go to default.In fact, I could have just copied this over.Um, honestly, so I'm going to come over here.Let's paste this in here.Now, I'm going to edit this.I now want to focus on a new thing that we're looking at.I want to take a look at some data.Now, I'm going to do this because this is what I personally do.I'm going to duplicate this and I'm going to bring it back to uh the catalog and go to emissions, go to default, go to emissions data and look at the sample data.
The reason I'm doing this is because I want to be able to just oneclick over, take a look at my raw data.You can also just create a query and tab over.Um, but then I don't know, that's not my that's not my workflow.I like having a different thing for it.You can do that if you'd like.uh just do you know select everything from emissions data.Now what we are going to do is we're going to use the AI and what we're going to be looking at is I want to take a look at this county name as well as the population.So for each county so this is in Alabama.This is the county state name in Alabama.I want to look for this county and this population.Let's take a look at our emissions.But more specifically I want to take a look at the emissions per person.
So, we're going to have to do a calculation here.So, I'm going to ask the AI.I'm going to say I want to look at the emissions per person in each county.Let's go ahead and generate this.Let's see if it will get exactly what I want.It may or may not.And let's accept this.I'm just going to hit tab.So, we're casting this as a double.And then we're casting the population as a double.And then we're saying that's the emissions per person.Now, this theoretically should work, right?But let's go over to our GHG emissions right here.Now, here's the thing, and this is not, you know, a data brick specific thing, but this happens all the time in almost any platform is this is a number.This is a 100% a number.Has a comma there.Should be rented as a number.
But you can see right here, I can just tell you right now, this query is going to fail um because it needs to be changed.Let's go ahead and try to run this.Now, the reason why this is going to fail is because this is a string, right?We have letters, we have characters that are not numeric in this column, and that is an issue.And so, what we need to do is we need to convert this or we can also in here ask it to diagnose this error.I'm gonna see if the assistant can do it for us because if it can then that would be fantastic.Let's see if it's able to do this.This is kind of a specific fix.It needs to look into the data.And it looks like it got it perfect.It says you need to remove the thousands separator before you cast it.
This looks excellent.Let's actually uh replace this.Let's get rid of that.And now let's try running this.And wait a second.We have latitude and longitude here.Let's go back because I didn't want latitude and longitude in the first place.I was just looking at this and I got mixed up.Um, okay, that's fine.We'll keep this.But I am before we even run this, I am going to say I don't want latitude.Did I spell it right?In longitude, I want the county and the population for those columns.I'm just using AI here.I normally I could just fix this myself.I just want to test it because I think it's, you know, an interesting thing.All right, let's accept this and let's go ahead and try running it and see what happens.All right, we're running into some issues.And I'm just going to tell you that's going to happen and that's okay.
Let's take a look.One, we I don't think we even have a county column.Let's go right over here.We have a county name column, which actually should be fine since we're not grouping on anything.But I actually want this column right here.So, I'm going to copy this as the column name and we'll come right back here.Population should be correct.And then we're working with a replace.I believe that we need back ticks for this and not brackets.
Let's just go ahead and try that.And let's run it.All right.Now, this is working.Listen, AI is not perfect.Uh sometimes we got to step in and do what we do.So, this looks correct to me.Let's take a look just really quick because we are breaking it down by the county state name.Um, which is what I would do.I wouldn't want to use this county name because what if we have another county name that's Baldwin County, right?And when we start trying to visualize this data, then that could be issues because it's going to probably try to group that data and it just it'll cause issues.Now, what we're going to do with this is we're actually going to look at the top 10 emissions uh based off of probably the emissions per person.I think that's all we should do.
So, I'm just going to add it this time.I'm not going to ask the AI.So, I'm just going to say order by and then I'm going to say emissions per person.And we'll do descending.And this should be really Actually, I should have done I should limit it by like 10 or something.I'm going to say limit 10.There we go.Now, let's run this.And I'm super interested.This is real data.So, you know, I'm really curious.So, emissions per person, the population is only 5,000.They have a lot of emissions.That's in New England.This is in North Dakota.New England.North Dakota.Very interesting.So, based off the emissions per person, these are the places.And this is not what I would have guessed.I would have guessed like New York or, you know, I don't know, North Carolina or something like that.
But these are we got New England and North Dakota.And then I think Mo is Missouri.I don't quote me on that, but this looks good to me.Um, this query was a little bit more challenging than our last one.I think you would agree.Let's bring this over.We're going to go back to our dashboard.I could also make this another tab.Um, and it looks like that reset.We'll do that at the end.Um, we'll just place that how we want it at the end.Now, what we actually need to do is put this in our data.So, I'm going to come in here.I'm going to place this in there.Again, it's not um it's right here.The emissions, we can change this.So, we don't have to um we don't have to do that.Let's go ahead and run this.And our data is working.
Even though it's underlined, it's still reading it in fine.We do have it uh correctly done.We can always like we did before uh do emissions and it shouldn't say emissions data emissions.default emissions data just to get rid of those red lines.We can do that.Now we have our data down here.This is really useful.We don't necessarily have to even use this column, but we do have the population for emissions.And uh let's get rid of our limit because I want to make a specific type of visualization with this.It's a scatter plot.Scatter plots are really great because we're going to be able to use the population and the emissions per person on a scatter plot and kind of take a look.Hey, as the population increases, does the emissions per person increase as well or does it decrease?A scatter plot would be great for this.
Let's call this uh let's do emissions per person.That's what we're going to call this one.Let's come over here and we're going to come in and we're going to choose our emissions per person.Now on our xaxis we can choose the emissions per person.We can switch this around, see which one works better.Then we'll also choose the population.Let's scroll down a little bit.Now we need to change this from a bar chart cuz that does not look right.We're going to change this into a scatter plot.Now for the scatter plot, we want the raw data.We don't want any aggregation.So, let's say none here.And for the sum of population, none as well.That should be good.We can also really quick change the size because it's a little blurry.I want to see a little bit more granular of what we're looking at.
We have this one up here.Uh, this emissions per person is 0.5.Okay, so that's low, but the population is 10 million.I'm curious where this actually is.Let's come down here to the tool tip.Let's it add in the county state name.So now when I hover over it and it's so small.Um now when I hover over it, this is Los Angeles County.Um this is actually really good.There is a very low emissions for that amount of people.And you can see that because it's over on this left hand side.If we had something um over here, this is not going to be good.Uh this is one of our New England ones.They have emissions per person at 5.95 and that's in uh I think megat tons.So that's a lot of emissions.Their population is 5.16,000.That's not a lot.
That's a little over 5,000.They have a lot of emissions.So as you can see, the areas that actually have a higher population tend to have less emissions.Um, overall, I mean, these are Cook County, Harris County in Texas, uh, Maricopa County in Arizona, but a lot of these ones are actually fairly low per person.In the areas that don't have a lot of people, they actually tend to looks like they have higher emissions for the lower population.I mean, some, of course, are over here with very low emissions per person.It's just really interesting.I'm I'm kind of, you know, I'm kind of looking into this as we go.Let's add this title.We'll say emissions per person.We'll say emissions verse population.And uh we could add some type of description.We don't have to, but I'm just going to say higher populations tend to have lower emissions per person.
Um, and you know, we could go more in depth and add more notes.That would be useful, but we're not going to.But I think that's really interesting.Uh, I'm kind of fascinated by that myself.So, we have this emissions verse population one.Really quick, I'm going to add a title to this one.I'm going to say emissions per location.I'm just going to keep it like that.I think that's uh perfectly fine.Uh, let's scroll down really quick.We're going to add in some more visualizations.I'm going to just put these here so that we can scroll down a little easier.Um, but now we have these ones in here with us.Let's come back to our SQL editor and let's add a new tab.So, I'm going to say a new query here.Now, what I want to look at is the total emissions by state because I want to see what states are just doing the worst.
They have so many emissions.They're the top 10 worst states in America.I wouldn't say that.That's actually that's a bit extreme.We will need to reuse this really quick.Um, we're going to have to reuse this replace.I'll just copy this over.In fact, I feel like I can write this quite quickly.If we were in the emissions default here, um, what we need to do is we need to come over here and let's see.So, I don't want to have to take this and break it out by the state over here.We have the state abbreviation.So, let's use it.Let's copy this column name.Let's bring it back.And all we're going to do is just keep the state abbreviation.We don't need to do any of these calculations.Uh we should be able to get rid of all of that.And let me see what I'm doing wrong here.
Okay, it looks like I have an extra parenthesis.Then we're just going to say total emissions.That should be fine.Then we need to group by.So we're going to say group by because if we look at our data, we have a lot in Alabama, right?We have a lot of counties in each state.So, we have to group on this state abbreviation and then I'm not going to go over to it, but then we're going to group and do our sum right here.Right?And we're have to actually do the sum in just a second.So, we're going to say group by the state abbreviation.And there we go.And we'll take this.And then right up here, we just need to do the sum.So, I actually did need that extra parenthesis.I got rid of it.I was I was so shortsighted.
I got too excited.And we'll keep the top 10 actually.Um because I know that when we start visualizing this, we're not going to need uh all of them.Uh although it would be Let me just comment this out for a second because I am curious to look at all the states and see which one has the um highest.So the total emissions is Texas, Florida, Ohio, Illinois, Georgia.you know, that's a lot of the south and southeast and and not a lot from uh the west coast.Let's come down here.We have Vermont, Richmond, AK, is that Arkansas, uh DC, me, Maine.So, actually some of the Northeast is actually quite good with New Hampshire.Uh but then the West Coast and like kind of the Midwest tends to be really low emissions probably because their populations are lower, but I guess maybe not because of what we looked at earlier.
Anyways, let's limit this by 10.And then I'm going to copy this over.Yeah, we'll go back to our dashboards.Let me go back to the emissions dashboard.
Let's scroll down.And actually, we got to go to the data first.Let's create this.And we'll run this.I need to have our emissions and our default.That should be good.Let's run this data.And then I'm going to rename this.I'm going to say uh total emissions per state.That should be good.So now we have these.These are our top 10.What I actually want to look at this for is percentage-wise.We're going to have to do some other analysis because I do want to add something that you can't necessarily visualize.Um, we're just going to have to dig into that in the data really quickly and perform a little calculation.It's not nothing crazy.Um, but we may use AI for it.We'll see if it can uh it can work for us.We'll do totally emissions by state and we're going to do a pie chart right here.
Now for the angle, all we have to do is the total emissions, but we want to break it out our color.We want to break it out by the state abbreviations.Uh, we definitely need to add the labels here.Let's add our labels.There we go.Um, and it has it over there.So, we have this little legend right down here.We have Texas.That's 20% in the top 10.That's in our top 10.These are the total emissions.If we tried to add all of them, which you know what?Let's just go try it.We can get rid of these 10.Uh we can do that.Let's run this.We'll have all of our data.Let's go back to our dashboard.And now we have all of them.So, it looks like Texas is 10%.But that is a lot, right?We have a lot of different colors.
And it's really hard to see uh almost anything if I'm being honest.If we want to, and maybe this is a good uh thing to do, is we can add a filter right here.And I haven't even I haven't done this at all in this video yet, but I'm just going to say um maybe a range slider might be good.Uh for the field, we can do let's see total emissions per state.We'll look at the total emissions.And let's see if I can just kind of scroll up and do something like this.That might work.But then again, it's then, you know, only doing the calculation or the percentage based off of that.So, we're just reinventing the wheel here.I'm just demonstrating it can be done.Um, but I don't think we need this.All that being said, we're actually going to delete that.
But that's okay.Let's go back.We're going to add the limit 10.Listen, I'm here for education purposes, right?I want you to know what you can do.If you want to do that, you can.Um, but we're not going to do it.Let's go back here.Now, we have this.This looks good, but I don't like uh this title, actually.Let's get right here.I'm just going to say emissions percentage or something like that is fine.Feel like that's good enough for like a title even.We can and I think we should come in here and add some type of description, some information here.So, I'm just going to say the top 10 states account for X amount of emissions for the whole for all of the US.Now, I'm saying X amount because we don't have that information yet.We actually need to write that query.
Let's go back to our SQL editor and let's dig into this.I am gonna try to use this assistant because I feel like it might be able to understand um what I'm doing.I'm gonna paste this in and I'm just going to say I want to know what percentage I need to write this right.But what percentage of emissions are the top 10 states for the whole country?and let's see if it understands that.I don't know if I even wrote that well.Um, but let's see if it did with it if it does.Uh, this is a CTE it's writing.I'm just going to see what it's writing.It's writing a CTE.It's calculating the top 10 and then it's selecting it's selecting the sum of the total emissions.Okay, this could work.Let me take this query real quick and I'm actually going to open up a new tab or a new query.
And let's make sure.Oops.I need to get all this.Oh, it's doing it for a notebook.That's all right.Um, I'm going to get rid of that because I'm going to come down here to emissions to default.Let's paste this in here.And this may work.Let's run this.Okay, so this is the top 10 emissions.This is the top 10 percentage.I believe this is correct.Um you can validate this but what it's doing is we don't need this SQL here.What it's doing is it's creating a CTE calling it the top 10.Then we're selecting the state abbreviations.We have this query.It's taking the total or the sum for the top 10.And then we're using that later on.So now we're doing select and this is the sum of the total emissions from up here.And then we're taking the sum of the total emissions divided by this number right here which is all of them.
Now, wait a second.I may be wrong on this because we're only pulling from the top 10.So, maybe it's just looking at the total emissions from up here as top 10 emissions.It's taking the sum of the total emissions and then selecting the sum from emissions data.No, you know what?No, it is taking it from it's doing a subquery in here.I missed that.So, this subquery is actually selecting all of the emissions from the emissions data.This is great.I'm going to say it accounts for 51%.This is uh great job, AI.I'm glad it uh did a good job.I'm I I think I am going to add uh make a duplicate of this.I just that's how I that's my personal workflow.Okay.So, let's come in here and we're going to say that this accounts for the top 10 account for 51%.
Uh, let's make sure I spell this right.The top 10 states, I'm actually going to say these 10 states.These 10 states account for 51% of all emissions.I'm going to say of What am I What am I doing of all emissions in the US?I'm just I'm having a tough time writing.That is a useful statistic.That is a really useful statistic.So, I think this one is done.I think this is a really good visualization.Look, pie charts have its place.Percentages like this, I think, are really useful.Um, let's come back.Let's go to our SQL editor.I'm going to have that over here.So, I'm going to have my SQL editor, emissions dashboard, and the data.Now, what I want to do is I want to name and shame a little bit.Okay.I want to take a look the county state name.
What specific county?And we kind of looked at this earlier when we were getting our population data because we had to ground it with a group by something, but now we're actually using the county state name.We're going to take a look at the top 10 counties within the US.and we want to create a bar chart for this.So, let's uh use this and come right back here.Uh this was by far the hardest query uh that we've written today.AI did well.Um we you know we gave it a lot of the context, but I think it did a good job.Let's bring in some of our previous like this was a really simple um thing here.Actually, let's use this because it has the uh a lot of the information we're already wanting.Now, all we're doing is we're just looking at the total emissions, not per person.
So, let's get rid of this.We're literally just looking at it like this.So, we have the county state name.Let's go to emissions default.Um, we have the county state name from emissions data.And we don't have to do this.We need to do it.Let's close this parenthesis and call this as um total emissions.And then we have to use this alias for this part to order by it down here.We don't have to technically.We could just copy this whole cast uh and replace, but we're not going to.So now we want to look at the top 10.So this should work.Now we have the county state name in Arizona, Texas, Illinois, Florida.Geez, just so many so many emissions.Uh, you know, think of think of the world.Think of the think of your country.Let's come in here.Uh, no, we need to go back to the data.
Let's create from SQL and we're going to put this in here.Let's go back to our emissions.Let's run this.This should be good.Awesome.So now we have the highest total emissions right here.I mean, listen, even though Los Angeles County is in the top 10, it's because their population is four times as much as some of these.I mean, I just it's it's really interesting.That's why we did the emissions per person earlier because there are outliers and, you know, the total population does matter.Let's come in here and we're just going to rename this uh county shaming.All right, that's what we're going to call it because that's what we're doing.Let's be honest.All right, we're just going to make a bar chart.We're going to go to the county shaming.We're going to use a bar chart for our x-axis.
Uh, let's use totally emissions.Then for our yaxis, we can use the county state name.Um, and I do want to look at that from highest to lowest.So, let's do it like that.We can change the coloring if you want.I definitely want tool tips or not tool tips, sorry, labels.I definitely want labels on this.This is just our total emissions in like megatons.So, I'm going to say that I want to add a title.I'm going to say uh total emissions.I got to spell right.Emissions by M ton.M ton I think of CO2.Uh, and I want to make sure that's correct because listen, this dashboard, I'm gonna send this to the EPA right away.Uh, so we have m tons of CO2.Maybe CO2E.I don't know if I should be putting that in here.Let's add that.All right.
This looks great.Um, let's adjust this real quick.I'm actually going to come over this way.Double click.Double click.Come out a little bit.Uh, this this is something that I just have not gotten the hang of.I don't know if I'm doing something wrong, but let's click in on this and uh have that right there.We need to bring back our emissions versus population and bring this up.Now, I do Oh, what did I do here?Oh, I think I might have clicked on.Yeah, I zoomed in.Whoops.Uh, don't mind me.Listen, I make mistakes all the time.I want to clean this up just a little bit.Things like the total emissions.I just want to say total emissions, right?I'm cleaning up these X and Y axes.I'm going to call this uh the county name.Uh, maybe I should say county state name, I guess, to be more accurate.
That looks good.Emissions.This one looks good.Here we need Oops, let me zoom out.We need to rename this one emissions per person.We're gonna call this uh emissions.Oops.Did I spell that right?Emissions per person.That I does not look right, but maybe it is.And I'm I'm going to change this population to be capitalized.I just I think it looks better.Population.And uh let's see.Emissions per location.Emissions versus population.I actually should say emissions.Where's the title here?Oh, I got to do it up here.I'm going to say emissions for continental US.Did I spell that right?No.Continental US.My spelling is so terrible.But we're only looking at the continental US here, so that might just be worth noting.Um, we are done.We are done here.We have our United States emissions breakdown and I think this looks great.
Uh, we dug into some of the data a little bit deeper than we probably needed to, but I think this was great and we're able to use AI and build out our dashboard.I am super happy with how this turned out.Remember, this is a real data set.There's so much other data in here.So if you want to, you can use the assistant in here and say, "Hey, what other things can I look at for emissions and it'll give you suggestions, but this is what I wanted to build because I wassuper interested in it."And emissions is just, you know, something that everybody understands.People are curious about it and so visualizing it, being able to see it and kind of shame some of these counties that just got so many emissions, but it's worth it.It's worth uh worth building it out.
So I hope that you enjoyed this.I hope that you found this helpful.Before we go, I want to give a huge shout out to the sponsor of this entire series and that was Data Bricks.Data Bricks has been so awesome to work with because I already love Data Bricks.It was an easy fit.And what's even better is they have this data bicks free edition.If you have not already, if you just watched through this without following along, create a Data Bricks free edition account, go ahead and do that.I will leave a link in the description so you can build something like this completely for free.It is an amazing, amazing deal.With that being said, thank you guys so much for following along through this entire project.I had a lot of fun.and I hope you did too.If you have not already, be sure to like and subscribe and I will see you in the next video.
What's going on everybody?Welcome back to another video.Today we're going to build ETL pipelines in data bricks in under one hour.
25:35:30 - 25:36:16
Now, in this video, we're going to cover several different things.First, we're going to work on data ingestion, just getting data in.Second, we're going to actually build out our ETL pipelines.And then third, we're going to work on data orchestration or creating jobs in data bicks.At the very end, we're going to have a full end-to-end project where we pull data in from a folder in an AWS S3 bucket.Then, we automate it with an ETL pipeline to clean that data.Now, this video is made from several shorter videos that we have done on data bricks in previous lessons, but we're putting them all into one long video, so you can watch it all at one time.Let's not waste any more time.Let's jump into the first part, which is data ingestion.Before we jump into this data engineering series and start doing all the things, I want to slow down for just a second to take a look at what ELT is in data bricks.
This is the process that we're going to be walking through for this entire series.We're extracting data or getting our data into data bricks.That involves loading the data into different schemas and having that data available and then we transform that data.Now ELT might sound odd because most people are used to ETL where you extract data, you transform it and then you load it into the database.With a lot of modern data workflows, it doesn't actually make much sense to transform your data before because compute is quite cheap these days and so you can just load your data into data bricks and then transform itafter.Now there's something called the medallion architecture.We're going to take a look more at that in the next lesson when we take a look at bronze, silver, and gold architectures.Now, this is a really great way to kind of stage your data and it's been like this for a long time even before data bricks, but we'll be going into why and how we actually do that within data
bricks.Our data when we actually get it into data bicks is being stored in a delta table.It's kind of like a delta file type, which is basically just a parquet file that has this log system where you can kind of revert back and see previous changes to the actual document.And so we store our data in these delta tables and then we can do all of our transformations on it within a notebook or within SQL queries.Now that we've got that out of the way, let's actually jump into data bicks and see how we can do this.All right, here we are on data bicks and we're going to be doing two things.One, we're just going to upload a CSV file.It's probably the simplest way to get data into databicks, but then we're also going to connect to an S3 bucket.And so I'm going to show you how you can do that really easily.
And we're going to get all of our data into data bricks.Now we are just working with sample data for this lesson but at the last one when we start doing our full ETL process and automating this entire thing then we'll be using real data and so it'll be alot more a little bit more complex.There's a few ways to ingest data.One you can just click on this bring in data and it's going to take you right down here.But we can also just go to our data ingestion.And so when we click on this we're going to upload files to a volume or we're going to create and modify a table.Now, these are two separate things and these are important things to understand.Let's actually come over here to catalog for a second.And what we're going to do is we're going to come over here and we're going to create a new catalog.
And we're just going to call this one our data engineering.Uh that's all we're going to call it.I was going to keep going, but we'll call it the data engineering one.And let's go ahead and view this catalog.Now, when we create a schema, we're going to say this is uh video one.Let's go ahead and create this.We have within our data engineering we have our default and then we have this information schema but we also have this video one.Now we don't have any data in the schema but what we can do is we can create different ways to store our data.We can store it in a volume or we can store it in a table.Now in a previous series I kind of dove into these and how you can store your data as well as how to access the data once you put it in.
We're going to be putting all of our data into tables.So, I'm just going to set up one table.Now that we're here, though, we can do the same thing that we would do if we came over to our data ingestion, which is basically just drop a file in here like you would on any platform.Let's just go over to the data inestion just so we get the full experience.We're going to create or modify a table.We're going to select our CSV file.So, it's just our users_y, and we're going to go ahead and upload this.So, now we have this preview of our data, and we're going to specify what we want to do with it.We could create a table.We could overwrite an existing table.And we want to put this in our data engineering video one.So if it doesn't automatically populate, you can always just specify where you want to place it.
And we're going to call this underscore CSV because we're going to be bringing in the same file from an S3 bucket.So I just want to specify where we got this data.Let's come down here and we're going to create our table.So now we have our data sitting in our video one schema.So this is our users_y_csv.This is the simplest way to get data into data bricks.But I also have this exact same data sitting right over here in an S3 bucket and I want to use it.I want to connect to this data.I want to pull it in automatically.And that's going to really help us later on down the line when we start automating this whole process because we're going to create a connection to this data source so we can automatically pull this data in.And that's a big part of just data engineering in general, which is creating systems that can automatically ingest, transform, and load your data.
So, what we're going to do is we're going to come right over here.Now, I just want to show you this.I'm going to have a link down below so that you can see this as well.But this is basically just how you're going to create the connection.I'm going to show it to you in a second.It is very, very simple.So, let's come right over here.And what we're going to do is we're going to come down to data ingestion.Now, we want to go to the data bricks connectors and we want to go to our Amazon S3 bucket right here and we need to create an external location.So, we're basically connecting our databicks account to our Amazon S3 bucket.And then we can bring that data in very easily.What we're going to be using is this AWS quickart.Let's go ahead and select next.
We need to put in our bucket name.So, I'm going to come over here.Let's click in here.We can actually get it right here.there.There's other places to get it, but I'm just going to copy it from here.Uh, we're going to go back to our catalog explorer, and there's our bucket name.So, now what we're going to do is we're going to generate this new token, and we're going to copy this.Now, we're going to come over here to launch in quick start.And all we have to do is it's going to connect to our account.So, that makes it pretty easy if you're already logged in.Then, we're going to come down here and we're going to say I acknowledge and we're going to say create stack.It's going to come right here and it's going to say create in progress.
It's just going to validate it for a second.I had already done this uh before when I was making this video earlier just to confirm everything was working smoothly.And what it's going to do is it's just going to say create complete and then you're going to be good to go.All right.So, that took about 2 minutes and it says it is complete.So, all we're going to do is come back here and we're going to refresh this page.So, I'm going to go ahead and refresh.And now that that connection is active, we now have access to our users dirty.Let's come under here.We're going to click on this and we're going to go to preview table.So now we get this preview of the exact same data set.There's nothing changed.I'm not trying to trick you.All we have to do is we're going to come up here to data engineering and we're going to go to video one.
And then we need to name this.So I'm going to call this one dirty data S3.So I'm just naming it this purely so that we know which one came from which.Let's come down here to create table.And now we can see over here we have our dirty data S3 and our users_y_csv.I named it completely wrong but these are the exact same data sets and now we have them in from two separate locations.Now this is really important especially as we start automating a lot of this.If you have data that's sitting in an S3 bucket and you have other systems that then upload it into that bucket, we're going to be able to ingest that data automatically, whether it's updated or if it's a newfile.And we'll set all sorts of triggers and schedules and all sorts of really cool things in later lessons.
So that's how we ingest data within data bicks.In our next lesson, we're going to be transforming data within an actual data pipeline.So we're going to have the entire ingestion process as well as the transformation process all in one place.Now, in the last lesson, we worked on data ingestion into data bricks.So, we were able to connect to just a local file, just kind of reading that file in and then we were also able to connect to an AWS S3 bucket.Now that we have that data pulled in and we have it actually sitting in our schema, we need to clean this data up a little bit.And so, we're going to need to transform this data, which is part of the extract, transform, and load within an ETL process.So, we extracted and we ingested that data.And now, we need to clean up our data because it is messy.
That's the transformation piece of the ETL process.Once we have this done, we can put it into an ETL pipeline and then it sits there and it does a lot of the heavy lifting for us and we'll talk about that in this lesson.Now, really quickly before we jump into things, I want to talk about this bronze, silver, and gold medallion architecture that is very popular within data bricks.Now, we've actually already covered this bronze level, which is just our raw data.We ingested our data from our S3 bucket and it's just sitting there in this raw format.This is data that we are just never going to touch.What we're going to do is we're going to create transformations on that data and then we're going to put it into a different table or even a different schema or catalog.When it gets to that location and the data is actually changed, that's going to be in our silver.
So this silver layer or architecture is basically just once you clean it up and you have it in a lot better state where there aren't a lot of duplicates, there aren't a lot of issues with the data, that'swhere it's going to sit where you can then transform it into your gold architecture or layer.Gold is just production ready.You are ready to start using this data.You're going to put it into dashboards.You're going to put it into reports.You're going to put it into your apps.Whatever you're using that data for.Back when I was just using Microsoft SQL Server or any other tool, we would call this raw staging and production.The raw is bronze, the staging is silver, and of course, the production is gold where we actually use that data.So, what we're going to do in this lesson is we're going to actually use this.
We already have our bronze.we need to transform my data into silver and then find a business use case to create the gold table.So now that we have this background information, let's go onto our screen and start building this out.So in the last lesson, we brought in this dirty data S3.And this is what our data looks like.We have this user ID, first name, last name, their email, their sign up, the country, and referral source.Now, this is just our raw data.This is our bronze layer right here.Now, in this video, we're not going to do it exactly how I would do it in the real world.I'm just going to kind of keep it all in one place for us.So, within this video one or within, you know, whatever schema you created, we're going to keep our silver and our gold tables all within this one schema.
That is not typically how it is done.Here's what you typically would do.You're going to have a data engineering bronze catalog.Then you have a data engineering silver catalog.Then you have a data engineering gold catalog.And all these cataloges would hold the different levels.And so you're not just usually working with one small project like we are in, you know, this lesson, but typically you're working with lots of different projects and you're working with lots of different customers and you want thoseto be separated out so you don't kind of get them confused and you don't know which data you're supposed to be hitting off of.That typically is how it's done in a real workplace environment.We're just going to do it all right now within this video one schema.So this is our bronze layer right here.This is the file that we are going to be using.
Now in order to transform our data to get it to silver, here's what we need to do.Let's come up to our new.Let's go down to our notebook.So we have this notebook right here.Let's call this bronze to silver transformation.There we go.And I'm going to give you a little spoiler here.Uh we're going to create another notebook and we're going to call this one silver to gold.And so we want to uh separate these out.You don't have to separate these out, but for the sake of what we're going to be doing in this lesson, I do want to show you how kind of you set things up and you actually, you know, organizethings within an ETL pipeline.And then in the next lesson when we look at jobs and orchestration and automation, this will also come into play and I'll talk all about that.
So let's create these two different things.Now, I can write all this out because, you know, I know this data set.It's pretty simple and I already know what's wrong with it.So, I can go in and I can just fix it.I can write this out manually.But, uh, you know, let's get a little creative.Let's take a look at how we can use AI in order to see if it can do most of the heavy lifting for us.Now, in our sample data, I'm going to give you two things that need to be changed because there's only really two big issues.The first thing is in this date column, we actually have it as a string.And that's a problem, right?We need it to be a date column.And the issue is is this right here.We have one date field that is 2.29.24 instead of the uh forward slashes.
That's an issue.We also have a USR_109 as a user ID.And if we go down, we have a 1009 right over here.So we have a duplicate user ID.And in a primary key, like a user ID typically would be, that's an issue.So, we have two issues we need to solve.I am going to try to get the AI, which is the agentic AI, which is uh this one up here that we're going to be using to try to write this out and get it right.So, let's come back to our workspace.Let's come to our bronze to silver transformation and let's bring up our AI assistant.Now, I'm going to describe what I want it to do and then we're going to see if it's able to write it out.I myself could write it out very accurately in probably maybe three to four minutes, but this is not a coding tutorial.
I want to show you guys how ETL pipelines work in data bricks, not how to necessarily transform the data.So, let's try this out.So, I'm going to say take my data set and I can pull it up over here just so we can see it.I'm going to go to data engineering video one just so I can see the data.take my data set in the data engineering catalog in video one schema called dirty data S3.Now I like to be super explicit cuz I don't want there to be confusion especially as you have like hundreds of tables you don't want it to read in the wrong tables.I like to be super explicit.We're going to ask it.I'm going to say there is something wrong in the date column making it a string.I want you to identify and fix that issue.
There's also duplicates in the data set.I want you to remove duplicates on the ID.Now, I'm being slightly vague, right?I'm not telling it exactly what it needs to do, but I'm going to let this run and we're going to see if it's able to identify the issues and write the code.I do want it in Python.I think that's just the easiest way to transform this data.And so I'm going to say use Python and pandas and let's give it a go.So let's let this think for just a little bit and we'll see what it comes up with.So that took about a minute or so.It did a lot of different things and now it wants to actually run this code.Now before we do that, you can have it ask every time or you can just allow it to run the code after it's done.
I'm going to ask it to ask every time just because uh you know I want to make sure.Now, it does have a lot of printing just to show the work that it's doing.I myself don't want this in my output.So, I will ask it to change that in just a second, but it does identify that there's a period.It replace it with a forward slash.It converts it to two date time, which looks correct, and it also formats it for us.Uh, then it comes down here and it's doing just a ton of kind of pretty unnecessary things before it gets to this df.drop duplicates on the user ID.and we're keeping the first one, which is perfectly fine.And then lastly, it's doing a lot of verification.I basically don't want 80% of this code.I just want the simple stuff.So, all I'm going to say is I like the transformations you've done, but get rid of all the print statements.
All right, looks like it's done.And as you can see, it cleaned up the code immensely.Uh, this is uh really looking good.I'm going to go ahead and I'm going to accept all.You can see the diffs down here by the way for all the code that it's writing or taking away.We're going to accept all and we are going to run this ourselves.We can I'll just click run all here.Uh but we're going to run this ourselves and then we'll verify and make sure that this actually looks good.So let's open this up.Let's come down here and let's just do a display.We'll do dataf frame_clean which is what it named it.So now let's look at this new dataf frame that it has created.That should be a lot cleaner than before.So now if we come down here, we have our 1009.
Let's go see if our 10009 was removed.It was.And let's come over here to our signup date.And it looks like that now is converted to a timestamp, which is perfectly fine.Uh we could also do it as just a date column, but honestly, it really doesn't matter.Uh this is a great uh a great change and it cleans it up immensely.So now it's all standardized.It's actually in a date column or a time stamp column and that works great.Now, all we need to do as the last part of this process is we have to write this table to a new table and that's going to be our silver table.So, I'm going to come down here.I'm going to say and I could put it as the genie code or I can come over here.I tend to like using the side a lot more.
I don't know why, but I'm going to say uh write this cleaned table to a new table in the same schema and call it S3_cleaned silver.And so let's go ahead and let that run.And it should take just a second and we'll have that code for us.Let's go down here really quick.We have this.This looks great.I'm going to allow this to run for us.So it's going to run this code.Now it is giving us this warning and this is a very fair warning.We're using overwrite right here.And basically what we're doing is every time we run this, we're overwriting the previous data that's in that table.For now, I'm just going to use that cuz it's not a huge deal.You know, as you start getting more sophisticated with your data pipelines, you are going to want to think about things like adding data to your existing data instead of overwriting.
But, you know, that can get a little bit more advanced depending on your data and your data need.Now, it's going to run this and I'm going to accept all.And then let's come right over here to our data engineering video one.And now we have this S3 cleaned silver.So our bronze to silver transformation is complete.This is all we needed to do in order to transform our data.And now we have our raw data.And let's come actually back to our catalog.And we'll just take a look at this.We can get rid of our genie code real quick.So we're going to come over here.So our raw data is still going to be raw.Let's go ahead and run this.This is our bronze level, right?We still have the raw data.We still have the duplicates.But when we come over to our silver, this is now going to be our cleaned level.
So, now that we have all of our transformations completed, we've taken it from bronze to silver.Now, we want to create our silver to gold transformations as well.Let's come back to our workspace and we'll come down here to the silver to gold, which is going to still be right up here for us.Now, let's give it a use case, right?We could use this table just as it raw and we could hit off of it and we could build dashboards and all sorts of things.Sometimes we want to track certain KPIs or certain things that you can't just get from the raw data.So I'm just going to give it a simple use case.Let it write it out and we'll create our silver to gold transformation.So let's come right on here.I'm going to say that I want to know the best day of the week that people are clicking on certain ads.
And we're going to see what it creates for us.So, uh, I want to create a new table called insights gold.And I want it to show me the best days of the week and what ads people clicked on the most.And let's run this and just see what it does.All right, so it went and did a lot of work for us.It did not take long.This is maybe 15 seconds.It's doing some group buys on uh some different columns and it's getting some counts for us on different signups and referral sources.Let's go ahead and allow it to run this and let's see what it does.Now, it's given us a few things as far as outputs.One, this first one is extracting the day of the week and analyzing signup patterns.So, Thursday, Tuesday, Monday, and it's giving us kind of the day of the week when we had the most signups.
And then if we come down here, we also have another one where we're getting the referral source, basically social media, organic referral, Google ads or partner, the total clicks and the countries reached.And if we go down here, we have this last table, but it hasn't been run yet because this is actually creating our table.And so this one should be really interesting, but let's actually stop it really quick.And then I'm going to accept and then run this as well.I just want to see what this one is.And so then we have uh day name, the referral source, signups, and unique countries.I think this is the one that I, you know, was kind of hoping for when I asked it to run it for us, but it gave us different options, which I like.Now, all we have to do is we have to get rid of this.
And we're going to let that run.And so, let's accept that.And let's run this as well.Now, this display is literally just displaying uh right up here.So, we aren't actually reading this in.But uh let's come back into our catalog and let's go see if we have that gold table now.So now we have our video, we have our insights gold and let's just look at our sample data.And there we go.And so this would be like our gold table that we can now use.We now have some insights into our data.Now all we've done so far, if we come back in here, all we've done so far is we've just written code.We haven't necessarily created any type of pipeline.And so now this is the part of the video where we're going to get into building an actual pipeline.
And I did it this way very specifically.This is how I tend to write my code.I come into a notebook.I write out my code.And then I'm like, okay, this is looking good.Let me now go create my pipeline.So let's come right over here.We're going to come down to our runs.And there's this thing right here that says ETL pipeline.Now let's get rid of this.We also have this right here, which is kind of what we're going to cover a lot in the next lesson, but I want to talk you through really quickly while we're here.The difference.Now, we created two separate notebooks.One from bronze to silver and one from silver to gold.Now, sometimes with simpler pipelines like the one we just created, it could be totally fine to just come in here, create a job, and say, "Do this one and then do this one."
Right?That's all we're doing.We put it on a schedule or we can create uh, you know, a different trigger for that.And we'll look at that in the next lesson.But if you have a more complex pipeline, you're typically going to want to use this right here, which is our ETL pipeline.Let's go ahead and click in on this ETL pipeline.And let's come down here to start with an empty file.Now, you can start with sample code in SQL, sample code in Python, or if you have ones that you've already done, you can do that.We don't have anything, and I don't really want to kind of explain all of the sample code that they're going to be creating.Let's just start with an empty file.Now, we need to specify the language that we're using.And this is very important because once you create it, that's kind of the one that you're going to stick with.
We're going to use Python.And it's just asking for a folder path.And so, we'll keep that.And we'll say yes.And now what we have looks very similar, right?We have these uh kind of some notebooks on the left.Then we can write our code right here.It looks very similar.But there is a big difference between running something in a notebook like we were in our workspace before and running something in an ETL pipeline.When you're just running your code, it's running the code as is.It's pretty simple.And if you did what we said earlier, which is you literally just take that notebook, you put it into a job, and you say run this and then run this, it's literally just going to take your code andrun it.The issue with that though is it's not going to have any built-in data quality checks.
we're going to have to manage basically all of the logic ourselves and it's not going to handle any lineage tracking or dependencies within your code.Now, this is where ETL pipelines come into play.An ETL pipeline is going to have things built into it like automatic incremental processing, built-in data quality checks, failure recovery, things like that that are extremely useful when you have really complex pipelines, which we aren't doing in thislesson.of course is very simple, but you have to think, you know, if you're creating a real ETL pipeline with a lot of dependencies, a lot of complexities to it.You absolutely are going to want to come in here.Now, when we write this out, we can't just write it as our regular code.And we can actually do that.Let's come back and let's go to all of our files.Let's go to bronze to silver transformation.
We're going to move this just so we can visually see it.We're going to put this in our transformations.Then we're also going to take our silver to gold and we're going to move this to our transformations as well.So we're going to put this all in one place.And so now we have this silver to gold and we have the bronze.We don't actually need this uh file anymore.So we could just get rid of this.Now your UI might look slightly different.That's just because data bricks is always updating things, but you should still be able to follow along.But let's go ahead and this is our code.It's exactly how we wrote it before.Let's try to run this pipeline.It's going to try to run this and it should try to run that too.Let's just go ahead and run it and see what happens.
All right, so we got this error down here that says pipelines are expected to have at least one table defined but no tables were found in your pipeline which might seem very counterintuitive because you're like we've created differentdata frames.We've been working with tables.So it should understand what it's doing.Now it is actually rewriting the code as we go.I think it's identified uh the issue already.And let me explain this even though uh it's starting to write it out already for us which is awesome.Thank you Genie Code.But here's what's happening when you're running code just in a notebook.It's just going line by line and running the code.But within this ETL process and just ignore that for a second cuz I'm just going to let it run within this ETL process.What it's using is something called an STP which is a Spark declarative pipeline.
This is just a different construct and a different framework within the ETL pipeline.And so what it actually needs is something called a materialized view.It needs to kind of look at what the output is going to be or supposed to be.It's not just blindly running your code for you.It's doing a lot of heavy lifting with data quality checks and all these different things.Now it just went through uh and it fixed it for us.It is basically the same code and let's come up but it's creating these materialized views.So we have dp domaterialized view and it's kind of naming it and giving a little comment on what it is.It's doing the work for us and it's creating another materialized view where we use this insights goal and it's actually putting it all into one which is fine if that's what we want to do with uh this pipeline.
But let's go ahead and accept this and let's try running this pipeline again.So now we have a little bit more information.We can come right down here and we can see it was trying to create these different materialized views and it was working.And so now this whole thing has run successfully.Let's actually rename this really quick.We're going to do bronze.Uh, I need to spell bronze, right?Bronze to silver to gold ETL pipeline.And let's save it like that.And we come back over here.We can go to our jobs and pipelines.We now have this pipeline right here.Of course, uh, it failed, but now it's running and it's working successfully.But now we have this pipeline that we have stored and we can actually start using this in, you know, automations where we can orchestrate these pipelines.Right here it says orchestrate notebooks, jobs, queries, and more.
And there is a lot to that, and that's what we're covering in the next lesson.But if we open this up, we can actually see what's happening under the hood.We can see these are connected.We're doing this one and then this one.And we can see how it's running.And so there's a lot of things that this ETL pipeline is going to handle for us that we don't even have to worry about.That really is one of the biggest advantages of using an ETL pipeline instead of just running your notebooks.Although again, there are some advantages to just running your notebooks as is if it's a little bit of a simpler pipeline.I really hope you're able to follow along with this lesson because this is really cool stuff.You can also just come into here and we can create an ETL pipeline and you can create a pipeline with AI.
So we can literally just come here and we can type in exactly what we want our code to look like and do within our data and it can build that out instead of starting with a notebook and thencreating our ETL pipeline.you can just come right in here and start doing that process here.I will say though my personal workflow because I'm usually not doing super complex pipelines that are involving, you know, ton of different dependency chains and all these different things is I tend to like writing my code in notebooks.That's just what I'm used to.Uh but there are going to be lots of use cases where you're going to need to come in here and you can just start here instead of starting with a notebook.Now, in the last two lessons, we've been building out our ETL pipeline.We've been writing all of our code and getting everything set up.
But once we actually have everything set up, then we need to automate this process so that we don't have to manually go in and run the code ourselves.Luckily, data bicks has this already built out for us.It is called a job.And so, we're going to jump into data bicks.We're going to create our own custom job and we're going to see all the small things that you need to do in order to create this automation.Now, in our last lesson, we built out this bronze to silver to gold ETL pipeline.And we're basically creating two separate tables.This S3_clean silver and then this insights gold.And that is our silver and our gold tables after they're transformed.And we find our business insights.Now, just for demonstration purposes, I also just kept our regular code in here as well.We have this bronze to silver.
Then we have another notebook for silver to gold.Now, these are just regular notebooks and data bricks, but I do want to show you how you can use this within a job as well.But we have this bronze to silver transformation.You can see it in a pipeline.And then if we just go to our bronze to silver, this is just a regular notebook.Now, in order to create our job, let's come right down here.We're going to go to runs.We're going to come over to job.And this is orchestrate notebooks, pipelines, queries, and more.So, let's come in here.Now, this is a new UI for us.And what you can do here is you can orchestrate the different steps that you want within your job.If we click right down here, we can see all the things that we can do.We can create ingestion pipelines or we can use existing ones.
We can come down here and we can run notebooks, Python files, SQL queries, SQL files and we have some more advanced things right down here like if else conditions or you can uh create triggers from another job andthen we also have this ingestion and transformation and these are really useful because if you have an ingestion pipeline, an ETL pipeline or a database table sync then you can just use those that you've already created.Now we've created an ETL pipeline.Let's go ahead and click on this ETL pipeline.We're going to come down here and we're going to click on this bronze to silver gold ETL pipeline.Now, I'm just going to call this uh bronze to silver to gold.Keep it simple.And all we would need to do is create this task.Now, of course, that would be a little too simple, right?
But this is as simple as it can get for any type of pipeline orchestration that you're trying to do.Oftent times when I'm creating entire pipelines and there's a lot of different steps to it, I package everything into an ETL pipeline and then I just place it in here.And then what I'll do is I'll come over here to schedules and triggers.Now we'll look at that in just a second really quick.We can also trigger a full refresh on this pipeline.So we can click on this.We can also add notifications if you want to send this notification when it kicks off or when it finishes.We can also look at retries.Now, this is really important because sometimes you are going to have things that fail just for a various number of reasons.Maybe you're trying to run this, but the data hasn't all imported yet, and so you're trying to run this transformation, but there's some connection issue, and that caused it to fail.
You'd want to retry maybe an hour later or on a different day.You would want to attempt to try this.And so, you can come in here and you can say, "Okay, I want to try this a ton of times.Let's try it 30 total times."And every single time, we're going to wait maybe 30 or 40 minutes between each try and then it'll keep trying until it is successful.Again, with this, you can notify yourself and make sure that you know what's happening, especially if this is a really important pipeline within your company.It is important to have these things set up so you don't have to manually go in there and see it failed, you know, last night and just never got a notification.It never tried again.So, this would absolutely be something that you'd want to do.And then you have metric thresholds.
You can set these, especially for something like a run duration.If you know this should take five minutes at most, you can set a timeout threshold or a warning threshold at maybe 30 minutes so that it isn't just going to keep running because sometimes it gets stuck in theseloops and it keeps trying and it's going to run forever and it's going to cost a lot of money and you don't want that to happen.So, these are all really important things to think about when you are actually creating these jobs.Now, let's come back here to schedules and triggers for something like this.When you've done almost all the work in an ETL pipeline, you are going to want to schedule or trigger this most of the time.Now, for something like this pipeline, what we've done is we've extracted data out of an S3 bucket.
What we would want to do is probably set a trigger for this.Now, what we need to do is we need to create this task first.So, that is saved in there.And then let's say this is our entire job.It's a very simple one.But now we can come in here and we can add a trigger.There are several different types of triggers.When we have a schedule, which is as simple as it sounds, we are just going to schedule this.Right now, it'll be active.You can pause it.We're just going to schedule this.And we'll say every one week.And so, every one week, we're going to save this.And this is going to run every week.So, that's super simple.Now, let's delete this.And let's add another trigger.We can also schedule it.We can go a little bit more advanced.
And we can schedule it at a very specific day and time.Now, this is what I usually do because there are certain cadences and timing to things that I really like.For example, at a previous job that I used to work at, we wanted the data to be as fresh as possible because we actually had it refresh often, like every 10 minutes.And so, what we were doing was we were trying to run it as soon as we could in the morning to where it would still run, but it would give us the freshest set of data by about 8:30in the morning.So, we would kick off this job at like 7:45 so that the freshest data would be available by 8:30.This is more advanced.You don't have to do this, but this is a really useful thing to do.The next thing that you can do or the next type of trigger is a file arrival.
So, if we click on file arrival, we're going to say when a file arrives at this location, kick off this job and run everything within it.Now, for our process, this would be like our S3 bucket.If and we can go and look at our S3 bucket.If a new file gets dropped in here or this gets updated, then we may trigger this job and it will run.And of course, we have advanced settings as well where we can wait a minimum time between triggers because what if you're uploading a lot of documents at the same time?You don't want it to trigger 20 times because you just dropped 20 different files in there one at a time.You'd want to wait for all these files to get in there.So, that is absolutely an option.And if we go back, we also have a table update.
So this would trigger when new data is updated on a table.Now for our use case, this may work because we have S3 data.We're bringing it into our bronze table.So I can come in here and I can say when this table and I would just specify that table name that we've been using.when this bronze table gets updated from that S3 bucket then kick off this job which of course this ETL pipeline takes that bronze data we transform all the data we create our gold tables and then we have allthat data sitting there so this might be a really good use case we have some advanced options down here minimum time between triggers and wait after last change just like we did before because sometimes data gets updated continuouslyand so it might trigger it many times these are things that you should test and try out within in your pipelines just to make sure you get them right.
Now, let's cancel out of this and let's actually get rid of this entirely.Let's actually come here and we're going to go back to our runs or sorry, back to our jobs.And I want to show you one more thing within here that might be really useful.Now, we just kind came down here and we pulled in uh this ETL pipeline, but let's actually pull in and run a notebook.So, we're going to specify our notebook.We're just going to do this is our bronze to silver and this is a notebook.It's within our workspace, not a git provider.And let's select our notebook.So, we're going to come in here.We're going to do bronze to silver.Let's confirm this.And you'll notice we have a lot of different options in here.Some similar, right?We have retries, we have notifications, and we have metric thresholds, but we also have parameters.
These are parameters that you can pass down to the task.Because this is just a notebook, it doesn't have all that built-in stuff that we were talking about in the last lesson within the ETL pipeline.So you do need to configure this a little bit more within a job.So we can add these parameters where we create these kind of key value pairs that we pass into uh a notebook.But let's come in here.Let's create this task.And now we're going to add in another task.So let's come here.We're going to add in another notebook.And this is going to be our silver to gold.Now, these two tasks, and let's actually name this these two tasks that we've created, these two notebooks do the exact same thing as our pipeline.But I wanted to show you this because it does give us some more information when we're actually building out these jobs.
So, we've specified our path.We have our computer serverless, but now we have something called a dependency or a dependency chain.This right here, this line is a dependency with what we have right now.This silver to gold is completely dependent on this bronze to silver.Which means if we get this data in and this bronze to silver does not run correctly, then this silver to gold is never going to run.And in this use case, that's perfectly fine because this relies heavily on this bronze to silver.But there are going to be use cases where that is not the case where we would not want that to be, you know, a dependency.We wouldn't have to rely on it.Or we also have an option right down here to run if dependencies.And we have a lot of different options.So right now, all succeeded means this has to run properly in order for this to run.
But there are going to be cases when you create these chains or these dependency chains where you're like, it doesn't matter if this one runs.We just want it to run after this one runs, whether it fails or not.And so for that one, you can come in here and say at least one succeeded, none failed, all are done, at least one failed, or all failed.It doesn't matter.You can specify whichever option you need.For us, we would want to keep this all succeeded because if this one runs, we don't actually create the silver tables that are needed in order to run this one.So that is pretty important.We can come down here and we can create this task.And now we have this job that we've created and we can run it now or of course we could add in our trigger.
Now typically with something like this it could go either way.You could have it on file arrival table update or a schedule.It really is just very dependent on your workflow and how you want this to trigger.For most of these you're going to have some type of trigger.Let's just set it on a schedule.And let's go to advanced.And we're going to set this for every week.And let's do this on a Monday.and let's do it at 7:45 because that's when I used to do our some ones at uh a previous job.So, I'm going to do at 7:45 every morning.Let's go ahead and schedule this.And now we've updated this job.And now we can also rename this.I'm going to call this our silver to gold job.So now if we go back to our jobs and pipelines, we have our silver to gold job right here.
This was the pipeline that we built out in the last lesson.And this is going to be orchestrated and scheduled to run this pipeline.Well, actually we used uh the notebooks instead of the pipeline for that last example, but we're going to be running that code to actually create and update those tables.So that is how we create a job in data bricks.This is extremely extremely useful.Again, like we did just a little bit ago for our silver to gold job.And let's go into the tasks.If it's a really small transformation and maybe it's just for me, I'll just do it like this where I just have the notebooks.But if it's a larger transformation, especially if there's a lot of dependencies, if there's a lot of complexity, I will use an ETL pipeline.So get in here, mess around with this, try this out because this is super fun to play around with and kind of get all those dependency chains going and getting the ETL pipelines where they're triggering off of each
other or when a file is updated.This is really cool stuff to mess around with and is awesome to use within data bricks.Now, if you haven't been following along in the past three videos in this series, we've covered several things.One, we've just learned about ingesting data.Then after that, we looked at ETL pipelines and then we looked at creating a job to orchestrate all these things and to kind of automate the process.In this video, we're going to be putting all of that together into one.We're going to add some things that we didn't cover in previous lessons to make it a little bit more advanced, but it's going to cover a lot of the same concepts.Let's not waste any time.Let's jump right onto my screen and get started.Now, before we actually jump into data bricks, what we're going to be working with is that same S3 bucket that we created earlier, but I created this transactions folder, and that is going to be an important piece of
this process.It's something that we touched on in a previous video, but we actually going to be doing it in this lesson.So, we use this users_y.csv CSV in this bucket.But inside of this transactions, we have three separate transaction files.And we'll actually be adding another one later on to show how the entire process works.So, I'm going to have these and the other file down in the description.You can just download those from GitHub, but we will need those.So, we're just going to start off with these three, the 16, 1_13, and 1_20.Now, really quick, just to show you what data we're working with, this is our data.Let me actually zoom in just a little bit.Uh, the data itself is not as important for this specific project just because we're more focused on the process of building the pipeline within data bricks, but within the project, we will be cleaning this data a little bit
because this is just a horrible column.Uh I think whoever you know was collecting this data just left this free text or something for people to just put whatever they wanted in there.Uh not a good not a good system but that is the kind of data that we're going to be working with.So let's come up here.Let's get out of this.We don't need to save it.Now let's come up to our data bricks.Now in our previous lesson this is what we built.We built this uh pipeline right here.Bronze to silver to gold ETL pipeline.And then in the very last lesson, we created the silver to gold job which basically scheduled this and automated this and it ran successfully and everything was great.Now what we're going to be doing is we're going to be doing it in a similar fashion but covering some new things.
All you need to do and I actually have another tab for this cuz I don't want to have to keep going back and forth when we're building this out.But I created this end toend schema within our data engineering catalog.You don't have to do this.You can put this wherever you want.I just did.This is kind of where we'll be building things out.So, I'll just come back to this as we start adding in new tables, as we start creating this stuff.I'm going to come back to that.Now, this is where we'll be doing a lot of our work on this uh tab right here.So, let's come over to data ingestion.Let's go over to our Amazon S3.Now, if you haven't already, in a previous lesson, I think the second video, we connected to an S3 bucket.So, if you don't know how to do that, then come over here and do this.
Now, we used it for the one time because all we used was this users dirty.csv.But in order to schedule this data ingestion, we're going to use a folder.So, we have this transactions folder right here.So, we're going to click on this.We're going to click on transactions and we have those three separate files in there.And we can schedule when we want to bring those in.Now, we can be very specific or pretty laid-back.Uh, so for example, if we want to do, you know, once a day, we can specify what time of day we want that.And that's similar to a job.So it's not that crazy.Now, what we're going to be actually doing is we're going to schedule this for basically every 30 minutes.And what we're going to do is we're going to build this entire thing out.And what our trigger is going to be inside of our job is when a table gets updated.
So then we're going to drop a file in our S3 bucket.And when this brings it in at that 30 minute point, it's then going to refresh, kick off the job, which runs our ETL pipeline.We should be able to do all this within 30 minutes for sure.So, I'm going to say every 30 minutes, and we'll just set it at 0 minutes past the hour, which means at basically the top of the hour.Now, this is my time zone, but you can set it to whatever time zone you want.Now, let's go ahead and preview this table.It's going to start up our compute.Then it's going to give us uh basically what we need in order to create this table, which is our preview, and then where we want to place it along with the table name.Now, an important thing to note from just those three files is there's only 50 rows of data in each one.
So, if we come down here, we got all the way up to 100.So, we at least know two of those files are coming in just from this preview.We're going to keep this as the transactions, but for the schema, we're going to add the end to end, which is the custom one that we created for this project.So, we have transactions right here.Let's go ahead and create the streaming table.So, now this table has been created.Let's just look at a sample of this data.It should show us enough to be confident all three got in.But then we can just also run a query and that's perfectly fine.In fact, instead of waiting, uh, never mind, we got them all in.I was going to say we don't have to wait on this.We could just run a query in like a notebook or a SQL editor, but we have all 150.
So that's all three files.So now that we know we have all three of our files in cuz it's 50 each.It's going to be 150 rows.Now that we know those are in, we can start building things out.Now that we know that it's all in there, what we can do is let's come over here to our jobs and pipelines.Now this is where we were before.We only had these two things.We had a pipeline and now we had a job.And now we have another pipeline.And we didn't build this ourselves.This was built automatically.And if we come in here, we can get a little bit of information on this.This is our streaming pipeline that we created to put into this endto-end transaction.So this is that streaming table that we created.And so we don't have to technically manage this.
It's going to be managed by data bricks itself.And so this is just something to note that when we did that, we did create its own pipeline for this.Now what we need to do is we need to create an ETL pipeline.So let's come in here.We're going to click on the ETL pipeline.This new UI pops up right away.We don't have the options that we had before in previous lessons.Um but now what we're going to do is we're going to start building this out with Genie code.Now, I could absolutely just write all this out and this would be like an hour and a half video, or we can have Genie Code write it out, which I highly recommend trying it out and starting to usethese tools because they really speed up your work.And if you already know how to program, if you know how to code, this is going to be a huge boost to your productivity.
And so, what we're now going to do is use Genie Code right down here.Basically, tell it what we want to build.And we're going to do a few things.One, we want to build that bronze to silver, which is basically our raw data, which is that transactions table, to a silver table, which is where the data is cleaned, to then a gold table, which is what wewould use for like a production level uh product or production level analysis or whatever that might be.So, we can come in here and we can use that at and it is prompting us to do that.And if we come in and we can say data engineering.end end to end.And I'll just put it like that.So, it's looking kind of at that schema.I'm just going to say uh for the transactions table, I want to create a bronze to silver transformation on this raw data.
I want you to clean this data set.I'm just going to leave it really open-ended just to see what it does.Maybe it catches something outside of that column.I don't think it will, but uh let's just see what it does.Then we are going to create a silver to gold transformation.And you can do this in the same notebook or separate notebooks.It may also do that for you with Genie Code, but you can be really specific and it's honestly pretty great at what it does.And I want to track daily transactions in that gold table.So I'm going to give it just this to work on.It's going to take that.It's going to kind of create its logic.It's going to start writing everything out.Um I have found this is not just me saying this.I genuinely love working in this system because Genieode is very good at understanding context and what you're trying to do and working with tables and just everything.
And so we're going to let this run for just a little bit.I'm going to come back.We'll take a look at what it said and then we'll commit some code to start going on the CTL pipeline.All right, so it just finished.I haven't even really reviewed this cuz it only took, you know, 30 seconds, but it took a look at the data.Then it came down here and gave a proposed pipeline architecture.So here's what we have.We have our bronze layer, which is just going to be our transactions.py.And this is just going to read in the data as is.So, it's going to recreate basically the raw data, which I'm totally fine with.It's not a big deal.Then for our silver layer, we have the silver transactions_clean.It's going to trim the white space, standardize capitalization, remove duplicate spaces, filter out null transaction IDs or negative quantities and amounts, and add data quality expectations.
I think these are all perfectly reasonable things to do.Then, we have our gold layer.There's going to be transformations gold daily transactions summary.py.py.So there's three different files that it's going to create and it's going to aggregate some of this data into kind of these metrics right here.I think this all looks great.If there was something I wanted to change, I would just tell it, hey, let's do this instead.So let's just say go for it.Start writing the code, my friend.It really is my friend at this point.I've been using it a lot.So let's let this run.Let's watch the code and then we will commit everything.And then it probably will prompt us to do some type of dry run to make sure that there aren't any errors that were just missing.And then we will run the entire thing and start automating this with a job as well.
It's still writing.That was like 10 seconds.I stopped talking, but it's still writing everything.It's going to start organizing this.It's going to start creating our py files or just our Python files.I just am reading it as is.uh but it's creating our Python files and then it's going to start writing the code in which we are then going to review approve and then run.You can see these things starting to pop up.So we have our code, we have our diff or you know if we had code that it took out it would also say the minus.Uh but we're just creating code right now.And so right here it's saying all right do we want to try dry running this pipeline?Do we want to just see if it works?Um, and of course we're going to do that in a second, but I'm going to go to each one just to kind of see what it's doing.
It looks like this is our gold, and we're just using a group by for this.Uh, let's just see what it did for the data cleaning.So, it looks like it is going to drop some stuff in here, but we are looking at some regax replace, which is great.Some trimming and proper case uh for a few other stuff.And this looks perfectly uh good to me.I have no problem with what it's doing.Again, this is all subject to be altered.If you want to change this or have it do other things or fix the code yourself, you absolutely can do that.Now, all we're going to do is we're just going to accept this.And so, we're going to allow this and it's going to run a dry.So, we'll accept review next.We'll accept review next.And accept.I didn't have I could have done that a different way, but now we're going to try dry running this pipeline.
Now, what this does is it is not going to actually run through and run your code.It's doing a dry run.It's basically testing are there any big errors that we need to fix before you actually implement this into you know whatever process you're doing so that you don't have issues right off the bat.It's going to run for just a little bit and then it'll tell us if there's any big issues.Um oftent times if you've never done this before you shouldn't have any big issues but you could get issues like oh this table uh you don't have the permissions for this table.Maybe you wrote something incorrectly or in this case uh you know Genie code wrote something incorrectly that is not going to create the materialized view properly or you're pulling from a table that doesn't exist anymore.So there's lots of issues that could arise but let's let this run.
It shouldn't take very long and just like that we did encounter a small issue.Um it's actually going to run.It'll probably fix this very easily.Um, I am not exactly sure what the issue is here.Just glancing at it, but it looks like it's fixing that code for all of it.And let's go ahead and just accept that.And let's try dry running this one more time.Now it looks like everything is running properly.And this is really good.So what we can now do is we can rename this.So it's going to give us some feedback on that.But I'm going to rename this.And I'm going to say this is our end toend uh ETL pipeline.And that's what we're going to name it.So we have our endto-end ETL pipeline.And with this, if we come back here, obviously nothing has changed, right?
This was just a dry run that we did.Now what we can do is we can actually run this pipeline and it will run everything.It's going to do all the transformations, all the things that we would want it to do and we should and we will do that in a little bit.Now, what we want to do is we want to automate this process.All we have to do is we're going to come back here to not data ingestion into runs and let's get rid of this.Now, we're going to create a job for this.So, we're going to come in here and we're going to say we want our pipeline.And if we come in here, we have our endto-end ETL pipeline.That's the one we want.We're just going to call this um end to end ETL pipeline.Keep it simple.Now, what we're going to do, and you can always come in here and add notifications and retries and metric thresholds, which we covered in the last lesson.
Now, we're going to create this task, but now we're going to add this trigger right here.Now, this trigger is going to be a table update.So what we want it to do is when new data is actually updated and brought into that table, we want this job to kick off so that it runs our entire ETL process to clean the data and putthat new data into our, you know, new tables that we're creating.Now what we want to do is we want to say this table when this table gets updated.So let's come up here and we're just going to copy this name to the clipboard and we're going to put it right down in here.We could also have typed it out.Um, either one's fine, but I just wanted to copy it.So, when this table gets updated by our S3 process, which we're running every 30 minutes, this is going to kick off the ETL pipeline, right?
It's going to kick off this right here.So, now that we have that job updated and created, let's go back to our jobs and pipelines.And now we have a few new things in here.So, right here we have our endtoend ETL pipeline.I should have named this job.Let's actually come in here really quick.I'm just going to come up here.I'm going to rename this.I'm going to say job to run N2 to end pipeline.And let's rename this.So, we have our pipeline.We have our job to run the ETL pipeline.And we have our transactions.That's going to run 30 minutes uh on the minute.It looks like um it may have already run before.No, I think we're good.No, it did.It's already run twice.I think that's just because of when I set it to the zero time perfectly fine.
Um, but what we're going to do now is we are going to just check that this end to end ETL pipeline is working properly.It's going to create all of our tables.We're going to then write a query just to show that the data looks good.And then we'll go drop our extra file in there.And then we'll wait to have it update and the ETL pipeline bring in the data.Then our job is going to trigger.And then it'll run our ETL pipeline to bring in and clean that new data as well.So let us run this pipeline.This is going to take just a little bit to actually run and then we'll go check the data in just a little bit.All right.So this looks like it worked properly.We have completed completed and completed.Let us come up here and let's go back and let's refresh this.
And it is possible that I put it in the wrong place and it totally is.I absolutely forgot to change that in the ETL pipeline.It is pointed at the workspace default.Let's actually go back and you know this happens.We're going to edit this pipeline.So it is our default catalog that caused this issue.We have our default catalog and default schema as workspace and then default.Um you can change this.You don't have to, but you absolutely can.You also, if I'm being honest, I should have fixed this myself or caught uh this right away.I like to be explicit when I'm, you know, writing to places.I don't like to have defaults like this.So, I should have had it specified right here where we're writing.It should have been like, uh, you know, data engineering.end to end dot and then the, uh, table name just to be more explicit.
And we should have done this in basically all the Python files within the ETL pipeline.Totally fine though.Not a massive deal, just you know, something to think about.Now, if we come back to this catalog and we look at this, we can go to let's go to the silver transactions clean.This is going to be our cleaned data.Let's just go ahead and run this real quick so we can look at that sample data.So now this is our clean data.This product name looks much better.Uh looks really good.It did a few other really small things in here, but this is the main one that we're looking at.If we go back to the bronze transactions, uh, and look at our sample data.So, this is our bronze table.This looks terrible.So, obviously, it did a really good job data cleaning it.
Uh, and then we'll look at the gold daily transactions summary.
And this is looking at the transactions just grouping by and then looking at a lot of our data.And this is great for like a gold table uh that we're going to be using for you know some metrics or whatever we want to use it for.So all of this looks really good.Now in our silver transactions clean in our sample data again we at least in the sample we only have 100.Let's go and run this.So let's actually create a notebook with this and let's run this query.So now we can see we have 150 rows and let's add code and let's copy this and instead of the transactions clean we'll say uh let's go see what that table's called.It's not gold customers.I should have kept it up over here.Let's go back to our catalog.See when I start when I start messing with my systems I start getting messed up.
It's gold daily transaction summary.I could have gotten copied it somewhere else.Uh, but I'm going to put it right here so that we can look at this.And what we're going to do now is we're going to go drop in that other file into the S3 bucket so that we can see when it gets updated and to make sure that the new data gets inthere and gets cleaned.So, let's come over here.We're going to upload and let's click on add files.Now, we're going to come here.We have that 127.That's the new one that we didn't have before.Let's upload this and put this into our S3 bucket.And now we have 06, 13, 20, and 27 all in this S3 bucket.So now what we're going to do is we're just going to I'm going to literally just let this wait.
Let's come over here and right here, this is going to kick off in probably like five minutes or so.I'm just going to let it run.This is going to kick off and then you will see that this job to run the end time pipeline will automatically kick off as well once that table is updated.So let's just be patient.Let's just wait.I'm going to skip you ahead and you will see this running in just a little bit.All right.Now you can see that this is kicked off.Looks like it is running.When this process is finished, it is going to update that table with the new data which is going to trigger this job right here based on this table update on data engineering.toend.transactions.And that should start any second here.And it looks like that is working.We can see this one running.
And since it is literally running this pipeline, we can also see that this one is going to start running as well.It's just spinning up the compute so that it can run properly.Let's go ahead and let this run and then we're going to see and check in our queries if everything actually went through properly.All right, it looks like this uh job is still spinning, but the pipeline was kicked off successfully.It looks like it ran with no issues, which is exactly what we want.And now this job is done.So now our entire process is complete.And it is going to keep doing that every 30 minutes.uh every single 30 minutes from now until I stop the job or I stop this pipeline from running, it is going to kick this off.It's going to kick off the job.It's going to kick off the pipeline every 30 minutes.
Of course, I'm going to stop that cuz that's nuts to keep running.But let's come back.Let's go to our workspace.And I think it's this one.Let's go take a look.Yeah.So, now we have 150 rows.Let's go ahead and run this.We should see 200 rows of data.And there we go.And let's just make sure it's all cleaned properly in that product uh name.Looks great.And let's come down here and let's just make sure that this gets updated.We have 21 rows, but more than that, it's about the data because this is aggregated.So, um let's go ahead and run this as well.And we have 28 rows.That's just another week's worth of data.And these numbers are actually look uh basically the same, but we have this new uh week's worth of data in here that we didn't have before.
So that is the entire NTN project.It really brings everything together that we've been working with in the past several lessons into one final project.And I hope you were able to follow along.If you didn't follow along, you just watch this video to the end.I highly recommend using the free edition.I will have a link in the description.You can try all this out completely for free.You don't even have to enter a debit card or credit card, which I love.So, you can just use this and it is an amazing platform to try out.I highly recommend it.But with that being said, thank you guys so much for watching.I hope you like this video.I hope you learned something in this entire series.If you did, be sure to like and subscribe.I'll see you in the next lesson.
26:40:14 - 26:40:20
What's going on everybody?Welcome back to another video.Today we're going to be setting up and installing R and R Studio.
Now, this is our very first lesson in this series, so we're just going to be installing and getting R and R Studio set up.In future lessons, we're going to be diving into the basics of R.We'll be grouping, aggregating, visualizing, cleaning, and a ton of other things using a lot of different packages that are very popular within R.By the end of this series, you should feel very comfortable using R and R Studio.If you haven't checked it out already, I have a full course called R for data analysis over on analystbuilder.com.I will leave a link in the description as well as a coupon code if you want to take that full course.It covers more topics, has practice problems throughout the course, as well as goes more in depth, and has more difficult projects.With all that being said, I'm super excited to get started on this series with you.
Let's jump on my screen and get started.All right.So, let's get started in downloading R Studio.Now, R Studio is created by a company called Posit.Now, R is the programming language, but R Studio is the interface in which so many people interact with R.And so, we're going to be using R Studio throughout this entire series.What we need to do is first install R.And then next, we need to install R Studio.R is going to be installed almost the exact same way on every system.And then for installing R Studio, it's going to autopop populate this for Windows because it recognizes Windows as my machine.But if it doesn't, if it gets the wrong one, you go down here for uh Linux, Mac, Windows, whichever one that you want.So, let's get started by installing R on our machine.I went ahead and deleted R and R Studio from my computer.
So, I'm starting fresh just like you.We're going to come right here.I'm going to do download R for Windows, but if you have a different type of machine, be sure to get the correct one.I'm going to download R for Windows and then I'm going to come up here and say install R for the first time and then we're going to get this package right here.So, let's go ahead and click on this and I'm going to go ahead and download it.Now that it's done downloading, I'm going to go ahead and open that.exe file.You may not be able to see it, but it just says, are you sure you want to download this?And I'm going to say yes.Now, we need to set up our language.I'm going to choose English, but go ahead and choose the correct language for you.
I'm going to click okay.We're going to click next.And now we're just saying where it's actually going to be placed.So I by default it gets placed in my C drive under program files.That is where I want it.So I'm going to go ahead and click next.You can select your components.We want all of them uh just by default.And then it asks if you want to have this, you know, boot up on startup.I'm going to say no because I don't need it all the time when I'm, you know, restarting my computer.And then you can name this as well.I'm just going to keep it as R.Again, I don't really need a desktop shortcut or a quick launch shortcut.So, I'm just going to get rid of that.And now it's going to install on our computer.That took about 30 seconds.
And we now have R on our computer, which means we can come back here and we can install R Studio Desktop for Windows.Again, make sure you have the right one for your operating system.I'm going to go ahead and click on this and we are going to save this.Now that it's done downloading, let's go ahead and open it up.Now, we're going to set up and install our R Studio.Let's go ahead and click next.We're just selecting our location.Make sure you have enough space required.It's very small, but that's happened to me in the past where I have no storage.Then it doesn't really work.So, let's go ahead and install this.It's going to install.Again, this should only take about a minute or so.Now that R Studio is completely set up, let's go ahead and click finish.And now, we're going to go look for it.
So, we're going to come right over here.We're going to say R Studio, and we're going to open up R Studio.It says we need to choose our R installation because R Studio requires an existing installation of R.We're going to go ahead and choose the default one.We're going to click okay.And now R Studio from Bosit is popping up for us.And just like that, we are in our studio and now we have our user interface that we can take a look at.So really quickly, let's take a look at what we have here.Right here we have our console, our terminal, our background jobs.But this is our console.If you are looking for uh where you can write code, it's going to be right here.We just need to click on this R script and it pulls up our coding workspace right up here.
Now, this is where we can uh start typing.We can bring things in like reading in a library or a package and we write all of our code in here.Down here is our console.So, when we execute code, this will be where we get error messages or we can see the output of our code.On this right hand side, we have our environment.Now, this is where if we uh pull in some type of data frame or if we create variables or lots of other things that we're going to be doing throughout this series, they will show up right over here.And lastly, in this section on the bottom, you can actually come in here and we can select a file path to give it.So, let's come in here.Let's go to our YouTube and uh this is going to be our R series.
So, I'm going to open up our R series.We don't have any files in here just yet, but I'll have access to our files where we can then pull them in or read them in.And it's really great that R Studio has this because you use a lot of files when you're working within R Studio.This is absolutely something we will use quite a bit.We if we come right over here, actually, we can do Ctrl S and we can save this.Let's go down to our YouTube and I'm going to go to this R series and I'm just going to save this as first file.And if I save it, you'll see it saves as first file.R.Now, that's actually not a good naming convention.I should use an underscore there.But these are all things that we will get to uh within this series.
Now that we have everything set up, we can keep going in this series moving forward.We're going to learn a ton of different things.But with that being said, I hope that this is helpful.I hope you were able to get everything set up, and I will see you in the next lesson.
Hello everybody.In this lesson, we're going be taking a look at the basics of using R Studio and R.Now, right down here in the last lesson, I showed you how to access uh kind of a file path here.And you can see what files are in here.And all you have to do is click on this.And then your file folder comes up.And then you can click into wherever you want.You're going to open it up.And these are some of the files that we're going to be using later on in this series.Over here on this lefth hand side, we have our console opened, but we can't interact with this data or write code yet because we don't have an R file open.So, what we're going to do is we're going to come right here.We're going to open up an R script.
We can also open up a ton of different files.In fact, at the very end, we'll be opening up an R markdown file to create a dashboard for some data visualization.But you can open up lots of different files here if you want to do that.We can also open up these files over here.So if we want to, we can do that.But if we open it up right here, then we can name it and then it gets saved into that file path.So we're going to call this one the basics of R.And we're going to save that.So now we get this open right up here where we can actually write our code.Now I say write our code.We can actually write code down here in our console.And I'll show you that in a little bit when we start creating some variables and expressions and different things like that.
But for me personally, most of my workflow is going to be up here.So I'm going to add some uh lines here so we have some room to work with.The other thing that I typically do or have set is a soft wrap long lines.Now if we don't have this, if I say I uh am writing something, this is going to be our code.Let me spell this right.And I add a bunch of dashes.You're going to note it just keeps going and it keeps going.Um, especially as we start bringing in code or we start bringing in files.Um, we're going to want something like this, which is a soft wrap, which will wrap it to the next line.And so, we still are on line two, but it is kind of all in our viewing area instead of being way over to the right, which I personally don't like.
So, I'm going to get rid of this.Now, we've opened up a file.We now have access to write code in R.And what we're going to do is we're going to start with the very basics.And I'll kind of show you how you can write it up here and you can write it down here.Now, one thing to note is we have this little sweep button right here.This is our clear console.We can click this button.It's going to reset everything over here.And we also have a sweep button over here.We can clear out our environment.We'll be using both of those, but let's get started with the basics.So, we're going to take a look at variables.Now variables are where you're going to assign a value whether it is a string or it is a number to a variable which is then stored in R's memory.
So let's call this one the num variable.We have to use an assignment operator.Now this assignment operator right here essentially says take this number.We'll do 42.Take this number and put it within this numbum variable.Now we want to run this code and we can do that by highlighting our code like this and doing controll enter.Now that we've ran it you can see over here it is store that as a value.We have our numvar.Then we have 42.Now that we have this what we can do is we can say print and we'll do num_var.If we print out you're going to notice down here in the console 42 is printed out.So we printed it out up here where we're actually writing our code into our console.But we can interact with our code as well down here.So we can do num_var and then we can do times 2.
And if we run this, we get 84.It just doubles it.So we're able to write this.But notice if we come up here, let's do ctrls.I just saved this file.If we get rid of this, so let's get rid of our basics of R and we're going to clean this out.If I pull back up our basics of R, that multiplication times two is not there.So, we don't have access to the code that's written down here in our console.So, that is okay if you're just messing around and kind of looking at your code.Maybe we've pulled in a data set and we're looking at data.We don't really want to save it in our code.That's okay to write it down here.But anything you want to save, it is best to write it up here.Otherwise, when you save it and you exit out and you come back later, you won't have it.
Now, I told you that this was numeric and we can actually check that by using this class right here.So, we're going to say we're going to pass through our variable.So, we have our number var.We're passing through this variable into this class function.And what it's going to do, it is going to output the data type of this right here.Now, of course, we're passing through our variable, but in the memory, it has this stored right here as the value in memory.So, we are looking at this right here.We're not actually looking at the text.So just something to note.Now we don't have to just store numbers like this.We can store a lot of other things including string.So if we want to say we'll call this a string variable.You don't have to do this uh but I'm going to do it.
But we can put it in parenthesis and say I like R.And if we save this, you're going to see I like R here as our string value.So, we can also store strings as well as numbers.Now, all we're going to do for the rest of this lesson is take a look at a few different ways to store data inside of variables.Those are things like vectors and lists and maybe even a data frame.These are common ways that data is stored within R.And so, really, that's all we're going to take a look at.If you already know data types within R, this is a perfectly fine time to cut out.In the lessons after this, we're going to go into a lot of other things like operators and expressions, reading in files, sorting the data that we read into dataf frames.We're going to get a lot more advanced as we go, but again, this is the very basics.
So, let's take a look at a vector.So, so far we've only stored something like a string or a number.That's just one value and one value, but we can actually store multiple values.So, let's call this a vector variable.And what we can do is we're going to do a c.Then we're going to open up our parenthesis.And this is going to say that this is a vector.So we can do 10, 20, 50, 100, and thousand.And then when we run this, you'll notice we have this right here.So it's going to say we're storing numbers.And this right here is an index.So we have one through five.So we have one, two, three, four, and five.So now we are storing multiple values within one variable.So vectors are good for storing sequences of the same data type.But if we want to store a lot of different stuff, it could be whatever we want.
We can store that in a list.Now lists are very popular.So we're going to do um a list variable.And what we're going to do is we're going to name each of these variables that we're putting in here.So I'm going to say that the name is equal to Alex.And then we'll say age is equal to 30.And then we'll say scores is equal to we'll pass through a vector here.We'll say 90, 50, and 24.Just like this.Let's go ahead and create this list.Now, we can just call this and we can just say we could even just say uh list var here.And it's going to pull in the name, the age, and the scores.Now, you'll notice we have this little shortcut right here.And this is saying that's what it's called.So, if I only want to call the name, I only want to retrieve that from this list, I can do that.
And if I run it, it's only going to output just Alex, just the name.That's all it's going to do.There are other ways to do this as well.We could uh let's get rid of that.We could do a bracket and we could look at the index.So, if we did a one, let's go ahead and run this.The first index within R is Alex.So we're still pulling up the same one.We could also do it by the name just in a different way.We would need to do a double bracket and pass through name.And we can run this and it's still Alex.So all these ways work.I will say the one that I typically do and this is not just for lists.This is similar if we're working with data frames where we have columns and rows.You can pull specific columns by using this shortcut.
And I do this all the time.So that is how I would do it.That's my personal preference.Now there are other data types within R, but the last I'm going to show you, and this is the one that we're going to be using in future lessons, is a dataf frame.Now, a dataf frame could be you just pulling in a CSV file that has columns and rows, which is what we are going to do.But I want to show you kind of what a dataf frame looks like.So if we come over here, we're going to say dataf frame, and we're going to pass through, and you're going to actually write data.frame.frame.So if we come right over here, it says the function data.frame creates dataf frames which is coupled correlations of variables which share many of the properties of matrices.Now matrices is another data type but we're not covering that one right now.
But let's click on dataf frame and we can pass through different things like this data right here.Now when we pass through this data and let's actually take a look at this.This is what it actually looks like and this is just some of the uh information but it's storing it as data.And so what we're going to do is we're going to do something really similar.Let's say the name.This time we're going to pass through multiple values.So not just a list, it's essentially multiple lists.So we'll do a vector here.And I'm just going to make up some names.So we'll say Alex, Sally, and John.And I need to have that in quotes.And then we'll do a comma.We'll pass through our next one.So this will be age.And we'll do another vector.So we'll say is equal to uh we'll do 30 50 and 99 and then we'll pass through the scores.
And in fact uh let's just keep the scores like this because it'll be simpler.Now let's go ahead and create our data frame.And our data frame is up here in data as well.You'll see it looks a little bit different.This says as a list of three, but this we have this little grid.Now let's actually click on this.It'll pull up this data frame.And now it looks like an Excel spreadsheet.It looks like a CSV file or a database or wherever you store structured data.We have our name, age, and scores.And here is kind of this index that it gives us.And you can see it's all pretty.It looks really nice.And so data frames are extremely popular within R to use, especially with structured data.And this is something that we are going to use when we start pulling in larger data sets.
And that's something that as you kind of work with real data in a professional environment, you'll start working with CSVs and larger data sets and you'll have to do all these things with them.And so that's what we're building up to in this series.So I hope that this was helpful.I hope you learned a little bit more about how to use R, a little bit more about data types and variables.In the next lesson, we're going to be taking a look at operators and expressions.
Hello everybody.In this lesson, we're going to be taking a look at operators.Now, operators in R are just symbols or keywords that perform operations on variables or values if you haven't already put those values into a variable.Now, we're going to take a look at several different types of operators, but if you've been following along in this series, we've already used an operator before.it was something called an assignment operator.So if we have our variable and we go like this, this is an assignment operator.These are characters that say when we put a 42 over here, this 42 is going to stay within this variable.So this already is something that we know.So that is an assignment operator.Now the next one that we're going to take a look at is an arithmetic and I spell this right?Operator.There are other ones as well like comparison operators and logical operators and we'll get to those in just a little bit.
But let's start out with looking at arithmetic operators.These are operators that are specifically built and designed for math.And so let's declare two different variables just to start and then we'll take a look at these arithmetic operators.Let's just do the classic x and y.We'll say x is 10 and we'll say y is three.Now let's go ahead and declare those.We're going to see in our environment right over here.We have our x and our y.Within these variables, we have the very basic ones.We're going to take our variables.We're going to say x + y.And this is going to be, of course, 13.Now, what we can do, by the way, is we can assign this to another variable.So, if we wanted to, we could say a is going to be assigned x + y.And if we run that, x + y is 13.
So, a becomes 13.Now, we don't have to do that every time we do any type of operator or mathematical equation, but if we want to store that value, we can.And this may not look like it makes sense, but it does make sense because we've stored these values.We're adding them together, and then we are assigning them.So, that is just simple uh x + y, but we can also do x minus y.This is just subtraction.And we're going to get seven.So that's 10 - 3 is equal to 7.We also have multiplication which if we do x * 10 and that's the little star right here.So that is on my keyboard the shift 8.If we do x and sorry it's supposed to be x * y we're going to get 30.And so we're just multiplying them together.We have one more of the basic ones and then we'll start going to kind of the more complicated ones.
But that's division.So, we're going to say x and then we're going to do a forward slash y.And this is going to be x / y.And that's 3.3333 because it's 3 into 10.Now, the next one that we're going to look at is a little bit more challenging.This is an exponent or to the power of.So, it would be x and we're going to do this little carrot here.That's what it's called.It's called a carrot.X to the power of y.So, we're going to do 10 to the^ of 3.So, it' be 10 * 10 * 10.And so when we do that, we're going to get 1,00.So that one's really good.I'm sure you've seen that if you've taken algebra or, you know, other types of maths, you're going to recognize that pretty quickly.But this next one is most likely one that you haven't seen.
This is called a modulo.And what it does is it takes the remainder of a division.So if we do x and we're going to do two percent signs of y.If we run this, we're going to do 10 / 3, which means three can go into 10, but we have a remainder of one.And so that's what a modulo is used for.Now, I will say you're going to use these a lot.They're fairly straightforward.They're not crazy confusing.This is kind of foundational math that most people should know.If you haven't, just messed around with those.Uh those are really good to know.Now, I'm not going to dive into it a lot, but have you ever heard of Hemdos?This is the order of operations within math.This is something you need to be aware of because if you do something like, and I'm just going to use numbers.
I'm going to do five * 10.If we do it just like this and we run it, of course, that's going to be 50.But then, let's do divided by 2.And let's run this.Now, of course, that's going to be 25.But if I add plus six here and we run this, this is where it starts getting a little complicated, right?What's happening where and what's going to happen if I add a parentheses around all of this?So this is where PEMDOSS comes into play.PEMDOS stands for parenthesis, exponent, multiplication, division, addition, subtraction.So if we are looking at this, we have to start with the P, the parenthesis.So, we're going to do everything in this parenthesis first before we do anything outside of the parentheses, which is multiplying times 5.We would also do the exponent, which we don't have, multiplication, which is not in the parenthesis.
And then division.So, we would divide 10 by 2, which is 5.Then, we would add 6, which is 11 * 5 is 55.Let's make sure that's correct.And there we go.If we did it in a different way, if we uh put the parentheses over here, and let's get rid of this real quick.If we put the parentheses over here, now we're going to multiply times 50, then divide by two and add six, and that's going to be 31 because we're going to get 25 right here, and then add six toit.And so these parentheses are very important.You will see these in different types of equations and different types of math that you'll work with within R as it is very statistics heavy.So, you know, this is just kind of foundational arithmetic and maths that you need to know in order to work with these types of programming languages.
The next one that we're going to take a look at, and let's give us some more room right here, and these are going to be comparison operators.Comparison operators allow you to evaluate different conditions.So, let's take a look at one.So, we have x and y here.We created those earlier.So, we're going to say x is greater than y.Now, when we run this, we're going to get a different output.We're no longer going to get a string or a number.Now, we're getting what's called a boolean value.Now, this boolean is either true or it is false.So, now if we say x is less than y and we run this, and I did an uppercase, whoops.Let's go ahead and run this.Now, we're going to get a false.So depending on whether it is a true condition, it evaluates to true or it evaluates to false, that's what our output is going to be.
Now we can also add in to these ones an equal than or an equal uh as well.So it would say x is less than or equal to y.And if we run it, it's still going to be false, but you can add that in if you want that these uh to potentially be equal or you want to check for that.The other ones that you really need to know are x is equal to y.Now this is wrong uh because this is actually an assignment operator just like let's go back up.This is in certain conditions within R.We need to say equal equal.This is actually what you need to write.And so it may seem a little counterintuitive but that is the syntax that you need to use.Now x is not equal to y.One is 10, one is three.So of course that's going to be false.
But if we said x is equal to x then this will evaluate to true.The last one that you need to know and this is the opposite of equal to is not equal to.So if we say x is not equal to y that's an exclamation point with an equal sign.If we say x is not equal to y we're checking are they not equal?And that is true.They're not equal.And so these are comparison operators that are very commonly used.You'll use these so often they'll just become second nature.And the last one that we're going to take a look at is logical operators.Now, logical operators, uh, you know, aside from, you know, the basics, logical operators are used all the time for everything.They are here to help determine and evaluate expressions to determine if they are true or if they are false or if multiple conditions are true or false.
So, right up here, let's get this uh x is greater than y.We know that that is true, right?We know this is true.But what if I add I want that to be true.And this is where the logical operator comes in.So we want x and y that way evaluates to true.But we also want x to be equal to x.So we're going to put this right here.So now we're evaluating two separate conditions.And this one right here, this amperand I believe is what it's called, which is a shift uh let's see, seven on my keyboard.This amperand means that both this and this condition need to be met in order for it to evaluate to true.Let's go ahead and run this.So since both of these conditions is true, this is great.X is greater than Y and X is equal to X, this evaluates to true.
But let's change this.We're going to change it to Y.We know this is false.So this is true but this is false.So are they both true?So it needs this and this need to be true.Since one of them is false, we will get an output of false.And so this is what a logical operator is.Now we're going to take the take this exact same thing and we're going to bring it down here and we're going to change this into a bar.and I call it a bar, but it's a shift and it's right above my enter key on my keyboard, right next to the backslash.Um, but this right here means or.So, this is and and this is or.These are the ones you're going to use 99% of the time.So, you're going to say is this condition true or is this condition true?
If either one of these conditions are true, it will be true down here.They don't both have to be true.So now if we run this we're going to get true x is greater than y this evaluates to true or this which evaluates to false since just one of them is true then the entire expression evaluates to truethere is technically one more logical operator and I'm going to be honest I I don't think I ever use this one or if I do it's a very specific use cases.This is the not operator.This is going to say this.So let's run this.This is false.And we're going to run this with the not operator and it's going to change it to true.So it basically reverses the boolean value that is in the output.If it's true, changes it to false.If it's false, it changes it to true.
It just flips the value.That's all this operator does.I think I've used this a few times in very specific use cases, but 99.9% of the time I'm using the and and the or logical operators.Those are the ones that are the most common to use.So this is the basics of using operators.Now in the next lesson, we're going to start working with our data set, how we can pull it in, how we can put it into a data frame, how we can write files and create files as well.If you haven't already, be sure to check out my full R for data analytics course on Analyst Builder.I'll leave a link in the description and a coupon code if you would like to take that course.Thank you guys so much for watching and I will see you in the next video.
27:09:27 - 27:10:07
Hello everybody.In this lesson, we're going to see how we can read and write files within R.Now, as you can see down here, we have this parks and wreck data set.I will leave, you know, the GitHub below so you can go and you can get this exact file.It's just a little sample file that we are going to pull in.But what we can do is we can literally click on this and we can import this data set.Now in order to do that there are some packages that we need and we do want to install these.So let's go ahead and get those installed and then we'll continue.Now you can see right down here this is the code that they are writing to bring in this data set.And coincidentally enough in just a second we're going to write this exact same thing.
And there are different ways to write it.We don't actually have to use this library right here.There are tons of other libraries or even default things within R that we can use but this is our data set and we can import this data set just like this and it's going to be saved into ourmemory into our data and now we have this data frame.So then if we come over here we can call in this parks and rack data set and I can just hit tab and I can run this and it's going to show all of this data and that isa very simple way to do it.Now, the only downside to doing it like this is if you are creating some type of automation.Let's say you're pulling in data from somewhere from the web and then you are creating a CSV file.
You're pulling that data into here with that CSV file and you're manipulating it.You're changing it.Then you're writing another file after you've cleaned up that data for a specific purpose.Now, in that scenario, doing it like this is not going to work at all because you need to actually write out the code so it's saved to the file.And so we are not going to do it like that.I don't really recommend that unless there's just some one-off file that you just want to get in here and, you know, do whatever with.Let's go ahead and sweep this because uh we don't need it.Um what we can do is we can come in here.We can write very similar code.So I'm just going to show you how to do it uh without anything.So we're going to do read.csv.So read.csv.All we have to do is pass through the file name.
There's a lot of other what are called parameters or arguments that you can pass through as well.So you know if we were uh writing it out again if we write out read CSV you can come in here and you can get additional help on this and look at all the different parameters that they havein here that you can pass through.Now what we need to do is pass through this file.So let's come down here.I have this uh parks and wreck data set.I'm going to click on it and I'm going to copy this as a path.You can do that with a shortcutt control shift C, but I'm just going to paste it in there.And if we try to run this, and actually let's really quick, let's declare this as our data frame.But if we try to run this, then it's not going to work.
This backslash is actually a special character.What it does is it says that this Y, the letter right next to it, is a special character.Now, we can actually negate this by putting another backslash.And then what we're saying is is the special character is this right here.And so, it just keeps it.And we can Whoops.Let me put it in the right spot.So, we can put in a double slash.And that's perfectly acceptable.Let's go ahead and run it.And now we have our data frame right here.And we can click on it.We can open up this data frame and it's beautiful.We're doing uh some parks and wreck and this is what we're going to be using in the next several lessons uh this small parks and wreck data set but that is how we can read in a CSV file.
Now there's lots of different types of file formats.There's JSON, Excel, etc.There's lots of different ones, but this is in a nutshell how you do it.You may just need, you know, a different way to read it in.But there's so many different file formats that you can read in within R.Just about anything you can imagine.Now when we have this data frame, we've created it.It's up here.It looks great.Now we can start messing with this dataf frame.We can use it.We can look at it.For example, we can use this right here, which says the head of the data frame is going to give us the first five rows of that data set.I guess it's giving us the first six here, but this is just a sample of the data.You can imagine because we're going to be working with larger data sets, especially as we get towards the end, that if you have a thousand, 10,000, 100,000 rows, you don't want to look at all of that every single
time.You may just want to print out just a few rows of the data.And that is how you can do this.We also have a few different things that we can do to kind of check our data that we just pulled in.This one right here, and let's see if we have it right here.This gives us the structure of our data frame.So if we come and open the parentheses and pass through our data frame and so what it's going to tell us is going to say here is the character the department the role these are our columns and itsays this is a character column character character these are strings and then annual salary this is an integer and then dogs rescue with three legs that's also an integer.Another one that you might use and I do use these by the way because I often uh you know kind of want to see how the data is sitting.
Another one we can use is summary.And this is going to give us some statistics of our data set.Now, more specifically, this is really good for our numeric columns, but it's not as good or useful for our character columns.But we have some min, first quarter median, mean, third quartile or quarter bolt, quartile max.Um, and the same for the other ones.So, it gives us just a little bit of information about our numeric columns and that can be really helpful.Now, like I said, there are different things when we're pulling in data.I'm going to pull this down.There are different things that we might want to use.For example, if we say header, the header says whether we're going to keep our headers in our file or not.So, if I say equals false, I'm going to do dataf frame 2 here.
So, we're pulling this in and we're saying the header is equal to false.Now, if we run this, it's going to look a little bit different.So now this row as our headers which are our column names now they are actually part of the data and so if you don't have a header on your data it's just goes straight into the data on youknow row one this would be something you need to write in there otherwise it's going to not understand that although it does have header as a default saying true because we didn't put it up here default is trueyou can specify that it is false another thing that you might need to use and let's go back here is SP.This stands for a separator.Now, by default, when you're pulling in a CSV, it's going to be a comma because that's what CSV stands for, a comma, separated value file.
That's what a CSV file is.Now, we don't have to keep it as a comma.Let's say, for example, we have a space that's separating everything or we have a dash that's separating everything.It's whatever you want it to be.Now, by default, again, it is a comma.And if we run this and we go back up to our day frame two, it's going to be the exact same.But if we change it to something like a space, we're going to completely change how this file looks.Now, every space that you see within here is going to be a different column.It's going to separate it out like this.And this looks terrible.So, we definitely don't want to do that, but it is something that you should be aware of.That's a parameter that we can pass through.So, let's run this correctly.And let's actually put this back to the default.
Let's run this.Let's say we have our data frame and we've done some things to it.We are happy with it.Maybe we've aggregated some of the data.And now we say, okay, I want to export this to a file.Instead of readcsv, we're going to write.csv.So write.csv right here is going to put all of this data into a file.So we're going to do this.And what we're going to do is we're going to pass through this exact same thing.I'm going to pass through this file path, but we have to specify what we're passing into that file path.So, we're going to say here, take dataf frame 2.And then here's where you're going to place it.Now, we don't want to call it the exact same thing.It will overwrite our previous file.We don't want that.So, we're going to say uh output.
So, now we're taking this dataf frame 2, which is the exact same data.We haven't done anything to it, but you know, uh, we're taking this dataf frame 2, and now we're going to export that data set or that data frame into a file.Let's go ahead and run this.And there we go.So now we have our parks and rack data set.If we then wanted to read that in, and we can.Let's come right over here.We're going to do underscore output.And let's do this as dataf frame 3.Now let's run this.Now we have our dataf frame three and there is our data set.You'll notice we now have six variables instead of the five.That's because when we exported our data set, it brought along this index right here.What we can do is let's overwrite the that previous one.
Let's put a comma here and we're going to do row.names.This says whether or not we want that index to be written with it or not.and we're going to say false.So, let's overwrite that file.And then let's read this in again.And let's go take a look at our dataf frame 3.It no longer has that extra column with the index.We got rid of that when we wrote it to the file.So, this is the basics of working with files.It of course goes more in depth.You can connect to APIs.You can connect to databases.You can connect to a lot of different file paths.But this is the basics of how you can read and write and create dataf frames with files.So, thank you guys so much for watching.In the next lesson, we're going to see how we can select and order our data that we pulled into a dataf frame.
Hello everybody.In this lesson, we're going to see how we can select and order our data that we're pulling in from a CSV that is in a data frame.Now, what we need to do is we have to first pull in our data set.If you haven't been following this series, then you can get this data set down below.It'll be in the GitHub.You can just download it, put it into file path.And if you don't know how to read in a file, check out my last lesson because that's how you actually work with files, which is right here.You can see how to write files and read in files.Now let's read in this data frame and let's open it up.So now we have columns like character, department, ro, annual salary, dogs rescued with three legs.Very specific column here.But let's start out with just seeing how we can select only specific columns.
Then we'll look at only specific rows.And then what we're going to do at the end is we'll see how we can order different columns.So let's come back here.And what we're going to do is we're actually going to pull in a library here.And let's go over here to the library.And we want to pull in a library.Now, if we come over to the packages, we don't have a ton pulled in.Right?As we're going through here, there's a lot that will, you know, you might want to use that are not in here.And one specifically that we want is dlier.And that's how I pronounce it at least.Uh, but it's dpl.
This package is specifically made and designed for people like data analyst, data scientist to manipulate and select and query and work with data.So we are going to go ahead and we're going to run this.Now it's saying there is no package called dlier.That's not true.There is a package called dlier.We just need to install it.So we're going to come up here.We'll go right above it.We're going to do install.packages.There we go.And then we're going to do dlier.I got to spell that right.I deleted everything that I had in R and started from scratch at the beginning of the series.So I need to install some packages as well.As you can see, we just installed dlier.And because of that, we have a lot of different options that we didn't have before.And specifically, we have this one right here.
This is the grammar of data manipulation.If you click on this, you can come in here and you can see all that it can do.And it can do a lot of things.and we'll use a lot of these in this series.And so now that we have that, we're going to go ahead and we're going to uh pull in that library.We could also just click on this and it would be ready, but I still want to write it in the code.So now we've pulled in that library and we can start using things that are within that library.I'm going to come back here just to make it look nice again.Now one of the functions that's within dlier is select.Let's say we want to only bring in the character and the role column.Those are the only ones we want right now.
We can do that by saying select and we're going to open this up.We're going to pass through our data frame.And now we can select what columns we want.So we're going to say character and roll.And let's go ahead and run this.Now, we're getting our output right now as just an output in the console, which is perfectly fine.What a lot of people will do is when they're running these select statements is they're going to assign this to its own data frame, which is fine.Here's what I will say, and I'm going to start doing it.But here's what I will say.Your data right here and what you're storing in your memory is going to exponentially increase.It's going to be kind of hard to work with all these different dataf frames, but I'm going to say dataf frame characters and we're going to assign this and then we're going to run it.
So now I've created a new dataf frame with only uh two columns.Now we have character and ro.So we're able to just take the columns that we want.We don't have to take all of them.Now let's say we go back here and we actually want all these columns except for this last one.This last one we don't really need at all.And so what we're going to do is we're going to take that and we're going to just come down here and we'll do the same thing.We'll pass through our data frame and we're going to say minus which means we don't want this column.And let's see what that's called again.Dogs rescued with three legs.So I'll say dogs rescued with three legs.We'll see if uh I actually think this is capitalized.But now let's run this.And now you're going to see all of these columns except the one that we didn't want.
Now this seems silly.This seems very, you know, simple, at least the way I'm looking at it because we're just getting rid of one column.But in the real world, when I have been working with data in the past, I'll get data from a client and every single time they send these columns that I just don't care about.I don't need.there's no reason they're in there and they take up space, they fill up your database or they take up your memory, whatever it is, and you just don't want to see it.This would be an example of one that I'm just like, okay, get rid of this column and then we can start looking at it.So then I would assign this to another data frame and then I would only work with that new data frame.I wouldn't work with the original data frame because that one has that dogs rescue with three lengths column that we never needed in the first place.
We could also get this exact same output by doing something a little bit different.And what we would do is we would say character and then we do this little colon here and that means through and then I believe the last one let's get rid of this one is annual salary.So then I would do annual salary.And what this does is it says I want this column through this column.And then if we run this, it's again not going to include that last one because it is not in between character and annual salary.So that's how we're able to specify what columns we want.But I think more importantly is actually selecting what data we want.So what rows of data we actually want to keep in our output.So let's come down here and we're going to say filtering.Now filtering data is super important.
You don't always want all the data or you want some subsection of the data.So what we can do is we're going to come right down here and we're going to say filter.And filter is going to allow us to create a specific condition.If it is met, then those rows will be returned.If it is not met, then it will not be returned.So again, we're going to pass through our data frame.But for this one, let's take a look where annual salary is greater than and let's say 50,000.So we're going to do 501 23.So we're only going to filter on annual salary where it's greater than 50,000.Now if you look in our output, we have an annual salary here and none of them are going to be lower than 50,000.This is using our comparison operators here.So we have other comparison operators that we can use.
For example, we could do right here.We want to say where the role is equal to and now we're looking at a string.We can just say they're a director.And if we run this, there's only going to be one person who's a director, and that's Ron Swanson.Now, you'll notice that we also have a different director.We have Ron Swanson, who's our director, but also Leslie Nope is technically a director, too, but it isn't a specific match here.Now, there is a specific function that is kind of like regular expression.It searches for a specific pattern.It's called grapple.And we can use that.We can say grapple.and we're going to pass through director.Now the only thing we have to do apart from that is we're also going to specify what column we're looking in which is RO and we'll close our parenthesis.
So now we're looking for the word director in this RO column.If it's anywhere in there it's going to return it.So now if we run this it's not just director.Now we have deputy director as well because it was just searching for that keyword.And so if it contains director anywhere in this RO column, we are going to find it.Now when we're filtering data, we typically aren't just filtering on one thing or you know sometimes you are but sometimes we have multiple things.Let's go ahead and let's put this filter down here.I should have kept the uh previous one.I'll write it again.So we're going to do where the annual salary is greater than 50,000 and that's 5,000.And let's just run this.But we also only want to see where their department is parks.So what we're going to do is we're going to use a logical operator which is our amperand.
We're going to say where the annual salary is greater than 50,000 and then we'll create another condition.We're going to say where their department is equal to parks.Now let's run this and you'll see now we have all the annual salaries greater than 50,000 and where the department is equal to parks.So we can have multiple conditions in here and we can either have an and or an or in order to specify what we're looking for.Now right now we're just filtering and before we were just selecting.Let's see how we can combine these.And there's going to be a little bit more advanced and we'll get to a lot of this in the next several lessons.What we're going to do is we're going to use something called a pipe operator.So we're going to take our dataf frame and we're going to build our pipe operator.
This says take the data frame and then so what are we going to do next?We're going to select just this data set.So let's bring this back.So we're taking our data frame and then we're only selecting character through annual salary.So we don't have that last column.And then we're going to add this pipe operator as well.And then we'll say do this.And let's format a little better.This is kind of how you add multiple things on top of another.So we're going to take our data frame.We're going to say and then select only these columns.And then we're going to filter it down like this.So let's run this right here.And actually we're getting an error because uh we don't need to pass through these data frames anymore because we are already specifying at the very beginning take this data frame and then select just this data.
If we do it if we keep passing through the data frame it kind of gets wonky because it's like yes I already know I'm supposed to be using the data frame.So it gets confused.But this right here is how we kind of chain these together.Now we only have these four columns and only with those conditions being met.Now the last thing that we're going to look at and I'm going to actually put this down here.I'm going to say uh this is our called our pipe operator.I'm going to put this down here.And up here I'm going to say ordering.And once we add ordering and see how we can order it, we're going to add it down here into kind of our chain is what we're going to call it.Now for ordering data, let's take this right here.We're going to look at our annual salary.
Let's say we wanted to order it like this, lowest to highest.That's very easy to do when you're looking at the data in here, but there's a hund different reasons why you'd need to actually order it in your code.And so let's come over here and we're going to use arrange.Again, this is in within dlier even says it right here.This is how you order the rows of your data.So we're going to say arrange and what we need to do, of course, is pass through our data frame, but then we're going to specify what column do we want to order it on.We're going to say annual I need to spell right.I'm not spelling right at all.Annual salary.And then if we run this, you'll notice right up here that the annual salary is from lowest to highest.So by default it is ascending which means lowest to highest.
But we can reverse that to do highest to lowest.Let's say uh let's do lower c lowerase actually.Uh let's pass through this annual salary.Give me one sec.So now we're saying take the annual salary but do it from highest to lowest.That's what descending means.It's going to be the exact same thing except the opposite.So we have lowest to highest here.So now let's go back to our pipe operator area where we've chained these all together.Now we have all this information, but I want to order it by annual salary right here.So, I'm going to take uh this and I'm going to say oops my pipe and I'm going to paste this in.But I have to get rid of this data frame again.So now I'm saying take our data frame, select these columns, filter on these conditions, and then arrange them with annual salary descending.
Let's go ahead and run this.And there we go.So we have our output that we're looking for.and we filtered down by a ton of different stuff while selecting columns, rows, and ordering our data all in just one kind of easily readable code.And so that's how we select, filter, and order our data specifically using that dlier package.That is something that's very popular and very common to use within R.If you haven't already, be sure to check out my full R course on analybuilder.com.I will leave a link in the description with a coupon code if you are interested.Thank you guys so much for watching and I will see you in the next lesson.
27:33:34 - 27:34:18
Hello everybody.In this lesson, we're going to see how we can group and aggregate our data in R.Now, we're working with the exact same data set that we were in the previous lessons, but if you don't have it yet, then you can get this data set down below in the GitHub.You just have to download it and you'll be able to work with it along with me.Now, we also need this library dlier.Let's go ahead and run both of these.So, we've loaded our library and we've read in our file.Let's open up our file so we can take a look.Here we have our character.We have the department that they work in, their role, their annual salary, and dogs rescued with three legs.What we're going to be doing is we're going to be grouping on our data and then looking at aggregations.
For example, we have a lot of people who work in the parks department.And let's say we want to know what's the average salary of someone who works at the parks department.Right now, just looking at this data, we don't know.We could kind of guess maybe it's, I don't know, like 50ome thousand, but we don't know for certain.And so that's what group by and aggregations in general within R are used for.Let's go in here and let's see how we can write this.In the last lesson, we learned about the pipe operator, and we're going to be using that again.So, we're going to write it just like this.We're going to take our data frame, and then we're going to write our group by first.So, the group by says we want to take a specific column, put it all into one row, and then perform an aggregation on it.
So, our group by is grouping the values right here in this department.So, let's say group, and we're going to do underscore by, and we're going to do this based off of the department.And then we'll use another pipe right here and we'll go down.Now we need to actually aggregate our data.Now we do this with summarize.Summarize allows us to use some median whatever it is and do it on whatever column we choose.Now it has to be except if we just use a count.Typical aggregations need to be on some type of numeric column.Now I'm going to show you the one where we don't have to do that.That would just be n.That's going to be account.And let's run this.So you're going to see right down here in our output we have city management, health, and parks.So we have two, one, and then seven.
This is just getting a count.So we don't have to specify a column that's numeric because we're just counting the rows.We're not counting a specific column.You'll also notice that we have this n and then in parentheses for our column name.If we were to save this to a dataf frame, then it would have n with the uh parenthesis like that.We can change that by saying count is equal to.So we're going to assign these counts and sign it the name of count.So if you run this now, we have count right here.Now that is the most simple one.It's just a classic count.But let's take a look at let's say an average.So we're going to copy this.And now we're going to get the average of the salary.So we're going to say mean and mean means average uh within R.
And then we're going to do annual salary.Now if we run this, we're going to take a look at the average salaries within each department.So within our parks departments, 54,571.Health only has one person as we know.So that's going to be 60,000.And then city management is 90,000.This is something that is really important when you're doing aggregations because right here, if you only had this information, you don't really know how many people are in each of these departments.Maybe it's only two people, maybe it's three, maybe it's 100, maybe it's 10,000.It is important to know when you're doing aggregations, especially with something like an average, how many numbers or how many data points are behind these numbers.we are actually able to add multiple.So if I put a comma there, then I go right down here and I say count of is equal to the n.
I can run this.And in this aggregation, it doesn't change the department or the annual salary.But now we have an additional aggregation that we've added.And we can do that for as many as we'd like.We can do three, four, five, six, seven different types of aggregations.That would be perfectly acceptable.So, let's take a look at some other aggregations, and we're just going to add them in here.And we can always name them.This one, of course, says mean annual salary, but I could call this uh averagesalary is equal to, and I need to find that equal to.And then when we run this in just a second, it will work.But we have other types of aggregations.We can do the minimum of our annual salary.And if we run this, it'll give us the smallest salary within each department.So we have department average salary right here, the count, and then we have our minimum salary.
Here's the minimum amount that someone makes in each of these.Conversely, we can also do the maximum salary.Let's go ahead and do the max.And we're just going to keep stacking these aggregations all on the department.But this is the most that somebody makes within that department.Now, we also have another interesting one, and this is one that I think gets overlooked a lot, but that's going to be median.Median gets the exact middle point of your aggregation.So, let's put in annual salary here.And I'll explain this in just a sec.I'm actually getting a few too many of these aggregations.Let's put this into a data frame.So, I'm going to say aggregation data frame.We're going to assign this.And let's run this right here.And let's open it up.So, here we have our median annual salary and this says 90,000.
Let's go back and let's take a look.Let's just take a look at city management.This only has two values.If it had three values, it would take the one in the middle, but we only have two.So, what it does is it takes those two middle points.It takes the average of those two middle points, which is going to be 90,000.Now, 60,000, we already know what happens there.But 52,000 is the one that's interesting to us.So let's order by the salary, then the department.So now we have 25,000 all the way up to 90.So we have 1 2 3 4 5 6 7.7 is an odd number, which means it has a middle point, which is going to be four.So if we go 1 2 3 and four, this is the middle point of our data.If we go back to this data frame, 52,000 is our median right here.
Now, as I've gotten more into data analysis and working with numbers, I find myself using median a lot because average has the possibility, it doesn't always, but it has a possibility of skewing some numbers.Let's say, for example, in our data frame, we had Ron Swanson and he's making $10 million or $100 million.If we went and aggregated and just looked at the average, the average would be like $20 million or something like that.I don't know.I'm just throwing out a number, but the average would be insanely high, but only one person actually makes that much in the department.If we took a look at the median, the median is still going to be 52,000 because that's the middle point of the data.And so depending on what type of analysis you're doing, depending on what you're looking for, average and median can show you and give you different insights into the data.
So, it's just one to be aware of and to use wisely.Let's go back and take a look at our data.And so that is how we group and aggregate our data.And again, you can do multiple aggregations.If you want to go even more in depth on grouping and aggregating data within R, I have a full R for data analytics course on analystbuilder.com.I will have a link in the description if you want to check it out, as well as a coupon code just in case you want to take it.With that being said, I hope that this was helpful.I hope that you learned something and I will see you in the next lesson.
Hello everybody.In this lesson, we're going to see how we can handle missing data within our data set.Now, in order to do this, we're going to be working with a new data set.It's called the messy data set.You can get that down in the GitHub.I'll have a link in the description.We're going to need a new library for this called TidyR.This is part of the tidyiverse and they have functions that are specifically created for cleaning up data.And so we're going to be using that in the next several lessons as we look at different things that we need to do in order to clean up data.If you haven't already installed it, you can just install it like this.It's install.packages and then tidyverse in quotes.And then you'll have access to tidyr.It'll look just like this.But I'm going to go ahead and get rid of this because I have it right down here for you.
Now, let's go ahead and bring in our data set.We'll take a look at it.So, I'm just going to run everything really quickly, and we're going to take a look at our data set.So, going through our data really quickly, we have customer ID, customer name, email, transaction amount, transaction date, and category.Now, when I'm looking through this, I can just at a glimpse see very easily that there's several issues.One, we have some null data.So, there isn't any data in here.Now, these look a little bit different than this in the transaction amount, numeric versus string.We'll take a look at that in a little bit.We also have a transaction date, and these are all different types of formats, and that doesn't look good.So, we need to fix that up.We also have a category, and in this category, we have capital electronics, lowercase electronics, and maybe some different spellings as well in here.
So, we need to clean these things up.These are all things that if I was working with this in a real data set, I would be taking a look at these, trying to standardize dates, as well as take a look at this data and see, dowe want to do something with NLES or the blanks?Cuz sometimes we do, sometimes we don't.So, let's come right back over here.We're not going to get to everything in this lesson because, you know, they do have different use cases.We're just going to be looking at missing data.So, to get started, let's come right down here.And what we're going to do is we're going to check our null values within our data set.So what we're going to do is we're going to do call and then sums and we're going to take a look and it's basically just going to summarize uh we're going to do is na and then pass to
our data frame.We're just going to summarize for each column which ones have no values or blank values.Let's go ahead and run this.Now you'll notice on here we have customer ID, customer name, email, transaction amount, but we have no blanks in these columns.But if we look back here, we know that in customer name and in email, we have blanks.Uh we see them, but it's only showing up for transaction amount.Now, that has to do with just how it was pulled in as a data set.Now, we can actually fix this very easily by coming in here and passing through a parameter called NA.This is going to take the blank fields and make them NA.So, we're just going to hit tab and we're going to pass through a vector here and we're just going to say if it's blank then, comma, make it NA.
That's all we're doing.So, for these blank strings, if they're blank, we want to make them NA.Let's read this in again.We'll overwrite our previous data set.Now, let's look at our data frame.And now, you'll see that these are NA as well.This is just something that sometimes you have to do kind of somewhat manually.you have to specify you want that to be done.But now if we run this, you'll see we have one, one, and two.So this is a lot more accurate.Now, within this data, sometimes what you're going to want to do is just get rid of it.So for example, let's say we're creating an email list and we say we have to have this email available, otherwise this data is just not useful to us at all.So what we want to do is we want to actually get rid of this data.
So, what we're going to do is let's come right down here and let's create we'll do dataf frame cleaned.We're just going to create a new dataf frame.But all we're going to do is we're going to drop that row if it is blank.So, we're going to say uh we can take the data frame and we'll use a pipe here.Then we're going to say drop na.And that's right here.And you can see it uses this tidy r.And it's just going to drop the rows where any column specified contains a missing value.So, we're going to come here and we're going to specify the email column.And if you remember, we have this email right here.So, let's go ahead.Let's run this.Let's take a look.You'll notice we have one less row.Let's take a look at the data frame cleaned.
And we'll compare.So, now we only have 11 rows of data compared to the 12 before.And now we don't have this customer ID 109, which is uh Helen Carter.We have 109 completely gone.And so we just got rid of that data.That is a perfectly acceptable thing to do depending on the use case for your data.Our use case was we're creating an email list.It's pretty hard to give an email list to somebody to email out if that person doesn't have an email.So we just got rid of it.And that is a perfectly acceptable thing to do.And I'm actually going to put up here.I'm going to say uh remove rows when no email is present.Now another thing that we could do is we could actually fill in this data.So for example we have transaction amount and let's say we need to use this transaction amount.
For example in transaction amount let's assume that when it has na it's actually a zero.It means there was zero transaction amount paid here.Maybe they got a full discount but this would be contextual.It would be we know that when it says NA it's supposed to be a zero.So we just want to populate this with a zero.Now this makes a big difference when you start doing aggregations on it.Now we looked at aggregations and grouping.When you have a zero in here, that zero is going to be counted in that aggregation.And so if you just did 0 and 99, then the average is going to be about a 50.If we have NA here, this does not count towards the aggregation.So it would just be 99.99.So let's go ahead and do that first option.Let's go through here and let's populate these with zeros.
Let's say that's our use case for what we're doing.So, we need to take this column, this transaction amount.So, we're going to come right down here.We're going to say data frame.Then, we're going to do a dollar sign, and this is just a shortcut of specifying the column name.We're going to do transaction amount.And we just want to say when the transaction amount is null, then populate it with zero.So, we're going to create a bracket here.We're going to do is na and we're going to pass through this exact column.So we can just copy this.So we're saying when this column is blank then what are we going to do?We're going to populate it with a zero.And that's it.So let's go ahead and actually real quick let's do this on dataf frame cleaned.Glad I caught that.
Otherwise we'd be doing that to our original dataf frame.So let's go ahead and run this and let's go back to our dataf frame cleaned.And you'll see 0.00 0 0 and 0.00.And that is fantastic.When we go to aggregate this, these zeros are going to be counted because now they're numbers.They're not null.Now, sometimes that's not what we want to do.Maybe we know that NA means it just didn't take the data incorrectly, but we want to count it as an actual sale.We know that it wasn't zero.It's a nonzero number.Maybe it was 50, maybe it was 100.We don't know.But we don't want to populate it with a zero because that's going to bring down our averages and we know that can't be correct.So what if we just wanted to populate it with the average value?We can definitely do that as well.
Let's come back here and let's redo this really quick.Let's overwrite and we're going to go like this.It should bring us back to how it was before.So this is just the first option to populate null numeric values.Now we'll have our second option.So we're going to take this column again, this data frame cleaned.And in fact, we need this whole thing.So let's just copy this down.And we're going to populate it by going like this.And now we're going to say take the mean of the transaction amount.So we're going to say mean and then we're going to pass through just the transaction amount.So let's get rid of this and let's make sure we have our wrap on so we can see it all.So now we're taking the average of this column.Let's go ahead and run this and take a look.
Now, it isn't populating it.And I have a feeling we need to pass through another parameter here, which is na.rm.It's basically going to say when you're taking this, make sure and check that it's the correct one.Otherwise, it may not evaluate it to NA when that is what we're looking for.So, we want to say that's equal to true.And we're going to run it just like this.And now we have these values populated.Now, if we go back at Charlie Brown, he had NA and so did Ian Brooks.So, let's come right here.We have 180.2656.180.2656.Now, when we run this, these people, Ian Brooks and Charlie Brown are going to be included in the aggregation, but they won't change the number if we're just looking at averages.Now, if we start doing other things and other types of aggregations, of course, it's going to change the output, but we're looking at specifically for averages.
these people will be included and we can also run counts on them to know this is how many sales or counts we made.So that is very much an option, but you need to be really really confident that what you're filling in is accurate and useful for your analysis down the line.You don't want to put this in here and maybe just leave it in there because someone coming behind you is not going to understand that that's what that is.So you always want to keep an original data frame.You always want to kind of document what you're doing and why you're doing it because otherwise your analysis might not make sense down the line.Now, some other data that is missing is right here.This is a customer name.Now, we don't have this full customer name and maybe we don't have another data set or another part of our database where we can pull that in.
And maybe we just want to pull in Emma.Maybe that's all we know and that's all we want to do.But, you know, people's emails aren't always accurate.So maybe we just want to fill this in with unknown.We know that the customer has a name.Everybody has a name.We just don't know it.And that isn't necessarily the most important part of the data.They can still reach out to this person via email and say, "Hey, customer or whatever it is."So we're going to put unknown here.And this would be something that we would have.And this is a small data set.But let's imagine we have a 100,000 rows of data.Maybe there's, you know, 200, 500, a thousand people with no customer name.we now can just specify that and so we keep it in the data set but it isn't just blank.
And so let's see how we can do that.We're going to come here to dataf frame and let's actually pull it in just like this.Whoops.I'm just messing up here.Let's pull in this dataf frame cleaned.And now we're going to do customer name.Isn't that what it's called?Yeah, customer_enamed.And let's pull it in right here.Now we're going to do the same thing.We're going to say if it's blank.So, we're going to do is na and then we're going to push in here or or pass through in here our customer name just like we wrote it.If it's blank, then instead of a number, we're going to do unknown.And so that's it.We're checking if it's blank and we're passing through unknown if it's not.This again safeguards against other things you might do later on when working with this data set.
Sometimes when you're working with nulls and you're putting it into a CSV or you put it into a data set, those get dropped.I know for I know for instance that if you put certain data that has blanks into something like my SQL, those rows just get dropped in some instances.And so you want to be careful about leaving things blank.Even though it's, you know, inconspicuous, it's just a customer name.We don't need it.Sometimes you just want to populate it just to make sure that if it's been put in other systems, it doesn't get dropped or deleted in some way.And so these are some of the ways that you can handle missing data within AR and within your data frame.We're going to call this one populating text or character columns.And so I hope that this was helpful.If you haven't checked it out already, I have a full course on R for data analytics.
We go even more in depth into handling missing data as well as a bunch of other data cleaning techniques.I will leave a link in the description as well as a coupon code if you would like to check that out.But with that being said, thank you guys so much for watching.If you like this video, be sure to like and subscribe below and I will see you in the next video.
Hello everybody.In this lesson, we're going to be taking a look at parsing and converting dates in an R dataf frame.We're going to be using this lubricate package right here.You can use library and lubricate to load in that package that we can use it.We're going to be using the exact same data set from our last lesson.If you haven't already gotten that from the GitHub, I'll have the GitHub below so you can go ahead and download it.And then we're going to import it exactly as we have it right here.This is what our data frame looks like.And we're going to be specifically looking at this transaction date.In here, you can see we have a ton of different formats.And that's not a good thing.uh that is a bad thing because if we want to use this, let's just say we wanted to use dates in order to create a line chart, so a time series plot or something like that.
Well, if the data sits like this, it's not going to work.Or if you want to aggregate it on or if you want to parse it out or if you want to do anything, you can't really do that with how it sits right here.Now, this is a very exaggerated view of this.It normally doesn't look like this, but let's say, for example, you're pulling data from a database in two separate parts and you're putting into one output and you're outputting it to a CSV.I've seen it a 100 times where you have two different types of transaction dates.Ones like this and ones like this.And they both are technically dates and they're being stored, but they're being stored differently.And so, this is something that we want to clean up and we want to standardize so they're all looking the same in the same format.
And Lubdate is very helpful with this.And what we're going to do is come right back here.We're going to run our code so that we pull in that data frame.And now we can start working with it.So we're going to specify.We're going to do data frame.The dollar sign is just a shortcut to specify our column.We're going to choose our transaction date.Now what we want to do is we want to first standardize all of them and then later we're going to parse them out into day, month, year, whatever we want because that can be very helpful as well.So the first thing that we're going to do is we're going to use parse date and let's see if it comes up right here.Parse date time.This is from the lubber date package as you can see right here and it basically is just a really helpful function to help standardize your dates.
So let's go ahead and click on this and we need to pass through as one of the uh as one of our arguments you need to pass through what column we're actually working on.But now we need to pass through orders.So for parse date time this orders allows us to specify different formats that our dates are going to be in and then it standardizes them for us.So we're going to say orders here.We're going to say that's equal to.Now, let's make sure we have the soft wrap lines on uh just in case it gets long.Or we could just pull it down here.But what we need to do is we're going to pass through a vector and we just need to specify what different formats are we actually working with here because we have year, that's month and day.This one, and those are dashes, and then we have month, day, year with these forward slashes.
And so we need to just kind of go through here and see what different formats we have and it'll standardize them.So let's do this first one.It's year, month, and day with dashes in between them.So we're going to do capital Y for the year, month, and day.And of course, this needs to be within quotes.Let's make sure we get that.Let me go back.There we go.But let's put a quote right here.And there we go.And now we can just do that and separate them by commas.Let's run this one actually and let's come in here and you'll see that now we have one and those are all standardized and all working correctly.We're getting a message down here saying seven failed to parse.This is just a message saying hey we did some of them correctly but there's a bunch that didn't work correctly and this is a very helpful hint for us.
This is kind of a message that's saying hey you didn't get them all so be sure to go back.Now that isn't all of them.So, let's reread our data frame since we overwrote that.Uh, but let's look at our data frame and let's do some of these other formats as well.So, for that one, we're going to do a comma and then we're going to say month slash dayward slashyear and then we'll look at another one.So, let's come in here.We have another one with slashes or forward slashes, but this one is a different direction.We have year, month, and day.So, let's make sure we get this one as well.So we'll do year that's a forward slashmon and day.Now one thing and this is just I just know this is this right here isn't actually text.It is still a date although it has text in it.
It's still being stored as a date properly but it has a different way it's displaying it.So on the back end it could actually look like this but it's displaying like this.So what we're going to do is let's run this one and see what happens.And we got one that failed to parse.So let's come back here.So this Grace Adams is the only one that failed to parse.Let's come up here.Let's run this again.And let's create a duplicate of this.We're just going to do dataf frame raw.And we're just going to pass through the data frame just so we have it.Um so we can compare.So we have our dataf frame raw.And if we go back the one that didn't work and let's run this one more time.Sorry about that.The one that didn't work wasright here.
So that's gonna be Grace Adams.Let's go through to Grace Adams.And that's because this is a different format than up here.Again, this is year, month, day.This is day, month, and year with dashes.So, let's come in here.We're going to say day- month dashy year.And we just need to rerun our data frame so that we can rerun this one one more time.Let's go ahead and run this.And now we're not getting any error message.So now if we go and we look at our data frame, this looks just beautiful.I mean, that is a thing of beauty.Let's compare it to how it was before.And I'm just going to go back and forth.You can see that this one is much more preferred, right?We now have everything in one format that we want.Now, after we get this, we can also parse these dates out.
So let's get rid of this data frame raw.We don't need that anymore.Now we can take this transaction date and we can pull out the year, the month, and the day.And we can actually create new columns with this.So what we can do is we'll take data frame.But now we're not going to do transaction date.We're going to do transaction date let's do year.And then we're going to pass through.So for this new column, we're going to take this transaction date.But we only want the month.So let's just make this month.And I actually said year here.So let's actually do year.This year is going to extract just the year from here, which is 2024 for all of them, I believe.And it's going to make its own column.And we can do this exact same thing with the month.
Whoops.And the day.So we can say month here.And then we have a function that's month that's going to extract just the month.And then of course we'll have one as well for day and we'll do day as well.So I'm going to run both of these.And if we come up here and go all the way to the right now we have this all broken out by the year, the month, and the day.Zuber Date makes it really easy to standardize and work with these dates because there's a lot of different reasons why you would want to actually parse these out.It just depends on what you're using it for in the future.And so, I hope that this was helpful.If you haven't already, I have a full course where we'll dive a lot more into the data cleaning process.So, if you want to check that out, I'll have a link down in the description as well as a coupon code if you would like to use that.
With that being said, I hope you enjoyed this video.Thank you guys so much for watching.If you have not already, be sure to like and subscribe, and I will see you in the next lesson.
Hello everybody.In this lesson, we're going to see how we can remove duplicates from a data set.Now, if you have not been following along, you can get this messy data set down in the GitHub below.I'll have a link.You can just download the CSV and you are good to go.All we're going to need for this lesson is our dlier.Let's go ahead and run this whole thing.So, we get the library and the data frame.And let's open up our data frame.Now, at first glance, even if you've been using this data set in previous lessons when we were looking at parsing and converting dates as well as handling missing data, you may not have noticed that we have duplicates inhere.We do.We have duplicates right down here.We have Alice Johnson and Alice Johnson.It just wasn't something that maybe I pointed out so maybe you just didn't notice.
But we have another duplicate which is we have a customer ID here that's 104 and we have another customer ID that's 104.And typically within a data set like this, this is going to be our unique ID.This is our primary key.So we shouldn't have duplicates for a customer ID.And so there are a few things that we're going to be doing within this in order to make sure that we remove the correct duplicates from our data set.So let's come over here and the first thing that we are going to do is we want to check to see are there duplicate rows.So we're going to take our data frame and we'll just do it like this because it's a little easier to read.And we're going to do a distinct on it.So distinct, it's going to keep only unique or distinct rows from a data frame.
And that's it.It's pretty simple.And I actually need to I don't think I wrote that right.Uh we're going to run it just like this.Keep it simple.And as we go up, you'll notice we still have the 104 and the 104 because it's looking for a distinct across all columns.So the only one that is the same across all columns is Alice Johnson.You'll see 101, Alice Johnson, Alice J.Same transaction amount, same transaction day, same category, same everything.But 104 David Lee is not the same as 104 Emma who made a different purchase.We got those confused.So the only true duplicate across all columns is going to be Alice Johnson.Now we can very easily remove the second Alice Johnson because we can come right here.We're just going to say dataf frame no spell duplicates right.If you guys have ever watched me, you know how terrible I am at uh at spelling.
We're going to take our data frame.We're going to look at the distinct and that's going to get passed through into this new data frame.So let's run this.You'll see we have one less.And so now we have this saved.There's no more Alice Johnson.And so we are doing really good.But what about this 104 right here?Well, we can do it kind of the easy way, which is just saying, okay, we only want to keep one of these people.And so we can actually use this exact same syntax.And let's get it over here just so it looks nice.We'll do duplicates two here.And I'm going to say take the distinct but only of this one specific column customer ID.So we're going to pass through I need to spell this right.Customer ID.And when we run this, let's go ahead and run it.
We're going to go like that.And now we don't have any duplicates in our customer ID.You're going to quickly notice though we don't have the rest of our data and that's not ideal.Let's come right here and we're going to use another argument which is keep all and we'll do keep all.And you can go back and check.It's just going to keep all the other columns.And so we just want to say true.By default it was false.So we'll run this again in duplicates 2.We now have all the columns and we got rid of that second one.Now, was that correct?I don't know.And there may be a better methodology to actually keep to actually determine which customer ID we want to keep because this one doesn't have a customer name.And if we go back to right here, this person made a purchase on 10 or the transaction date at least on 104 of 2024.
And this person up here only made one on March, which is 35, which is before it.So, you might want to incorporate some logic here to say we actually want to take the person with the most recent transaction date.And we can do that.And that's actually not super hard to do.So, let's come here.Let's put this right down here.We'll do we'll make this uh node duplicates three.We're going to take our data frame and let's tab over here.We still want to look at the customer ID and take the distinct customer ID.We just want to arrange it because it's taking it going top down.It's saying, "Okay, keep that one.If there's ever a duplicate down here, get rid of it."Which is what it did right here.It said, "Okay, keep this one.Oh, we have a duplicate.Get rid of it."
So, what we want to do is we want to order this.And so, we're going to do an enter here.And let me just bring it over here so it looks nice.We'll do arrange.And we want to arrange this by that transaction date.We want to do it by the customer ID first and then the transaction date.But we want to do this descending from highest to lowest.That's the most recent.So we want to say take the most recent person.Then we'll add our pipe here.And now when we run this, we get an error because this is all caps.All right, let's try this again.I got excited and let's go look at this uh no duplicates three and unfortunately we're getting the same thing and that's because of a transaction date issue.Uh we're going to go back and if you haven't done this already or you haven't taken that lesson on parsing and converting dates you we need to do that.
That is really important actually.So we're going to um clean this data up a little bit.I'm going to place it right here.So you'll have that in the code in the GitHub.But I'm going to take this.I'm going to run this.And if we go and look at our original data frame.Now we have standardized these dates.So now when we run this and we take a look at the duplicates three, now it's taking David Lee.It was not working properly because our dates were not properly cleaned.And so before they looked horrible.And I think we should be able to see this right here.These dates are all over the place and so it didn't know how to order them properly until we cleaned them.Now, I'm not going to go into the data cleaning process for the dates because that was our last lesson in this series.
So, you can go and check that out if you want to.Again, I'll have this code in the GitHub so you can just copy and paste this if you'd like.But, it is worth noting that you can go learn how to do it in that last lesson.But then once we clean that up and we standardize them all properly, we order them from highest to lowest, which is going to look like this.So these are the most recent all the way down to the old ones.And then we kept the distinct customer ID.And so now our output looks a lot better.We now only have one Alice Johnson.And now we kept David Lee because he had the more recent transaction date.Now for this use case, that logic works.But you need to figure out the logic for your actual data set because maybe that doesn't make sense.
Maybe you want the original person and this new person needs to get a new customer ID.And you can do that by maybe taking the max customer ID and adding one to it.I don't know.Depends on what you're doing.But that is how we can remove the duplicates and we can make sure at least follows some type of logic that we can actually document and hand off and people can understand.So I hope that you learned something.And if you want to dive into data cleaning and using R even more, I have a full course on my platform analyst builder.I will have a link in the description.But I hope that this was helpful.If it was, be sure to like and subscribe below and I will see you in the next video.
28:11:33 - 28:12:17
Hello everybody.In this lesson, we're going to be taking a look at data visualization and then creating a presentation.This is kind of like a little mini project and kind of shows you how to put all your visualizations into one output, which can be really helpful.Now, what we're going to do is work with a new data set here.We're going to be using this parks and wreckb budget.csv.This is a new data set for this series.So go ahead and get that down below in the GitHub and we're going to get going.The only thing that you need to do besides things that we've done in previous lessons is we're going to using a different library.It's called ggplot 2.This is a data visualization library specifically designed to make it easier to visualize your data.Let's go ahead and run this and let's take a look at this data frame.
So in this data frame we have year, we have the department, then we have budget in thousands.And if you go down, you can see we have a lot of different departments.Sanitation, public works, city management, education, transportation.There's a lot of different departments.Now, what we're going to be working on is we're going to be taking a look at bar charts, and we're also going to take a look at line charts, some categorization with a bar chart, as well as sometime series visualizations with a line chart.Once we get those, we are going to be putting this into an R markdown file, and we're going to kind of make it look pretty.We're going to make it look nice, and then this will be something you can hand off to somebody.So, let's get started and let's take a look at how we can get our very first bar chart.
So, we have our data frame here and I'm just going to start by saying we do need to do a little bit of work to get it properly formatted for something like a bar chart.Bar charts are great when working aggregated data and we can easily aggregate this data because we have something like a department to then aggregate on something with the budget in thousands.We could also aggregate on the year and look at the total budget for the year, but I'm more interested to see how much money have we budgeted for in total for every single department.So, we can just use a sum here.If you want to change it up and you want to look at maybe the median or you want to look at the max or whatever it is, you can do that.But, we're going to do the sum of this parks and recck department to see how much money they budgeted for over all these years.
So let's take our data frame.We're going to use our pipe operator and we're going to use some of the things that we've used throughout this entire series.If you haven't gone through the series, this is what we've covered so far.And then grouping and aggregating is one of them.So we're going to group on the department and then we'll add another pipe here.We're going to summarize this.And we want to do this on the budget.So we're going to do the sum of the budget in thousands.Now, we can name this as well.It isn't super important, but we'll call this total budget and we'll say that's equal to the sum of budget in thousands.Now, the next thing that we're going to do is where we actually start creating our visualization.And so, this is where it starts to get different than what we've just looked at with grouping and aggregating.
Now, we're going to actually build out the visualization.Now, for the very basics, especially with using ggplot 2, is we need to just be able to kind of get something over here under our plots.So, we kind of want to create our very first layer.And that's how plots typically work is you're layering one thing on top of another.And then you're also adding in different adding in different colors or different variations of things that you want to change.Typically, when you're doing a plot, you're going to start off with ggplot.This ggplot is going to give us that first layer of what data are we actually working with.And the ones that we're working with are the department and our total budget.So we're going to come down here.We're going to say aes.Now AES is something that you use to specify the variables that are going to be mapped into the data.
And you can look through it right here and read into that.But we're going to specify AES for our aesthetics.And we're going to pass through our X and our Y.So we're going to say X is equal to department.And I need to spell this right.And then we'll do a comma.And we'll say the Y is equal to, and let me make it look a little bit better.Total_budget.And we can keep it like that for now.But just knowing what's to come, we will come back and we'll edit this a little bit.But when we start getting to visualizations, we're no longer going to use these pipe operators.We're now just going to say plus.And that says, okay, we're adding to the next layer of our visualization.We can actually look at just this.Let's go ahead and run this.And we have down here our X and our Y, but we don't have the layer on top of it.
What are we actually putting in this visualization?You'll also notice this looks horrible at the bottom.It's text over text, and it just does not look good.We'll fix that later on, trust me.But let's keep going.We want to add a bar chart here.So what we want to do is we're going to do geo m_bar and you can see it right down here.So within ggplot so within ggplot they have all these geometry visualizations is that's what that g stands for the g_bar and so we want to specify this is a bar chart and we can leave it just like this.Let's go ahead and run this.Now we're going to get an error here because we need to set up a specific parameter called stat or stat count.Now just knowing these if we come in here we have just the classic stat and then you can also do different options like stat count.
I'm just going to use stat and we're going to say it's equal to identity.We're going to do it like this identity.And so this is just something that we have to pass through in order for it to actually kind of understand what we're working with here.So now we're actually getting a visualization.This looks really good, but we're going to have to clean this up quite a bit.make several changes to it.One thing we can just add really quickly is we're going to add a title.So we're going to do gg title and we just have to pass through a string.So we'll call this total budget by department.Just keep it super duper simple here.And so now we have a nice little title here.But the first thing that I want to fix is we want some colors in here.So, we're going to come back to our aesthetics and we're going to do a comma and we're going to say fill is equal to and we're going to do department.
So, now it's going to give us a legend and each one of these colors will be a different department.Let's run this.And so, you don't have to do this.In fact, we could just make it a specific color.We could just say we could just say red.And we could do it like that.We'll make them all red.or it's kind of like a salmon almost, but a different color.We can just make it a specific color and that'd be perfectly fine.But let's just go back.I like this kind of like rainbow color here.It's nice.But at the very bottom, we're still having an issue with how this looks.Now, typically, if I'm working with kind of a simpler visualization, I would do a theme.And again, we're just adding a layer here.I would do this like minimal theme.And it would kind of get rid of some of these colors in the back.
do a little bit of spacing and it looks nice.It's a minimal theme, but for this theme, we actually need to specify this right here, which is an element.So, we need to come back here.I'm going to get rid of this.I'm just going to have a base theme and we need to do axis.ext and we need this for the xaxis.So, along this x-axis, we need to work with this text.So, we're going to say is equal to.And now we need to pass through element text.And all we're going to do is adjust the angle.And we're just going to come in here.We're going to say the angle, not angel.The angle is equal to 45.So now it's going to be at a 45 degree angle.Let's go ahead and run this and just see how it looks.And this looks aund times better, but I think we need to adjust a little bit uh as well.
So, we'll do the height adjustment and we'll say it's equal to one.Let's try this.And there we go.So, this looks a hundred times better.The only thing that I would change is I would want to order this from highest down to lowest.So, I could visually just see in order from highest to lowest which department is which.Now, we can do that.It's going to be right up here in our summarize.Now, we can do that.It's going to be right here in this X because we have our department right here.We can actually use something called a reorder and we pass through the department first but then we do a comma here and we say minus the total budget.That minus just means go from high to low.That's all that minus means.If we did it the other way, it'd be from low to high.
Let's go ahead and run this.So now we see that public works takes about a hundred.I think that's a million dollars.Then we have recreation, park, sanitation.So that is visually you can see it going down.Again, we don't have to use this, but I just like the colors and I wanted to uh so let's keep going because I think we got a good gist of how we can create this visualization and we willadd this to our output in a little bit.I might want to just show you what this R markdown looks like.We're going to call this uh presentation_final.
Let's open this up real quick.It creates this output for an HTML document, which is perfectly fine.Um, I'm going to use a different one called flex dashboard.You don't have to use that, but that's the one I'm going to use in this lesson, but we'll be passing through this right here.And so, hold on to this.Don't change that because we will need it.Now, let's go down to our line chart.Now, line charts are a little bit different because in this we're just looking at as an in total.We're not looking at it over time, but now we're about to use this column right here.And now we have a specific year that we're going to look at over time for all of our data.I think we should do two separate visualizations.One where it's all the departments together and then one broken out by departments because those are two very different visualizations.
And so what we're going to do is we can actually copy um I don't know quite a bit of this.Let's just copy this whole thing down because now we're just grouping on the year, but we still want that sum of total budget.And then down here in the X, we're not looking at the department anymore.Now we're looking at the year.So then our Y is our total budget, which because we're grouping on the year, we might want to call this our annual because this is our total budget.So now we should change this to annual budget.And we can still use the same fill at least for this visualization.It shouldn't matter at all.Um, but we will use it in the next one.We break it out by the department.The only thing that's really going to change is we have to go to GM and I'm going to say line here.
So, this is going to create a line visualization.And let's just run it just like this.And apparently this actually does matter.Let's get rid of this really quick.And let's try running this one more time.And in essence, this is our visualization.It's very simple.Uh let's actually add in that minimal theme.So I'm going to do uh theme minimal.This is just the one that I think makes it look nicer.We can also add in little dots on the year so we can kind of see what this is supposed to look like.So I'm going to do gam point and this is just going to add dots on where the data goes.And you can see, so this is 2005 6 7 8 9 10.And it's just easier to see.And I think just for a quick line chart for the budget or the annual budget over the years, this is pretty good.
But we could also add in a title here.So I'm going to say uh GG title and I'm going to say annual budget for all departments.And we'll do it just like this.And that looks great.Now, what if we want to break this out by the different departments?This is where it gets a little trickier.Not much.Let's copy this down.And we want to break this.I'm going to say break out by departments.That's just for the people who are looking at the code.Um, so now we're not really needing to group by this because it kind of already has this for us.Whoops.It kind of already has this for us.I just messed up all the data, but it has the year, the department, and the budget.So, we really shouldn't need to group this data.Let's pull this back.But in our ggplot, we do need the year.
We do need the budget in thousands.So, we're going to do budget in thousands.And then we're going to need our color or our fill.So, I'll do color is equal to I'm going say department.So, let's go ahead and just try this.And there we go.Now, this is kind of all over the place.Maybe we want to get rid of these points real quick.Just see what this looks like.Maybe this looks a little bit better.But we have this department as our legend.And so now you can see you can just kind of follow one of these colors, whatever one you want to follow.And you'll be able to see that budget changing over the years.This is not the annual budget for all departments.Uh this is the angel budget per department.There we go.And we'll run it just like this.
So this looks good.And we have you can even go back and look at you know previous ones you've done.And so you know we're holding a lot in memory just storing these.But these look really good to me.I think we are good to go.So what we need to do now is we want to group all of this.Now, what we want to do is we're going to change this a little bit and we're going to put all of our visualizations and essentially all of our data in here.Now, I'm going to change this to a flex dashboard.And I just find these easier to work with.Uh, so we're do flex dashboard here.Now, I'm going to save this.And when I save this on knit, which means we're going to actually process the data and we're going to create it.We're now knitting to a dashboard instead of before we were doing to an HTML document.
Now, if you don't have this installed, which I completely deleted my R Studio and R in order to do this, I need to install this again.So, let's go ahead and do that.But while it's working on that, let's start moving over all of our stuff.So, I'm going to come up here and I'm going to get this right here.And what we need to do is put it in a little code block.and we're going to use little tick marks to specify where we're going to have our code.Now, I need to use what I like to call squiggly brackets.And I need to specify that this is our code because you don't have to use this uh just with R.You can use this with other programming languages.So, we want to specify this is our code.So, all we're doing is just getting in our data set.
If we had other things where we were cleaning it up or transforming it or whatever it was, it'd be in this code block.Now, we want to put in our first one.This is our bar chart and we're going to come down here and we're going to do three with the R, of course.Oops.Let me fix that.We're going to post our code and then do three as well.And so now you'll notice it kind of has it highlighted.This is where our R code is.Now, if we try to just run this, let's save this and let's knit it.So I just clicked dit.It's going to start processing this as well as our visualization and it's going to give us an output.Now it just gives us our presentation final and our one visualization.But we haven't really added a lot to this.
Let's add our other stuff as well.So now we're going to come down here and we can just copy this.Let's not get crazy.And we're going to do one, two, three.And then I'm going to do another one down here.One, two, three.So, let's go back and get our two other visualizations.We have this one, and I'll paste it right in here.And then we have this one.And I'll paste that one in the bottom one.And let's go ahead and save this as well as knit to flex dashboard, which is what we just did before.
And taking a look at this, it looks like something went wrong because none of this is working properly.If we scroll up and down, this just doesn't look right.Let's go ahead and exit out of this.Let's go back up and let's give these titles really quick.We're going to do one, two, three.And I'm just going to give it the same title as we have up here.We don't need these uh quotes right here.We go down here.Let's give it three annual budget for all departments.And then lastly down here as well.And this is annual budget per department.Let's go ahead and run this
and let's see what our output looks like this time.It looks quite a bit different.We have this right here.This uh side data that does not look correct.Uh we need to go back and we need to get rid of this.Let's go back to our visualization.Let's just run this and we'll run it just like that.You'll see in our output we're getting all these things and this is being put into our visualization or our output as well.We don't want this.Now, if I'm looking at this really quickly, I think we just didn't add in a space here.And so, it's like printing out these themes uh as we go.So, let me add in this space right here.And we'll add it in here as well.Now, let's try saving this.And let's knit it.
And this looks good.Although it's really small in order to make it larger.Let's try something right here.Let's do a colon.We're going to say vertical layout.We'll do a colon and say screen.Just like this.Let's save this.And this should allow us to have them stacked on top of each other.And let's see.Knit to flex.So, let's just make sure it's working.I think this may need to be lowercase, which is why it's not working.Let's try this again.There we go.But this vertical scroll stacks them on top of each other and allows you to scroll down.And there we go.And this looks 100 times better than how we had it before because now it has a scroll wheel, allows these things to expand.Now, we can also publish this.We can say publish document.In order to do that, you have to have these connected.
And RS Connect is is something that Posit created in order to publish these.We're just going to say yes.Uh I had this before, but you know, I deleted everything.So now I'm starting over with you guys.But let's go ahead and publish this.It looks like it's still working on that.Let's give it just a sec.It took about 1 minute.Says it is installed.Let's bring this back.Now we can p publish it to our pubs, which is a free service.You can also do Posit Connect and Posit Cloud which are paid services or at least in some way or shape or form.You'll have to pay for it.We're just going to use our pubs and we're going to go ahead and click publish.Now, all you have to do is create an account, share it, and you'll get a sharable link that you can then put on your resume, put on LinkedIn, put anywhere you want in order to actually share your project.
So, I hope that this was helpful.If you haven't already, I have a full R course that goes a lot more in depth into the data visualization and presentation side of things.So, if you want to go ahead and check that out, I will leave a link in the description below.I'll also have a coupon code if you want that as well.But I really appreciate you watching and I hope that this whole series was really helpful.If you did find if you did like it, be sure to like and subscribe and I will see you in the next lesson.
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 careerdriven 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 to 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 uh let's do Chicago cuz why not?Uh so it's going to search for data analyst positions in Chicago.Uh 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 inhouse 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 one who's actually going to be looking at these résumés.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 so that they can look at it.or maybe later on down the line, this actually is a person who is reviewing résumés and so if they come across your resume, they may be able to put a face to the name and that may give youbonus 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 wantto say.Number two is to actually ask for a referral.
Now, if you don't know what a referral is, it is where somebody who already works at the company can refer you to a specific job and it 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 cuz 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 that 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 forfor that position.When I was applying to jobs and only applying to job postings and not using any of these strategies, my success rate was 0.04, 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 like 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 and you can download this.You'll just rightclick 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.
Uh this is the certificate of completion for the data analytics boot camp.I have my not signature but my name as well as u 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 of work to go through all those videos and learn allof 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 video.
Seek backward 5s ←
Longer seek (10s) Shift ←
Play Space Seek forward 5s →
Longer seek (10s) Shift →
0:00 Auto-scroll A Copy link at current time S

2026 FREE Data Analyst Bootcamp [24 Hours+] for FREE | SQL, Excel, Python, Power BI, GitHub, AWS