Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (19.9k points)
edited by

How to iterate over rows in a Dataframe in pandas (Python)?

1 Answer

0 votes
by (25.1k points)

You can iterate over rows in DataFrame in pandas by using a for loop and iterrows method on the dataframe you wish to use. iterrows method will return an iterator and which is just an object that allows you to use a for loop over it and iterate over it's contents. Heres an example:

for index, row in employee_df.iterrows():

    print(row['name'], row['email'])

You can learn more about pandas by watching this video:

Browse Categories

...