close

How to iterate over columns of pandas dataframe to run regression

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to iterate over columns of pandas dataframe to run regression in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to iterate over columns of pandas dataframe to run regression?

  1. How to iterate over columns of pandas dataframe to run regression?

    You can use iteritems():
    for name, values in df.iteritems(): print('{name}: {value}'.format(name=name, value=values[0]))

  2. iterate over columns of pandas dataframe to run regression

    You can use iteritems():
    for name, values in df.iteritems(): print('{name}: {value}'.format(name=name, value=values[0]))

Method 1

for column in df:
    print(df[column])

Method 2

You can use iteritems():

for name, values in df.iteritems():
    print('{name}: {value}'.format(name=name, value=values[0]))

Conclusion

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read