0 votes
in Python Pandas by
How to iterate over a Pandas DataFrame?

1 Answer

0 votes
by
You can iterate over the rows of the DataFrame by using for loop in combination with an iterrows() call on the DataFrame.

import pandas as pd

 import numpy as np

df = pd.DataFrame([{'c1':10, 'c2':100}, {'c1':11,'c2':110}, {'c1':12,'c2':120}])

for index, row in df.iterrows():

    print(row['c1'], row['c2'])

Output:

   10 100

   11 110

   12 120

Related questions

0 votes
asked Feb 10, 2021 in Python by SakshiSharma
0 votes
asked Nov 9, 2021 in Python Pandas by Robin
...