1

I have the following table:

(https://i.stack.imgur.com/nV4RA.png)

And the following list:

(https://i.stack.imgur.com/0SGyO.png)

What I wish to do is to extract the information from the Cell type, treatment, field 1 and field 2 columns when there is a match between the Location column in my table and the string in my list.

What I expect to obtain is for example: if r01c01 from the table [in the column Location] is present in my string list, then get a variable for each individual information like this:

cell_type=HCT WT

treatment=NT

field_1=25

field_2=34

I have tried the following code just to obtain the information from Field 1, however I am getting the following error: InvalidIndexError: ([], 'Field 1')

for i in range(len(subfolders_name)):
    y=exp['Location']==subfolders_name[i]
    indices_true=[index for index, item in enumerate(y)
            if item is True]
    print(exp[indices_true, 'Field 1'])

I am not sure whether this is the right approach, or there is just something missing from my code. Thank you!

1 Answers1

0

You can do this using the following:

df = exp[exp['Field 1'].isin(subfolders_name)]
ali bakhtiari
  • 1,051
  • 4
  • 23