In this session, we will discuss the mode stacking and stacking and melting of data, so the first
thing which we will do is we will impose the required library's.
So we are importing Seabourne as Asness, Fondas as BDI and no as an.
So now we will go ahead with looking at different through volume transformations, so stacking and stacking
and arming the rebels have their own documentation act does not find that out.
Or so you can refer to those in case you want to check the full documentation and learn more about them.
But we will cover only what is actually required and the important parts of that.
So this is the dip state, does it, so we are loading the students from the library.
So the data set contains the total bill, the six more days, time and size of the of the particular
date.
And this is the detail of the bills.
The amount the what is the amount?
This is the bill amount.
This is the gender of the person.
This is if the person is smoking or not, then that the average someone has visited the restaurant,
then the time when they have visited and the size of the group of people who have visited.
So for this dataset, we will check details further.
So we would, first of all, group the data.
So here what we are doing is we have this entire data.
So now we are grouping the data by the and then by six.
And we are creating an aggregation with size of the group of people.
So, like, we run this.
So here you can see what happens here is that while we have the data, so it has brought all the data
with the B, so we have all the details of each and every day, which we have.
And for each day, it has further created a further subgroup of male and female.
And on the male and female, it has created a size which has been aggregated.
So this aggregation.
So this aggregation is actually the sum of the size of the data, so it is adding the value for it.
So it is actually finding out all the Sundays then for all the Sundays, a finding of all the Fenians,
and it is just adding the Google, the number of people who are dead in the group.
So this is how the abused group, but.
Now we are getting to find out all these values, but it is a little difficult to how to analyze this
kind of data.
So we want the data to be in a column form where we can actually analyze it more to you.
OK, because what happened now is that when we have created this grouping, this specific indexing available,
so I cannot actually find out the particular value based on some particular index.
I want the data which looks something like this so that I can retrieve certain values from it and apply
for those based on the bottom does, which we have.
So what we can do is.
We can use Unstopping, so we have needed this tips, gva just dimps biodata, so what we are doing
for that is we are applying the unstaffed method on top of and we are creating a on unstuck from this.
So let me run this.
So here I have the unstaffed version of this group.
So what happened here is it has unstaffed the media and we have the indexing.
So now the index, instead of being up to level the index, it is now just a single level index.
So it has only one level of indexing, which is Thursday, Friday, Saturday, Sunday, which I can
refer to easily.
Now it is more understandable and we can use it more easily.
So this is an unstoppable version of it.
Now when we are giving the barometer so indiv is what it is doing is it is giving Thursday, Friday,
Saturday, Sunday here.
And it has unstaffed mean Fehmi.
So how it was actually the first nibble here.
We had those during this time in the sun.
Then we have male and female as the next level.
So on unshocking it has removed the male and female and only the first level, which was actually that
now we will unstaffed on the basis of an argument which is zero.
So when we strike on the basis of this, what happens is it is unstopping the level.
Zero.
So what it does is it does stacking the zero to.
So it is unshocking zero levels or the keeping the level one.
As of this summer, male and female remains as it is, and it has on Thursday, Friday, Saturday,
Sunday.
So we have the Thursday, Friday, Saturday, Sunday on the column by vigneron stacking on the basis
of one.
What it does is it unstaffed the level number one.
So the level number one, which is.
Female lend me get unstaffed, I'm it is represented on the lip, so which levies you want to unstaffed,
you need to provide that as an input barometer for this function.
Onestop function.
Now, further, what we can do is if we want to have or new object, like when we are of looking at
the columns of the upstart unstaffed, what we get is we get this multi-level kind of indexing.
So this is the type start on stack.
So in type, start on stack.
We have this multilevel column name.
So it is kind of difficult to understand how this actually works.
So when we talk about the balloons, the balloons have size and undersize, it has male and female.
So this is kind of difficult to interpret how we will filter out the values, how we will apply any
operations on the volume, that becomes difficult in this particular case.
So what we can do is.
We can use tips us this was the deed of name name, and we have this size Godmamma, which is the double
meaning of the.
On the colony, so we done this, we can get the volume as it is, so I'm just getting the double reading
this particular thing, which is the first colony and this is my second colony.
So I can use this or what I can use I can simply use of copy this entire day Dufrene and then would
dive into different and different levels and use that.
But this kind of a tricky thing and it would take some time to understand also.
So a better thing of a better thing.
What we can do is.
Instead of using this kind of a structure, it is convenient, if it is convenient, you can use this
kind of a structure.
If not convenient, then what we can do is we can simply use.
So how we can do the stacking, so this is the start us them for me.
This is what we have generated, so they absorb us, has the problems.
Size me, size women, so these are problems.
So when we do the US stuff, what it does is it again stacks back all the stuff on me.
So I again get the level kind of a structure.
Now, if you want to start with the level of zettl, it will start from the the zeroth level.
And if you want to step on the basis of one, then it will stand the possible.
So if we want to make the data by now, then either we can use the stack and sucking for changing the
levels of data or we can use melting.
So let us see how melting works.
So we have this data, which is of having forced last height weight.
So all the data is just in the form which we usually like to work with.
Now what we can do is we can use dort make.
And began giving the lady and we are giving the lenient on bubbleheads.
We want to make it so we are giving the first and last name.
So what did we do with it?
Will simply.
Change the look of fear, so it will change the height and weight into column name itself and it will
give the value in front of you.
So this is how it will make it.
It will just by making you alone as it will increase the number of rules when we make something, it
will increase the number of rules and when we are.
Converting this so we can also look at this as cheese box index, so if you will just run this particular
piece of fruit.
So here we are just converting this first and last as the index theme's.
So this is what we can do.
We can have the next visas index names and.
When we do this and the next, it will simply convert this and we will stop them together and we can
convert it into the original.
So it is a better use of the stuff because it kind of looks flawlessly might even be used on stacking.
If my positive job is so, I would feel like you can try to follow what you like and follow what you
are more comfortable with, but may think I'm stacking works more flawlessly and it's a lot more versatile
in nature.
Now, the other thing which we want to learn here is to convert into dummy variables.
Now, we have discussed A of about political benefits.
So let's say we have some variable as gender and it has two values, male and female, and we want to
convert that into a zero one.
So what we can do is we can create a dummy.
So how we can do is here we have started.
So it has this Volume six, which has values, female and me, so what I want to do here is I want to
get the Emmys for this.
So what I can do is I can simply these dummies.
So if we can work the column six to six and the school, me, I'm six and the school Fehmi, I'm wherever
the value of sex was me, it would be on the values to one under me and column.
And wherever the value of Fehmi value was female and the female column, it will there one.
So this is how we can dummy column instead of having this factual data.
Now same thing can be done when we have a multiple number of captivities.
Let's see if we have a job.
Nine, then we can have as many number of categories as we want so we can simply use get dummies for
that.
And there are other methods also by which we can convert something into a dummy and then put Sadan for
those on top of that so that we don't have extra number of of categories.
I make sure no problems so we even know when we will talk about feature selection, how we reduce the
number of volumes.
But for now, you just need to know that we have this dummy function, which helps us in converting
the categorical columns into dummy variables.
And for the ordinary columns, we will have another process which will allow us to convert those of
ordinary values into numeric values.
In the next session, we will learn about somebody else.
We will see how we can generate that.