
Erik W. answered 05/16/18
Tutor
5
(11)
Finance and Statistics Professional with Real World Experience
Try this (its in python 3.6). For some reason this editor doesn't see the indent for the for loop so I spaced it.
import pandas as pd
inp = [{'c1':10, 'c2':100}, {'c1':11,'c2':110}, {'c1':12,'c2':120}]
df = pd.DataFrame(inp)
print(df)
print("\n","For Loop Output:")
for indexer in df.index:
print(df.loc[indexer,"c1"],",", df.loc[indexer,"c2"])
inp = [{'c1':10, 'c2':100}, {'c1':11,'c2':110}, {'c1':12,'c2':120}]
df = pd.DataFrame(inp)
print(df)
print("\n","For Loop Output:")
for indexer in df.index:
print(df.loc[indexer,"c1"],",", df.loc[indexer,"c2"])