Suppose I have Panda’s DataFrame and I want to access all its rows through iteration. For this purpose, I have found a code, but it is giving me an error.
Error:
TypeError Traceback (most recent call last)
<ipython-input-3-0316491eec2e> in <cell line: 10>()
8
9 # iterate over each row and print the name and age
---> 10 for row in df.itertuples:
11 print(row.name, row.age)
TypeError: 'method' object is not iterable
Here is the code:
Can someone correct the above code or provide me with a code that iterate over DataFrame’s rows?