Skip to content

Instantly share code, notes, and snippets.

@ppeuchin
Created September 3, 2021 16:01
Show Gist options
  • Save ppeuchin/e28dc1d1482a7a6e58df14a6c3083a39 to your computer and use it in GitHub Desktop.
Save ppeuchin/e28dc1d1482a7a6e58df14a6c3083a39 to your computer and use it in GitHub Desktop.
Ranking Board
'''SoloLearn: 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.'''
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'])
x = int(input())
series = df[df["rank"] == x]
print(series["name"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment