#PythonBasics: How to loop/iterate columns in a Pandas Data frame?
Its simple all you need is to open your Jupyter notebook, use Python 3.0 runtime, declare your Data frame object in python code and load data using a simple .csv file. An example is shown below:
Import Basic libraries
import numpy as np
import pandas as pd
Reading the data to a dataframe
housingdf = pd.read_csv(“train.csv”)
Declare a method and note that you will need to indent it by a tab for every line below method declaration
def loopingDataFrameColumns():
#for loop is used below
for column in housingdf:
#prints column name
if housingdf[column].dtypes == object:
print(column,” -“, housingdf[column].dtypes)
Thats how it will look like:

And its done. Here is the output if you call the method.
