Welcome back.
So in the past few videos we've looked at how to create plots like this.
We've made some line figures some scatter plots.
Some bar graphs and some histogram.
These are more than enough to get started plotting some of the most common things you want to plot in
your machine learning and data science career.
But more often than not you're not going to be plotting directly from num pi arrays you're going to
be plotting from Panda's data frames.
And I guess you kind of are still plotting from num pi arrays because panders is built on no high res
but that's what we're going to focus on in these next couple of videos is plotting from Panda's data
frames.
So let's do that and there's data frames beautiful it's going to make that into a little heading using
escape and pressing em and now first thing's first going to import pandas because we need panders to
over data frames.
We've done this at the top of the notebook.
But we're going to do it anyway because we like that.
And now we want to make a data frame.
Now we've got up in here we've got our trusty car sales CSP which we've seen before which is just like
a spreadsheet that's been exported into a comma separated value format or dot CSP.
So we've seen this in the pandas section all car sales equals PD not read CSB.
I believe it's called car sales car sales.
You can always tab auto complete here.
There we go.
That's helped us out.
Thank you.
Put a comma.
There we go here.
Car sales we'll check it out.
Lovely.
That's our trusty car sales data frame.
Now before we plot anything from here let's practice looking up some documentation Panda's data frame
visualization wonderful that already knows what I want to look up it's almost like I've prepared this
earlier so we want to look at visualization and pandas.
This is the pandas documentation.
We use the standard convention for referencing the map plot API.
Wonderful.
So that means that pandas builds upon map Gottlieb.
So what we want to do is rather than reading through all of this documentation because there is a lot
of different plots hey there's a histogram.
We've done some of these.
Will go back up here.
We're going to start off by just writing some code and we're gonna try and replicate this in some sort.
So let's just copy this and I know a break in the number one rule.
Don't copy code rewrite it but we're gonna rewrite it anyway.
But I'm just putting it here.
Create a new cell below escape B so we can copy it out.
We don't have to keep going back and forth.
You might see something in a stack overflow question or documentation and you might just copy it straight
from here put it into your notebook and then go hey I need this part but I don't need this part and
just write out the parts that you actually need.
Right.
But you never want to be just completely copying and PD type range.
This is a bit all 2000.
So we're going to upgrade it to where we are now so 1 1 2020.
Wonderful.
A bit more closer to where we are now actually periods equals a thousand.
Now you might be going okay.
What does this mean payday.
Or date range.
Well remember our motto if in doubt run the code.
So let's see this to yes.
All right.
So what's happening here.
Well we've got dates on the index yep that makes sense index equals paid out date range.
It starts at this date first of the first 20 20 then goes up.
So it's going up by days.
OK.
And these are just random numbers being filled here in this column going up what is come some.
Well let's type that in T.S. dot come some.
What can we do.
Shift tab return came out of some over a data frame or series access cumulative sum.
What does that mean.
Well let's find out we run that.
Yes actually let's keep running we don't want a negative.
There
what is happening here.
This should be adding up.
Maybe we go here.
Yes this is interesting.
This should be adding TSA goes that.
I know what came out of some thousand it doesn't seem to be doing it here what it supposed to be doing
is adding this one to this one and then adding that one this one and then adding this one to this one
oh that's why TSA Eagles t is classic and you just trying to get ahead of himself and run the code.
My own motto is let me damn.
Let's see what happens.
Okay.
We've got something kind of similar to this but again remember it's always gonna be different because
we're using random not random Well this is just demonstrating that when we call plot from a PD dot series
we haven't done it from a data frame yet it comes out as map plot lib dot axes dot subplots.
So that's what we've seen before with this.
So really it's straight from a panda series they might delete this cell because we don't need that anymore.
But it's using map pot lib that's really handy to know.
All right.
Now we've seen plotting straight from a series let's plot from our data frame.
We've got car sales it's our data frame we'll view it again.
How about we make something similar to this but using our car sales data.
Yeah maybe we get some dates and the sale price over time we might add a little column to our data frame.
Yeah that sounds like a good project.
But before this video gets too long we're going to do that in the next one.
So next video I'll see you back then I try replicate something like this but using our data.
So we'll get a mixture of manipulating data and plotting at the same time.
That'll be good fun.