We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a5e379b commit 47e0b1bCopy full SHA for 47e0b1b
pandas/core/frame.py
@@ -5154,6 +5154,23 @@ def lookup(self, row_labels, col_labels) -> np.ndarray:
5154
-------
5155
numpy.ndarray
5156
The found values.
5157
+
5158
+ Examples
5159
+ --------
5160
+ >>> df = pd.DataFrame(
5161
+ ... {
5162
+ ... "Math_Sem1": [85, 92, 78, 88, 95],
5163
+ ... "Math_Sem2": [88, 90, 82, 85, 93],
5164
+ ... "Science_Sem1": [90, 85, 92, 79, 87],
5165
+ ... "Science_Sem2": [92, 87, 90, 83, 89],
5166
+ ... "English_Sem1": [95, 80, 85, 90, 82],
5167
+ ... "English_Sem2": [93, 82, 87, 88, 80],
5168
+ ... },
5169
+ ... index=["Alice", "Bob", "Charlie", "David", "Eve"],
5170
+ ... )
5171
+ >>> student_top = df.rank(1).idxmax(1) # Column name for student's top score
5172
+ >>> df.lookup(df.index, student_top)
5173
+ array([95, 92, 92, 90, 95])
5174
"""
5175
n = len(row_labels)
5176
if n != len(col_labels):
0 commit comments