‫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 histograms.
‫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 numpy arrays.
‫You're going to be plotting from pandas data frames.
‫And I guess you kind of are still plotting from numpy raise because pandas is built on numpy arrays.
‫But that's what we're going to focus on in these next couple of videos is plotting from pandas data
‫frames.
‫So let's do that.
‫Pandas data frames.
‫Beautiful.
‫It's going to make that into a little heading using escape and pressing M and now first things first,
‫we're going to import pandas because we need pandas to work with 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 make a data frame.
‫Now we've got up in here, we've got our trusty Carsales CSV, which we've seen before, which is just
‫like a spreadsheet that's being exported into a comma separated value format or CSV.
‫So we've seen this in the PANDAS section.
‫So we're going to Carsales equals PD read CSV, 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 and we go here.
‫Car sales.
‫We'll check it out.
‫Lovely.
‫That's our trusty car sales dataframe.
‫Now, before we plot anything from here, let's practice looking at some documentation.
‫Pandas, data, frame, visualization.
‫Wonderful.
‫It 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 lib api.
‫Wonderful.
‫So that means that pandas builds upon map plot lib.
‫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, so we'll go back up
‫here.
‫We're going to start off by just writing some code and we're going to try and replicate this in some
‫sort.
‫So let's just copy this.
‫And I know we're breaking the number one rule.
‫Don't copy code, rewrite it, but we're going to 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 stackoverflow 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 it.
‫Paid a tight range.
‫This is a bit old.
‫2000.
‫So we're going to upgrade it to where we are now.
‫So one one 2021 to feel a bit more closer to where we are now actually.
‫Periods equals 1000.
‫Now you might be going, okay, what does this mean?
‫Paid date range.
‫Remember our motto If in doubt, run the code.
‫So let's see this t.
‫All right.
‫So what's happening here?
‫Well, we've got dates on the index.
‫Yep, that makes sense.
‫Index equals PDA point date range.
‫It starts at this date, first of the first, 2020, then goes up.
‫So it's going up by days.
‫Okay.
‫And these are just random numbers being filled here in this column going up what is come sum.
‫Well let's type that in espn.com some what can we do shift tab return cumulative sum 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.
‫Well.
‫What is happening here.
‫This should be adding up.
‫Maybe we go here.
‫Yes.
‫This is interesting.
‫This should be adding to us equals that.
‫Hmm.
‫I know what came out of some days, and it doesn't seem to be doing it here.
‫What it's 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 TS equals TS classic.
‫You know, just trying to get ahead of himself and run the code.
‫My own motto is letting me down.
‫Let's see what happens.
‫Okay.
‫We got something kind of similar to this.
‫But again, remember, it's always going to be different because we're using random.
‫Random.
‫Well, this is just demonstrating that when we call plot from a series, we haven't done it from a data
‫frame yet.
‫It comes out as map plot, lib axis subplot.
‫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 that plot 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 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 the next video, I'll see you back.
‫We're going to try replicate something like this, but using our data so we'll get a mixture of our
‫manipulating data and plotting at the same time.
‫That'll be good fun.