I would like to assign names for the new column "SubtestName" based on the "SubtestID" column.
Currently my codes are as follows:
conditions = [(df4['subtestID'] == 325)|(df4['subtestID'] == 341)|(df4['subtestID'] == 1164)|(df4['subtestID'] == 1200),
(df4['subtestID'] == 347)|(df4['subtestID'] == 357)|(df4['subtestID'] == 1308)|(df4['subtestID'] == 1330),
(df4['subtestID'] == 328)|(df4['subtestID'] == 344)|(df4['subtestID'] == 1167)|(df4['subtestID'] == 1203)]
values = ["TestName1","TestName2","TestName3"]
df4['subTestName'] = np.select(conditions, values)
I would like to rewrite my codes in a better way without repeating "df4['subtestID']" every time I want to assign a new ID. I am planning to assign another 30 subtestnames.
I tried using this way but it gave me an error.
df4['subtestID'] in (325,341,1164,1200)
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
Any other methods I can use to assign the names to the SubtestID?