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:

Get hands-on with 1400+ tech skills courses.