Skip to content

Problem with DataFrame.lookup() #1001

@ijmcf

Description

@ijmcf

If the row and/or column labels are not present in the DataFrame, the lookup() method returns ... whatever it wants, apparently. I would expect either a NaN or an exception, personally - but whatever the result, it shouldn't be the wrong piece of data.

df = pandas.DataFrame({'A': pandas.Series(['A', 'B', 'C', 'D', 'E'], index=range(5))})

df.lookup([2], ['A']) # Correct
array([C], dtype=object)

df.lookup([10], ['A']) # 10 is not present in the index, so we get .. the last value in A?
array([E], dtype=object)

df.lookup([3], ['B']) # There is no column 'B', so we get ... the value from the last column (A) in that row?
array([C], dtype=object)

df.lookup([10], ['B']) # Neither row or column label is valid, so we get ... I can't rationalize this one.
array([D], dtype=object)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions