It's time to finally start coding.
And in this exercise, we're going to be exploring some data that we're going to grab from Kaggle.
It's time to do some coding, so open up your Jupyter notebooks.
Now, in my case, I already have some files here, but usually it'll just be whatever files you have
on your desktop.
It doesn't really matter because we're going to create a new file here and make sure that the notebook
is going to be in Python three.
So once you create that notebook, title it Whatever You Want.
In our case, we're going to be exploring some FIFA soccer data sets.
So let's just call it soccer.
Now, in order for us to learn about data science and machine learning, we remember our steps, right?
We have to import the data.
So we get the data from what we export last time, which is Kaggle.
If you haven't registered already, make sure you do that.
Otherwise just sign in and once you're assigned end, just go to data sets.
Let's make this a little bit bigger.
And within the data sets again, we can pick whatever we want.
But I feel like checking out the FIFA 2019 data set now.
I usually like looking at the scores here to make sure that it's a good data set.
In this case, it looks like the FIFA 19 complete player data set is looking pretty nice.
We have two megabytes of data.
It was uploaded eight months ago and it's a one file CSV file so you can actually click on quick look
here and I'll show you some other information that you may need.
In our case, it's a CSV file, so that's great, but just a heads up.
It is a bit of a big data set.
So if we click on it.
We can just simply click on download and wait a little bit as your data sets get downloaded.
Now I want you to unzip this file and put it on your desktop where your Jupyter Notebook is.
So you want it in the same folder as the soccer notebook that you just created.
Let me do that.
So now if I go to my home, I see that I have data CSV, which is the file that we imported from Kaggle.
As you can see right now, it looks like a massive amount of data.
We can't really read it because it's in CSV format.
Now, if we go back to our soccer notebook, we're going to use the PANDAS library to do our data analysis
to see what we actually get from Kaggle.
Now, in our case, we used Kaggle to grab our data, but you can imagine that there's different ways
to gather the data.
You can, for example, like we saw, use something like beautiful soup to scrape web pages so that
you can understand it better, so you can use any type of data possible.
Ideally, if it's in a CSV format, then we can use pandas and really do some neat things with it.
So let's take a look.
Now, luckily for us by opening Jupyter with Anaconda, remember the Anaconda Navigator?
We actually have access to libraries like pandas automatically.
So all we have to do is simply say import pandas and we can do as PD just so we have a shorthand instead
of typing up pandas every time.
So if I do this, I now have access to pandas.
And with pandas I can do read, underscore, see CSV to actually read our CSV file.
And because our CSV file is in the same folder as our soccer notebook, I can just simply give it the
string data dot csv, which is what we have over here downloaded.
So if I run this.
I get my data right here and look at that.
I have.
My pretty data with nationality.
We have links to photos, we have the name of the players, the IDs, the age and a ton of other things.
Now the neat thing with pandas is that we get this output as what we call a data frame, and PANDAS
allows us to manipulate this data frame so that we can do interesting things with it.
So usually what you'll see is you'll just create a variable dataframe equals PD dot read csv.
So that now this data frame is what we get down here.
All this information is now in our data frame variable and we can do interesting things and run different
methods and properties on it.
So for example, if I do data underscore frame, dot shape.
Or give me more information about my data.
In this case you'll see that a tuple object is not callable.
I get nice errors in my Jupyter notebook and that's because shape is actually not a method but instead
a property on DataFrame.
So if I run this again, look at that.
This is the shape of my data.
I have 89 columns and well, a ton of rows.
Now I can also do different things.
And this is the neat part about Jupiter is that I can just leave the input and output here, and if
I do a different cell block, I'll still have this information.
It will still have imported pandas speed.
So if I do now data.
Frame.
Dot.
Let's do.
Describe.
I'll be able to run this.
And again, it shows or describes the data that I have.
With describe we get the count.
So for example, the overall age accumulated, we get the mean age, that is the average age of the
player.
So 25 and we also get interesting things like maybe the oldest player is 45, the highest jersey number
is 99.
And all this different type of data.
Finally, if I do something like data frame dot values and I run this.
I get all the values of my data and you see here that it's an array that has different players in it.
So remember how I said.
Libraries like numpy work with arrays and lists in Python and help us manipulate them?
Well, as you can see, our data frame is stored as an array.
Of each.
Individual player that we could potentially manipulate.
And what we've done here is we've simply imported the data.
So we learned the first step of our ML steps, that is to import the data.
We found the data and we used PANDAS to grab our data into a data frame.
Now there are many different things that you can do with pandas.
And I want you to after this video, I'm going to link to this resource so you can try different methods
and properties on your data frames to see what type of things we can do.
So I want you to go through this exercise and just try different things, for example, in filtering
here.
We can try and learn about filtering our dataframe.
So again, if I just copy and paste this, change this to our variable that we have.
So DataFrame.
And then we want to filter.
Let's say let's look at the shape of our data or see what type of data we have.
You know what?
Let's let's filter by H.
So I'm going to say dataframe.
We're going to go by age.
And I'm going to say age is going to be older than let's do let's do 40.
If I run this.
Oh, and age should be capitalized here, so I've got a key here.
If I run this again.
There we go.
I got a least I grabbed the head, which means just the first couple of people of players with age over
40.
And I was able to do that just by looking at some of the PANDAS documentation and learning about filtering.
So I want you to explore this.
It's not too long and try out different data manipulation techniques so that you get familiar with pandas.
Again, you don't need to memorize this often.
You usually will just look at the documentation and grab the data that you need.
In the next video, we're going to try and solve an interesting problem with this data set.
I'll see you in the next one.
Bye bye.