OK.
Welcome back.
Now in the last video we went through different data types in panders series and data frames creating
some series in a data frame importing data and then exporting data.
Now we're going to look at different ways you can describe data in pandas so we'll make a little heading
here.
Remember to do that you can type some markdown if you've never seen markdown before.
You can do some research but to create a heading you can do two little hash.
And this world will press escape an endless shift enter.
Now I've got described data in a nice little heading format.
This is a great way to break up Jupiter notebooks.
So it's communicative
to the way you call functions.
We've already seen this on an example here to CSP on pandas data frames is by pressing the dot notation.
So if we go to tab it might show us.
There we go.
Took a little while and I got impatient and pressed time to long.
It'll show us a few functions here that we can run.
But remember there isn't a lot here.
So in the beginning don't focus on trying to learn all of these off by heart.
Just focus on using the few that were going through at the moment and then build upon your knowledge
as you go.
So the first thing we're going to have a look at is how to describe the data types in our data frame.
We can do this by typing in D types.
So you'll notice some functions have brackets after.
And some don't like this one doesn't have brackets over it.
The difference between these two is this is an attribute.
So we type in here attribute whereas a function like car sales to see as V is a function.
So the difference between an attribute and a function is this is going to perform some steps whereas
D types which is an attribute is just some meta information which is stored about the car sales data
frame.
So that's the two main things to remember here that the difference between an attribute and a function.
We don't want to run this line of code so we'll comment that out but we do want to see the D types.
Let's do that hitting shift enter.
Now this will tell us some information about our car sales data from columns.
So it's going to make column let's view it up here.
Make color odometer doors price.
That's our column names.
So this is going to tell us the type of our make column is an object.
Color is an object odometer is an int.
Doors is an integer.
And price is also an object.
Let's have a look at some other things we can do with that data frame.
Car sales note columns.
Now is this a function or an attribute.
It doesn't have brackets so it's an attribute.
So this is going to tell us our column names is going to return it as a list so you could go car columns
equals car sales columns.
Hit shift enter and now you've got your column names stored as a list so you can perform some operations
on this list and then use that later on to manipulate your data frame.
This is just how you access two of the main types of attributes from your data frame.
Let's have a look at something else.
What about the indexes go car columns index
has no attribute index all because we talked in car columns we want our car sales data frame.
There we go.
Beautiful.
So this is going to say Let's view the data frame here.
Car sales is going to say the range of the index starts at zero and stops at 10.
Step is 1 0 1 2 3.
Okay.
That makes sense.
Now we've gone through a few different attributes of our data frame.
Let's have a look at some of the functions we can call.
Remember the main difference between a function and an attribute is one doesn't have brackets attributes
don't have brackets and functions are going to perform some kind of operation.
So the first one will have a look at is describe.
There we go what the scribe does is gives us some statistical information about our numeric columns.
You might notice why isn't price coming up here is a numeric column so we've got odometer.
That means there's 10 columns count.
The main is seventy eight thousand six hundred one.
So the odometer is how many kilometers a car might have done and the number of doors that count is 10
meaning there's 10 rows with doors as a column and the main is for standard deviation is that zero point
4 7 1 4 0 5.
We've got percentiles here.
Min and max but no price.
Well if we come back up here we can see that the odometer is an integer value.
And the doors are also an integer value but the price is an object.
Now that's interesting.
Mm hmm.
Maybe when we imported it from our CSA this cell is formatted differently to these cells.
Don't worry we'll have a look at that in a future video but something to keep in mind is it describe
works on only numeric columns.
So let's have a look at something else.
Maybe we want info car sales or info and now it's important to remember that these type of description
functions and attributes are some things that you might run through at the very start of exploring a
new set of data.
So that's what we're doing we're pretending we've got car sales here and we want to start running functions
like info and describe to just start exploring our data and getting some information about it.
So what's this gonna give us.
Let's have a look Range Index 10 entry 0 to 9.
Now info is kind of like index combined with data types.
And so remember panders has many different ways to do similar things.
So as you go through and work through learn more about the library you kind of find a pattern that works
for you best.
I'm just showing your broad collection of different useful functions you can use throughout any type
of data analysis.
What this is going to tell us is that the make column has 10 non now objects 10 normal objects for color.
Same again for the rest of the columns.
There's two D types for int 64.
Yeah that makes sense in 64 in 64 and three for object.
Okay.
And that's not using very much memory all right.
Let's keep going.
Car sales you can call statistical analysis on your data frame.
So car sales don't mean we'll give you the average of your numerical columns remember price doesn't
show up here because it's an object not a numerical column you can even call mean on individual series
that's make a a series called car prices equals P A DOT series three thousand let's pretend that this
is our car prices that they're not in object format they're an integer format and then we go car prices
don't mean princes conferences I wish I was a car Prince.
There we go.
So that's gonna give us the average of these three numbers here.
That's pretty high there.
Thirty eight thousand five hundred eighty three.
Because we have this big value that's a car Prince car right there.
Next one we can have a look at is some so we can go.
Car sales not some.
This is going to sum up all of the different columns value.
So this is just really combined what's in the make column was in the color column.
It's total up how many at a domino there is how many doors there are.
It's not really useful calling it on the whole data frame so maybe we do it on a single column now to
select a single column we'll go through this in the selection video to select a single column just to
demonstrate it here doors dot some you type in the name of the column in square brackets as a string
and then call dot some hit shift enter.
Now that's just going to bring this some down here.
Now you can do a fair few different versions of this statistical like not just some bingo go mean median
and a bunch of others.
So I'd suggest if you're practicing try out a few different statistical functions even look up the panda's
documentation for different statistical measures you can call on different columns.
And then finally if you want one last bit of information about your data frame is length.
So the reason you might want this is say your data frames hundred thousand rows and you only wanted
to work on a few thousand for an exploratory data analysis.
You could figure out the length of the data frame you're currently working on by passing it to Len and
we can see that there's 10 rows in our data from we have a look at it one more time.
Beautiful.
That's nice and correct.
OK.
So that's the end of this describing section what you could probably do is go through practice running
the code yourself and then see if there's any other functions here that you want to try out maybe create
your own series like this and then see what statistical values you can find out about your series but
without further ado I'll see you in the next lecture and we'll look at how to differently view data
and select data.