0
Why does the last two lines give the same output?
import pandas as pd data = { 'name': ['James', 'Billy', 'Bob', 'Amy', 'Tom', 'Harry'], 'rank': [4, 1, 3, 5, 2, 6] } df = pd.DataFrame(data, index=data['name']) print(df ['name'] [df['rank']==int(input())]) print(df[df['rank']==int(input())][ânameâ])
1 Answer
0
Because both are valid and both index the same cell
1) indexes the cell by name column
2) indexes the cell by the dataframe row and then picks the column