将行追加到相同的熊猫数据框

时间:2019-10-19 07:55:16

标签: python pandas

我需要将列表保存在一个Excel单元格中。或将输入错误的行追加到同一DataFrame。

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

然后我尝试将新的数据框追加到旧的数据框。我知道我会遇到双重错误。有什么方法可以使用iloc添加数据。

listOfErrors = []

    #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单元格中获取所有错误,或者在行中附加书面错误。因此,如果我的测试发现两个错误,那么我需要两行并在最后添加错误。

Thx

0 个答案:

没有答案