I have a DataFrame
from pandas: 我有一个来自熊猫的DataFrame
: 框架
import pandas as pd inp = [{'c1':10, 'c2':100}, {'c1':11,'c2':110}, {'c1':12,'c2':120}] df = pd.DataFrame(inp) print df
Output: 输出: oop
c1 c2 0 10 100 1 11 110 2 12 120
Now I want to iterate over the rows of this frame. 如今,我要遍历该框架的行。 For every row I want to be able to access its elements (values in cells) by the name of the columns. 对于每一行,我但愿可以经过列名访问其元素(单元格中的值)。 For example: 例如: this
for row in df.rows: print row['c1'], row['c2']
Is it possible to do that in pandas? 熊猫有可能这样作吗? spa
I found this similar question . 我发现了相似的问题 。 But it does not give me the answer I need. 但这并不能给我我所需的答案。 For example, it is suggested there to use: 例如,建议在那里使用: .net
for date, row in df.T.iteritems():
or 要么 code
for row in df.iterrows():
But I do not understand what the row
object is and how I can work with it. 可是我不明白什么是row
对象以及如何使用它。 对象