How to resolve the typeerror int object is not subscriptable?

506    Asked by darsh_6738 in Data Science , Asked on Feb 16, 2023


Answered by Dipika Agarwal

To resolve the typeerror int object is not subscriptable: reader is a dataframe, since you want to iterate the rows you need to use the function iterrows:

import pandas as pd
reader = pd.read_csv('counts.csv', header = None)
for , row in reader.iterrows():
    label = row[2]
    print('row ',rowno,' label:', label)


Your Answer

Interviews

Parent Categories