All right, now you know how to extract
portion of a dataframe. But how about
deleting columns or rows from the DataFrame?
Well, for that, you'd want to use
df7.drop, so the drop method, know
that this is also not an inplace
operation. So your df7 DataFrame
will not be updated with the deleted column.
And here let me delete the City
column. You'd pass City for the column
name, and then 1, and so 1
argument means that you are about to
delete columns. That's how you tell
Pandas or Python, what you're about to
delete, or when you delete rows, you
want to pass a 0 there. So and yeah, this
is the on the fly DataFrame with
all the City column there. So again, df7
with City and drop, let me
drop 332 Hill St, 0
and yeah, Hill Street is not there.
[No audio]
And of course, if you want to update
your DataFrame with the changes you
do that, then when you print out your df7
DataFrame, the Hill Street
not there, and yeah, if you want to drop
columns or rows based on indexing, you
do a trick like df7 and then points
to index, and then what do you want?
Well, 0 to 3 maybe. So you're deleting
rows, execute that, and you gather three
rows only. Similarly with columns, columns
and 1 in here.
[No audio]
So you get ID, Name,
and State, the first three columns. So if
that confused you, you know, df7.index,
what that gives you is a
series with a name so with the labels of
your index column, so all this, and
similarly, columns gives you the names of
your columns. So that's how you access
the, your, the header of your DataFrame,
and the index column. Yeah, that was about
deleting columns and rows from DataFrame.
If you have questions, just feel
free to ask them, and I'll talk to you
in the next lecture.