将行附加到同一数据帧

2024-07-02 12:31:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要将列表保存在一个excel单元格中。或将输入错误的行附加到同一数据帧

我尝试将所有错误附加到列表中,然后将此列表写入数据帧(列表必须在一个单元格中)。 这有可能吗

然后我尝试将新的数据帧附加到旧的数据帧。我知道我会犯双重错误。有没有办法用iloc添加数据

错误列表=[]

    #ISKANJE NAPACNO VPISANIH PODATKOV
    errorIme = odpriChrome.find_element_by_xpath('//*[@id="page"]/div/section/article/form/section[2]/div[1]/div[2]/div/div[2]/div').is_displayed() 
    if errorIme == True:
        text= 'Ime;'
        listOfErrors.append(text)
        testDT.loc[customer, 'test'] = listOfErrors

    errorPriimek = odpriChrome.find_element_by_xpath('//*[@id="page"]/div/section/article/form/section[2]/div[2]/div[2]/div/div[2]/div').is_displayed()
    if errorPriimek == True:
        text = 'Priimek;'
        listOfErrors.append(text)
        testDT.loc[customer, 'test'] = listOfErrors

napaka=pd.DataFrame()

    errorIme = odpriChrome.find_element_by_xpath('//*[@id="page"]/div/section/article/form/section[2]/div[1]/div[2]/div/div[2]/div').is_displayed() 
    if errorIme == True:
        text= 'Ime;'
        testDT.loc[customer, 'test'] = text
        napaka = testDT.iloc[customer]
        testDT = testDT.append(napaka, ignore_index = True)
    errorPriimek = odpriChrome.find_element_by_xpath('//*[@id="page"]/div/section/article/form/section[2]/div[2]/div[2]/div/div[2]/div').is_displayed()
    if errorPriimek == True:
        text = 'Priimek;'
        testDT.loc[customer, 'test'] = text
        napaka = testDT.iloc[customer]
        testDT = testDT.append(napaka, ignore_index = True)

我需要在一个excel单元格中获取所有错误,或者附加有书面错误的行。因此,如果我的测试发现了两个错误,我需要在最后添加两行错误

泰铢


Tags: 数据textdivtrue列表by错误section