Q. Write a Python program to select the rows where the number of attempts in the examination is greater than 2.
exam_data = {'name': ['Anastasia', 'Dima', 'Katherine', 'James', 'Emily', 'Michael', 'Matthew', 'Laura', 'Kevin', 'Jonas'], 'score': [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19], 'attempts': [1, 3, 2, 3, 2, 3, 1, 1, 2, 1], 'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}
labels = ['a', 'b', 'e', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
Answer :-
df = pd.DataFrame(exam_data, index = labels) df[df.attempts > 2]
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )