Source From Here
Question
I have a DataFrames from pandas:
Output:
Now I want to iterate over the rows of the above frame. For every row I want to be able to access its elements (values in cells) by the name of the columns.
How-To
iterrows is a generator which yield both index and row:
Question
I have a DataFrames from pandas:
- import pandas as pd
- inp = [{'c1':10, 'c2':100}, {'c1':11,'c2':110}, {'c1':12,'c2':120}]
- df = pd.DataFrame(inp)
- print df
Now I want to iterate over the rows of the above frame. For every row I want to be able to access its elements (values in cells) by the name of the columns.
How-To
iterrows is a generator which yield both index and row:
沒有留言:
張貼留言