
The setup:
Adata
array([(1, 24, 'Male', '', 212, 193, 'High Pass'), (2, 26, 'Male', 'Caucasian', 234, 221, 'Honors'), (3, 31, 'Female', 'Caucasian', 182, 189, ''), (4, 27, 'Female', 'Hispanic', 214, 211, 'High Pass'), (5, 27, 'Female', 'Asian', 213, 204, 'Pass'), (6, 29, 'Female', 'Caucasian', 209, -1, 'High Pass'), (7, 26, 'Female', 'Hispanic', 212, -1, 'Honors'), (8, 25, 'Female', 'Caucasian', 230, 238, 'Honors'), (9, 27, 'Female', 'Caucasian', 239, 245, 'Honors'), (10, 26, 'Male', 'Caucasian', 226, -1, 'Honors')], dtype=[('ID', '<i8'), ('Age', '<i8'), ('Gender', '|S6'), ('Ethnicity', '|S12'), ('USMLE_1', '<i8'), ('USMLE_2', '<i8'), ('Medicine_Clerk', '|S9')])
BData
array([(1,), (1,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (1,)], dtype=[('Gender', '<i8')])
How do replace the "Gender" column in Adata with that in BData and update the datatype.
Adata['Gender'] = Bdata['Gender'] Adata
array([(1, 24, '1', '', 212, 193, 'High Pass'), (2, 26, '1', 'Caucasian', 234, 221, 'Honors'), (3, 31, '0', 'Caucasian', 182, 189, ''), (4, 27, '0', 'Hispanic', 214, 211, 'High Pass'), (5, 27, '0', 'Asian', 213, 204, 'Pass'), (6, 29, '0', 'Caucasian', 209, -1, 'High Pass'), (7, 26, '0', 'Hispanic', 212, -1, 'Honors'), (8, 25, '0', 'Caucasian', 230, 238, 'Honors'), (9, 27, '0', 'Caucasian', 239, 245, 'Honors'), (10, 26, '1', 'Caucasian', 226, -1, 'Honors')], dtype=[('ID', '<i8'), ('Age', '<i8'), ('Gender', '|S6'), ('Ethnicity', '|S12'), ('USMLE_1', '<i8'), ('USMLE_2', '<i8'), ('Medicine_Clerk', '|S9')])
Ok so now I need to change the dtype, not having much luck with that , do I need to copy the array?
Is there a nice way to do this? That is swap Adata['Gender'] = Bdata['Gender'] and update the dtype at the same time?
participants (1)
-
Vincent Davis