Reputation: 2065
iterrows can be used to iterate through a pandas dataframe:
for row in df.iterrows():
print(row)
How can I use a second for loop to iterate through each element in the row?
Upvotes: 0
Views: 1672
Reputation: 2065
iterrows returns a tuple. The element indexed by [1] contains the row. You can then iterate through that element.
for row in x.iterrows():
print(row[1])
for b in row[1]:
print(b)
Upvotes: 1