Skip to content

Pandas for Everyone Section 2.4.1 pg 36 #15

@paulhaus

Description

@paulhaus

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions