Array passed to an array


I was just seeking some clarification on why the following is possible:

selected_rows = f500[f500[“country”] == c]

More precisely: why do we pass (f500[“country”] == c) to f500?

It appears to me that we are passing a boolean test no an array like: f500[(boolean test)] but why isnt f500[“country”] == c) to f500 sufficient to pass the boolean test to the selected_row variable?

I have been trying to discover which library it comes from (if it is numpy or pandas) but I can seem to locate or maybe I’m not looking hard enough.

I think that I sort of understand that the results of the boolean test are being passed onto the array which is then an array of values from f500 based on that boolean test. But i would like someone to clarify it. Is this part of the way pandas can handle arrays as in vector math etc?

I am just trying to under stand why that works and where it comes from. It is better for me to understand it 100% that sort of understand it and have to relearn it later.

Thank You!

1 Like