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 Pandas DataFrame Notebooks from here.
Previous: DataFrame - itertuples() function
Next: DataFrame - pop() function
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/pandas/dataframe/dataframe-lookup.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics