Created
September 3, 2021 16:01
-
-
Save ppeuchin/e28dc1d1482a7a6e58df14a6c3083a39 to your computer and use it in GitHub Desktop.
Ranking Board
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''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