import pandas as pd
import numpy as np
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']}
C
A
print("Original rows:")
print(df)
print("\nReplace the 'qualify' column contains the values 'yes' and 'no' with True and False:")
B
print(df)
- df = pd.DataFrame(exam_data , index=labels)
- df['qualify'] = df['qualify'].map({'yes': True, 'no': False})
- labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']