Helen, before going deep dive into the session, let's have a quick recap of what we have done in the
previous session.
So basically we have imported our data.
We have done lots of data processing on our data as well as we have deal with the missing values.
We have simply dropped all the missing value because we have less missing values and after it we have
to define its function to change my data type.
Whatever the type of variable will be, it would just convert into some data format after doing all
these things we have accepted as Journey Day journeyman for our column.
And we have basically dropped this column because it makes no sense at all.
And in the session, we have to deal with this arrival time as well as this departure time feature as
well, because whenever you are going to parse this feature to a machine learning model, your model
isn't able to understand what exactly that particular day, what exactly the particular arrival time,
because you have to tell with machine learning model.
Yeah.
And I would offer this much my arrival, this much my departure hours did much, my departure this much.
And after what we have to do for this, for performing all these things, what do we have to do?
We have to fetch May not an hour from my data and we have to send to that machine learning model.
That's what I want to do.
So to extract work from just data to extract out from this column, I would define a function X.
Its name is Lex, its name is extract, underscore our and on what data stream I have to apply that.
It was at the very first parameter.
The second parameter is on what column I have to apply.
So now what I have to do.
So basically I'm going to say the fourth column dot dot dot hour.
So it will exactly return me some hour.
So now I have to store it somewhere else.
Let's say I have to store it in whatever column I want to pass in my function name.
You have to just concatenate underscore our order.
Similarly, you have to write a function.
Similarly, you have to write a function to extract your minute as well.
So I'm just going to write a function over there.
So for this I have to assign proper indentation, otherwise it will give me some error.
So this time I have to say this time I function.
Name is say accoustic underscoring.
And here I have to say I have to extract this minute and here I'm going to say column name is Will be
Nothing.
My column on this column.
And just as an all this team likes it, after doing all this thing, you have to drop that column because
that column makes no sense at all.
So I will define mine, let's say some new function.
Let's say in my function, name is nothing but drop on a score column to make it more user friendly.
And after it, I have to pass two parameters, my dear friend column.
Then I have to say what I have to draw.
So I'm going to say, do you have to draw?
And this time I have to pass my column.
Then X is parameter as well as I have to pass my in-place parameter as well, because I have to admit
as well.
And after doing all this, what I have to do, I have to just executed.
And let's say very first what I'm going to do.
I have to apply all of these three functions on my this departure time.
So let's say the very first I would apply all these functions on my departure.
Let's go down so that if I have to say what function I have to play, so let's say I have to extract
all those thoughts, I have to call this on a sort of assumption.
And here I'm going to say my datastream name is nothing but my training data.
And this time my column name is nothing or be on this call time.
Make sure we don't have any case sensitive issues, otherwise it will give you error.
Similarly, if you have to accept mynor, you guys can call this function as well.
And here very first you have to Passo data from the second one feature you have to parse.
What exactly is your column name.
So I'm going to pass all this stuff and after doing all these things you have to drop that particular
column.
So I'm going to say my function name is nothing but drop on this column and my data framing the thing,
what it's called data mining feature, multimode departure on this school time.
And after it, we have to just execute it.
And if this time I'm with the caller had already, we will see what we don't have any departure time
column.
And you have a two column names additionally over here as departure time and our deposit that on the
school minutes.
So that's a power function.
Whenever you have to do a task multiple times, just like that block of code and you function whenever
you have a need of that function, just call it that simple.
Similarly, you have to perform all these stuffs for your arrival time feature as well, which is nothing.
But which is this one.
So I'm just going to copy this and just I'm going to paste over here this time here, I'm going to say
my future is nothing but arrival time.
So just to do just played here.
Just played here.
And if you are again going to execute it, so if you are going to call ahead on your data now, we will
again see or there are two new Collum as a driver and it's go down.
It's called hour and arrival and it's called time.
And it's minute has been added in your data as well as you don't have any column name as a travel escort
time.
So that's about power, the automation.
That's the power of creating a function in Python as well as in any programming language.
Now, what we have to do is we have to process, we have to pre-process our this duration column.
So we will observe over here in this duration column.
This duration is nothing but in form of hours and minutes.
So whenever you are going to parse this feature to your machine learning model as yeah, this is my
duration, but machine learning model isn't able to understand because you have deltour machine learning
model.
Yeah, I have that much power in duration and that minute in duration.
So but I think that you will notice over here maybe at some places you don't have a minute, you don't
have a half hour as well.
It means you have to pre-process this column as well.
So what I am going to do over here, so that is first, let's say I have to outrate on each and every
duration to where I'm going to say wherever I don't have any Myners.
So simply I'm going to append as you get older and wherever, I don't have any hour in such case I can
spend zero hour with.
So for this, what I'm going to do, I'm just going to exit.
As for I, in range of whatever will be the length of my duration column so that if I'm going to say
this duration is nothing but I'm going to create a list of my duration.
So just create a list of the so very first to have to add to the data.
And here you have to access your duration.
And after that you have to I try to zero to whatever will be the length of your duration list, whatever
the length of my duration list.
And once you have all these things that I'm going to say.
So let me think.
Let me show you a thing.
Let's say I'm going to copy this and let's say I'm going to convert it into some string.
And if I'm going to call a spade over there, let's say I have to split it on the basis of the space
operator.
So remove the extra spaces.
So if I'm going to execute it now, we will see it will exactly the list where I have two hours and
this minute.
So my logic will be simple as that.
Wherever the count, whatever it's count, whatever the count of the list will be two will be two.
I don't have to do any manipulation in my data, but wherever it's length will be one.
I have to do some modifications, some manipulations in my data.
So here I'm going say is length of is length of my duration of I got a split because you have to split
it and you have to split it on the basis of the space tiebreaker.
And wherever this land is equally close to two, do so.
In such case, what you have to do, you have to simply skip it.
So to skip you guys can use this pass given order and here you have s block.
And in this block, what you have to do, you have to wait for the condition.
So wherever you have edge, it means that you have over.
So wherever you have this hour in duration of I, it means in each and every duration, if you have
this hour, if you have this edge.
So in such case you have to append minute, you have to open the zero minute in your data.
So here I'm going to say duration of by plus zero and you have to update this duration as well.
So I'm going to say just based on the what if you don't have any edge, it means maybe you have a minute
in your data.
So in such case, what you have to do in such case, basically you have to spend zero hour in your data.
So in such case, you have to upend zero hour in your data for here.
I'm basically going to append this zero edge in my data.
So what I have to do now just executed all of this just gets executed and.
I would have call had on Monday, the same night you see all the modifications, but you will think,
no, it's not happened because you don't have assigned this duration list in your data frame because
it is not updated.
You are too slow to update your data.
You have to insert this judicial list at this place.
So for this, what I am going to do is I have to excuse my data frame, then I have to access the duration
and here I have to assign this duration so you don't have to copy.
So I have to just as you ordered and if again, I am going to execute it, you will see a manipulation
has been happen in your data.
You will see a zero minute has been added in your data.
That's what I'm trying to show you.
So that's all about the session.
Hopefully we'll love the session very much.
Thank you, guys.
Have a nice day.
Keep learning.
Keep growing.
Keep practicing.