Filtering a data frame

We can select/filter specific rows based on criteria (using the same Titanic data frame):

print(df[df.age < 5])  

This means that we look into the data frame and select the rows where the age of the person is below five years old. (Again, this is creating a new data frame that can be manipulated as needed.)

If you think about this, you can apply almost any filter to a data frame. Then you can do things like select part of one data frame and combine/join with parts of another data frame. Very quickly, you end up with SQL-like manipulations that can be performed on database tables. With that point of view, you are open to a much wider spectrum of data manipulation than would appear in the base data frame.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.134.102.182