我正试图解决比较标记相同的Series对象的值错误。
我看过以前的stackoverflow示例以及其他在线资源,但它们并没有帮助。我试图从数据帧PatientFrame中选择具有相同randomTime的行,并将其附加到新的dataFrame newFrame中。
newFrame = pd.DataFrame()
for identity in patientList:
patient = int(identity)
patientFrame = data.loc[data['person_id'] == identity]
randomselect = patientFrame.sample(n=1)
randomTime = randomselect['symptom_start_date']
timeExtract = patientFrame.loc[patientFrame['symptom_start_date'] == randomTime] #This is where the error occurs
newFrame.append(timeExtract)
如上所述,发生错误。是比较数据框中的系列对象,而不是尝试将它们全部转换为字符串的问题的一部分吗?我确实尝试过这种方法,但最初并未成功。