TypeError: 'builtin_function_or_method' is not iterable

I have the code below:

import sys
import pandas as pd
matrix = pd.read_table('testGEM.txt')
ID = pd.read_table('test_transcripts.txt', header = None)
ls = ID.values.tolist()
list=[]
for sublist in id:
    for item in sublist:
        list.append(item)
id = tuple(list)
x = matrix[matrix.index.isin(id)]
x.to_csv('test10.out',sep='\t')

However, when I run the code, I got a problem saying:

Traceback (most recent call last):
File "map.py", line 7, in <module>
for sublist in id:
TypeError: 'builtin_function_or_method' object is not iterable

Does anyone have any idea where is the problem?

1 answer