调试ValueError:只能比较标记相同的Series对象

时间:2019-07-24 20:20:34

标签: pandas dataframe series

我正试图解决比较标记相同的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)

如上所述,发生错误。是比较数据框中的系列对象,而不是尝试将它们全部转换为字符串的问题的一部分吗?我确实尝试过这种方法,但最初并未成功。

0 个答案:

没有答案
相关问题