Now we've got our dates column past and it's in a good format that we can work with her panties date
time format.
Let's keep modifying our data frame so that we can work within and eventually build a model.
You can see here where we're reviewing the first five rows and we've got 53 columns along here.
But what you'll notice in the middle when there's too many columns to display in Juba a notebook it
truncated.
So we've got dot dot dot dot.
But if you wanted to see every column a trick you can do is DFA dot head and then dot t for transpose.
So now we'll see the first five rows across the top.
These are columns now.
And if we scroll down these are all of our columns so you can see all 53 darlings it is a fair few missing
values up towards the back end here.
Now this might be different depending on what rows we're looking at but that's just a a little way if
your data frame is getting truncated you can try to transpose it and you might be out of view them all
in one hit.
This could take us a fair while if we're going to go through each and every single column trying to
figure out what's going on.
So maybe to begin with is just to Kansas s Date column to remind ourselves of what it looks like now.
Let's check out the first 20 or so wonderful so we got different dates we can see we have good examples
from different years different models different days what would be better would be if it's all in order
that would make sense right.
If our data frame was from the top from row zero all the way down to the bottom it was in order.
So this is the first date and then as the examples went on as rows went on the dates went up.
So let's do that what we might do is go sort data frame by sale date.
This is good practice for a time series problem.
Right.
It's good idea.
Usually with the time series problem you're trying to use examples from the past or past events to make
some inference or predictions on future events.
So it's always a good idea to sort your values by the date that they occur.
So what we'll do is when working with time series data it's a good idea to sort it all sorted by date.
We're just getting light by day so we can do that with a little Panda's function so what we might do
is go sort data frame in date order DLF sort values go by.
This is where we pass it.
A column name.
And then we want to do it in place for him in place is just going to make our change if we didn't have
in place equals true.
We'd have to go DFA eagles that would just do it in place because we do want our dates to be in order.
We'll do a sending.
So we want it to go from smallest date to highest date equals true.
And now because we've passed our dates and passed I mean past is in PRSA day.
We can run these sort of functions saw values because Panda's going to understand sale date as a daytime
object.
So it's got some special properties about that.
So we go here.
Sale date dot head.
So what this is going to do is going to sort our data frame by sale date starting with the earliest
date first.
Hopefully if this works and then we'll view the same 20 rows always call the same line of code to view
the first 20 examples and see what's changed.
Wonderful.
So these numbers on the left here are the index.
So the index of the rows that we've just sorted ZDF don't head so the original index of that row is
two thousand two hundred five thousand six hundred fifteen but the sale date was 1989 or the 17th of
the first 1989.
So now you see how instead of having our dates scrambled we've got them in order.
That's exactly what we wanted and not what we might do.
It's also good practice to make make copy of the original data frame and why is this so we make a copy
of the original data frame.
We'll see it in a second.
So when we manipulate the copy we've still got our original data.
So we do something wrong on our copy we're we're exploring our data or when we're manipulating it we
can still always revert back to the original data frame.
So what we might do is make a copy and you can call this whatever you want I usually call it something
like IDF temp as in data frame temporary.
You call IDF experiment or something like that just something simple that you can remember.
We're going to use IDF dot copy so that it's basically it's going to say hey take the data frame we've
been working with including the changes that it's in order.
Sale date and just make a copy of it and save it to the variable DFT.
So let's do that.
Wonderful.
So if we check just to make sure the F temp dot sale date I know we want just the head area exact same
wonderful man we can also.
It's just the exact same copy of the data frame but now if we make changes and that's what we're going
to do we make changes to DFT temp.
Those changes won't be reflected in DLF if we ever need to we can revert back to DLF as our original
and we can manipulate IDF temp as much as we want because we know we've still got the original.
So beautiful.
Now we've got DFA temp what we might do is although we've we've ordered our data frame by date we might
use these dates to enrich the data in our data frame.
And if you're wondering what that means don't worry we'll cover it in the next video.
But for now just have a play around with sorting a data frame.
You could even sort it by another value just don't save it in place just see what it does.
You can change the ASPI into any column name that's a number and you can change this to false if you
wanted to and see if that works out.
But otherwise if you're following along let's make some changes to DFT temp.