In this lesson, we'll look at various ways of selecting data frame data including selecting data using a bullying mask. Creating a mask using comparison operators, using pandas boolean operations and createing a new column. Let's look at some approaches to selecting and filtering data in a panda's data frame. First, we'll set up our data frame and pandas as we have before from a CSV file. We've called ahead to see the first two rows just to see what some of our data looks like. Next in this frame, what I've done is have created a list of boolean values, the same length as the number of rows in the data frame. So that's one true or false for every row and I've marked all of the rows false except for the rows 3 through 6. So we can see we have a list, and they're all false except for these 4. Now I can use this list of booleans, and use it as an argument to the bracket syntax of our data frame. And what this does, is it returns only the rows that had a true value, that matched up to their row position. Now this doesn't only work with the brackets, index. We can also use it with the locks index and get the same result. So this is called a boolean mask, and it's integral to the approaches to filtering we're going to look at now. So the first mask I created, I explicitly said which rows were true and false. This is a possible approach but not a very useful approach when you're trying to understand your data. A more useful approach, is to start using comparison operators. So in this example, we're comparing the values two columns. The lives lost after CG notification, and the lives lost before CG notification. And what we're saying here, is we want a mask of bullying values with a true for any time, this condition is true. And we can see it for many years,it's false until 1979, and then for many years it's true. Now we can take this mask. And use it the same way we did with the original bullying mask. But in this case, the result is pulling up only columns that matched the condition we set up. So this is only columns where the lives lost before CG notification is greater than columns where the lives lost after CG notification. Now, the comparison operator doesn't have to be between columns, it can also be with the value. So we could create a mask for all the lives lost after CG notification, less than 600. Let's just call our mask directly here, and we can see, we get all the rows or the lives lost after CG notification have a value, that is less than 600. We've already seen the idea of boolean operators. Pandas uses the python bullying operators, and overrides them for use in creating masks. The three operators are and, or, and not. Let's look at the summary statistics for our data frame. And let's say we want to create a mask where all the cases are less than 60,000. The number of sorties is greater than 4500, this is what our mask would look like. So here in parentheses, we create a filter for all the cases less than 60,000. And then here we create a filter for all the sorties greater than 4500, we then join these together using the and operator. And this creates our mask, which we can then use to filter our data frame, returning only the rows that fit these two conditions together. Another thing we can do with a data frame is create a new column. We can create a new column using the same selection syntax. We used to look at an individual column, and here we are creating our new column by doing an operation between two existing columns. So we're dividing the lives saved by the number of sorties, to see the average number of lives saved per sortie. Now, once we do this, we can see that our new column saved per sortie has been added. And that is populated with data, that data is the result of the operation we performed between two other columns. You've seen how to select data frame data using bullying masks, created using comparison operations, and pandas boolean operators. You've also seen how to create a new column from the results of operations on existing columns. Now, you should try selecting data frame data.