0

I have a list of items that I loop to find values example: dfexample1

#List of documents:   
list1 = ['doc1.pdf', 'doc2.pdf', 'doc3.pdf']

#each document contains a DF with the same Test columns with the same Tets letters:

doc1.pdf: df1

 Test | Value
  a   |  5.5
  b   |  6.5
  c   |  8.5

doc2.pdf: df2

 Test | Value
  a   |  6.5
  b   |  11.5
  c   |  13.5

doc3.pdf: df3

 Test | Value
  a   |  12.5
  b   |  3.5
  c   |  9.5

I have a df with the Test values being the columns

a | b | c

in each loop I am trying to extract the value of each test and ad them to the df.

in the first example the same analysis will be repeated over a list of pdf documents so I need to extract each of those values and add them into de df.

I tried this:

for items in list:
    for index, row in dfexample1.iterrows():
        if item in row[0]:
           value1=row[1]

Verifying if value exists as column in the df:

 if items in df.columns:
    #How can I insert this value in the next row?

My expected result would be:

  a | b  | c
 5.5|6.5 |8.5
 6.5|11.5|13.5
12.5| 3.5|9.5

.T would not work I guess because the dfexample1 will be repeated with different values while looping across documents.

0 Answers0