Skip to content

New to python, need help on Question 2 #2

@LalehT

Description

@LalehT

Hi,
could you please explain what does this piece of code do? why should we use Boolean masking?
x = max(df['Gold'] - df['Gold.1'])
ans = df[(df['Gold'] - df['Gold.1']) == x].index.tolist()

and why doesn't something like this work?
ans = df[max(df['Gold']-df['Gold.1'])].index.tolist()

and what does this do?
.index.tolist()

Thanks in advance.

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