w3resource

Pandas DataFrame: lookup() function

DataFrame - lookup() function

The lookup() function returns label-based "fancy indexing" function for DataFrame.

Given equal-length arrays of row and column labels, return an array of the values corresponding to each (row, col) pair.

Syntax:

DataFrame.lookup(self, row_labels, col_labels)

Parameters:

Name Description Type/Default Value Required / Optional
row_labels  The row labels to use for lookup sequence Required
col_labels The column labels to use for lookup sequence Required

Returns: numpy.ndarray

Notes

Akin to:

result = [df.get_value(row, col)
          for row, col in zip(row_labels, col_labels)]

Example:


Download the above Notebook from here.

Previous: DataFrame - itertuples() function
Next: DataFrame - pop() function