...

/

Pandas DataFrame Operations - Selection, Slicing, and Filtering

Pandas DataFrame Operations - Selection, Slicing, and Filtering

4. Data Selection and Slicing

We have learned how to get a high-level view of our data and some basic data summaries. Now let’s focus on some more interesting DataFrame manipulation techniques, performing data selection, slicing, and extraction. For a clearer understanding, we will look at working with columns and then we will learn how to manipulate DataFrames row-wise.

One important thing to remember here is that although many of the methods can be applied to both DataFrame and Series, these two have different attributes. This means we need to know which type of object we are working with. Otherwise, we can end up with errors.

a. Working With Columns

We can extract a column by using its label (column name) and the square bracket notation:

Press + to interact
genre_col = movies_df['Genre']

The above will return a Series object. If we want to obtain a DataFrame object as output instead, then we need to pass the column ...

Access this course and 1400+ top-rated courses and projects.