Skip to content

Commit 47e0b1b

Browse files
committed
Adding an example
1 parent a5e379b commit 47e0b1b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/core/frame.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5154,6 +5154,23 @@ def lookup(self, row_labels, col_labels) -> np.ndarray:
51545154
-------
51555155
numpy.ndarray
51565156
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])
51575174
"""
51585175
n = len(row_labels)
51595176
if n != len(col_labels):

0 commit comments

Comments
 (0)