chendaniely / pandas_for_everyone

Repository to accompany "Pandas for Everyone"
http://a.co/d/c270uul
MIT License
389 stars 402 forks source link

Pandas for Everyone Section 2.4.1 pg 36 #15

Open paulhaus opened 3 years ago

paulhaus commented 3 years ago

Hello, I'm a Python Baby and am going through the book line by line. Section 2.4.1 Boolean Subsetting: DataFrames has a command line which is not performing the way the book suggests.

4 values passed as bool vector

3 rows returned

print(scientists.loc[[True, True, False, True]])

The book says that 3 rows should be returned, index 0, 1 and 3. Which seems to make sense.

But the Return line says IndexError: Boolean index has wrong length: 4 instead of 8 Which also seems to make sense, so I'm confused.

Can I get some clarification? Thanks Paul