Welcome back.
Let's look at yet another way of removing columns, and this time it's the pop method.
This is pretty easy to use.
We only need to specify a column label that we want to remove from the data frame.
And we call it on the data frame directly.
So in this case, we're popping or removing the H column.
But if we go back to the data frame, let's let's try with something else here.
So let's pop club.
OK, that's great.
Three things to note about this method.
First, what we get back is a note, the data frame with the column we moved, as we did when we use
the drop method.
But instead, when using pop, we get back the remove column itself in the form of a series.
Right.
So that's that's one thing to note.
The second point is that Pop works on a single column at a time, which is to say that we could not
use the pop method to remove more than one column at once.
Right, so these syntax, for example, which probably comes naturally to us by now of passing python
list of labels, these would not work with pop.
Right.
In order to remove club and H.
We'll have to pop club and then we'll have to club and then pop it.
So this is in this one work.
This is the only alternative.
Now, obviously, if we keep calling the method with different column labels, we definitely end up
removing several columns using pop.
But the point is that this needs to be done one column at a time, which is not very efficient.
The third point about using pop is that the method always works on the underlying and theater frame
directly.
In other words, it's as if it always operates with in place.
Set to true.
So if we pop a column, we're modifying the underlying data frame to no longer include that column.
So we pop Kolob here.
Now, if we take a look at the columns from our players data frame, there is no clopping here because
it's being pop.
And if we take that, take a look at the first couple of records, we see the same thing.
There's no clock.
OK.
So this the odd thing, it's as if pop operates within place.
Set to true.
Now it doesn't have an in place parameter.
Right.
But it's as if it had it and it was unchangeable.
It was always said to true.
OK.
OK, I'm trying to pop club twice here.
That's why I'm getting this error message.
So if we pop another column now, I'm popping age.
So going back here, if we rerun react security.
So we will see these H column disappear and we execute this order shall see it disappear from yours
as well.
So it's gone and it's gone.
OK.
So always be careful when using pop.
I mean, it's a very cute and convenient method, but it also does have some side effects that we should
be aware of.
If you want to remove a column and capture the remote sequence of values for whatever use case, this
is the perfect method for that.
But if you're planning on removing more than one column at once or you're exploring around and don't
want the changes to affect the underlying data frame yet, then I would advise using the drop method
instead, as we discussed in a previous lecture.
That's it for this one.