Transcript:
We look at indexing. Using is in, lets. Create a simple series to show you an example. Stop reading that series. Let’s use number vampires. Our range method. Let’s say 7 in P. DOT Arrange 7 & 4 index. Let’s also use vampire’s array method and then well index our series using a reverse order so we can say index starting with Negative 1 so indexing in this case will start with 6 and then goes down to 0 6 5 4 3 2 1 And so on, let’s save this in a variable called. SS, let’s see our series object. So we have values 0 through 6 and then indexing is in reverse order, 6 5 4 3 2 1 0 Let’s use is in to see which of the indexes have the values 1 3 5 4 7 How can we do that? You can simply say so our series object. SS, that is in, and then you simply pass a list of the values that we want in this case 1 3 5 & 7 So this is our series object is in 1 3 5 or 7 so this will return a boolean true or false for each of our index values, for instance, Index 6 is 0 so that will be false for our second row. The value is 1 so that will be true and it will also be true for Index 3 cause the value is 3 and so on. So if we run this, we get false, true, false, true false. Whenever the value is equal to 1 3 5 or 7 we get true for that index, and if we only want to see if we want to see each index and value where this condition is true, we can simply say our series object where our series object is in 1 3 5 and 7 5 4 7 in this case. Were all will see 1 2 3 rows right since the the values are 1 3 & 5 OK, next, let’s create a data frame and see an example of how we can use indexing using is in and lets. Save it in a variable called data frame so pretty that data frame. Let’s use a dictionary to create our data frame. Let’s say kimmy14. Our key and 4 values. Let’s pass a list of numbers 1 2 3 4 & 5 for our second key key and value combo. Let’s say Key 2 & 4 values. Let’s pass a list of alphabets. Let’s say a B C DN E. Let’s pass one more key and value combo, key, three and four values. Let’s pass another list of alphabets. Let’s say X Y Z S and K. So if we look at our data frame, we have five rows and three columns and let’s create some values. Let’s say we want to see the rows where certain values are true and let’s save this in a variable called bar and let’s say we want to see the values. X OK, 4 & 5 So we can say our data frame is in and then let’s pass the values that we created. We saved it in this variable var, so we’ll pass that. And if we run this, we get a boolean result, true or false. So whenever wherever we have one of the spiders in our data frame, we have true, and if we want to see the rows where those conditions are true, we can simply say data frame where our data frame values design variables, right, and that will give us the rows, so the first one X and the last two, they have those values specified in our variables here X K 4 and 5 4 5 K and X and we get no value for the remaining and similarly we can create different variables. Let’s say let’s create one, two three. What else do you have here? B and C, let’s say B and C. So if we want to see this variables in our data frame you to simply say our data frame is in everything. Simply pass our variables object, so this will return true if our data frame has dis values, so whenever these conditions are true, we get true, so whenever we have this final data frame 1 2 3 BC, we get 3 value, true value for those variables, so if we see our original data frame, this is that so since the values here are 1 2 3 we get through photos and the rest are. BNC PNG are right here. So we got through photos. Great, so this is what I have for indexing using is in. So in this lecture. We looked at examples of how we can use easing in series and data frame. Thank everyone and see you at the next lecture.