PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import pandas as pd
data = {
'name': ['James', 'Billy', 'Bob', 'Amy', 'Tom', 'Harry'],
'rank': [4, 1, 3, 5, 2, 6]
}
rank = int(input())
df = pd.DataFrame(data, index=data['name'])
#look at how this df is called
#print(df[df['rank']==rank])
#here we slice the df by 'name'
print(df[df['rank']==rank]['name'])
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run