我有DataFrame
只Pandas :
imp或t pandas as pd
inp = [{'c1':10, 'c2':100}, {'c1':11,'c2':110}, {'c1':12,'c2':120}]
df = pd.DataFrame(inp)
print df
输出:
c1 c2
0 10 100
1 11 110
2 12 120
现在我想遍历此框架的各行.对于每一行,我希望能够按列的名称访问其元素(单元格中的值).例如:
f或 row in df.rows:
print row['c1'], row['c2']
有可能在Pandas 身上做到这一点吗?
我找到了这个similar question.但它并没有给我所需要的答案.例如,建议使用:
f或 date, row in df.T.iteritems():
或
f或 row in df.iterrows():
But I do not understand what the row
object is and how I can w或k with it.