Ranking Board - Python Data Science Course (Pandas)
Ranking Board You are given a DataFrame that includes the names and ranks of people. You need to take a rank as input and output the corresponding name column from the DataFrame as a Series. Note that the rank is an integer, so you need to convert the user input to an integer. Here is my code: ---------------------------------- 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']) y = df['name'] print(y.iloc[rank-1]) ------------------------------ the output I got is Bob but they want Bob Bob Name: name, dtype: object I tried my best, not sure how to get the output as the series that they want it. Please any clue would be great. Thank you so much. Please help! I love sololearn a lot