@WilfriedF I believe this code is unecessary in our case here since == is the equality operator vs = which is the assignment operator (see here). Hence, the above line of code will check to see if the expressions on the left and right of == are in fact equal and will simply return True or False which is not something we need to do here.
I’m going to go out on a limb here and guess that @ipngasi is asking why they get an error for taxi[taxi[:, 6] ==2] = jfk as opposed to jfk = taxi[taxi[:, 6] ==2]. If so, the reason for this is python syntax.
When assigning a value (like: 5, “Some text”, or taxi[taxi[:, 6] ==2]) to a variable (like : x, string, or jfk), python requires you to place the variable name to the left of = and the value you want to assign to it to its right. I always like to think of this as reading from right to left: "assign the value of right side to the variable left side.
In other words, taxi[taxi[:, 6] ==2] = jfk will take the value of jfk and will try to store it in taxi[taxi[:, 6] ==2]. This will cause an error if there is no value currently stored in jfk. If jfk did have a value assigned to it, this line of code would assign that value to every row that has a value of 2 in the 6th column of taxi. This is not what we want to do in this particular case. This could be helpful in other situations though. Think of this line of code like a “filtered assignment.”
That said, what we actually want to do here is to assign the value of taxi[taxi[:, 6] ==2] to the variablejfk and we do that using this syntax:
variable = value
Therefore the correct syntax is: jfk = taxi[taxi[:, 6] ==2]
Also it was the key word if that tipped me off in the sentence “Why it said jfd is not defined if i put " taxi[taxi[:, 6] ==2] = jfk”?" – which implied that his question was “hypothetical” and not coming from the actual code provided. I did have to assume that jfd was a typo of jfk though…