Python pandas: TypeError: tuple indices must be integers or slices, not str

3.1K    Asked by NehaTambe in Python , Asked on Mar 10, 2021

Hi. Please help me solve this error. I am trying to print row values

import pandas as pd

df = pd.read_csv(“/home/user/data1”)

for row in df.iterrows():

    print (row['Email'])

Answered by Neha Tambe

The typeerror: tuple indices must be integers or slices, not str error comes when you can't get row information using row["pool_number"].

You should simply use this method to retrieve the value by index number:

row_name[0]

Hope this answer helps you!

Thus, Linear Regression and Machine Learning Course, both are related.



Your Answer

Interviews

Parent Categories