python - How to access column via index when using iterrows() -


i want know how can access columns using index rather name when using iterrows traverse dataframes.

this code find:

for index, row in df.iterrows():     print row['date'] 

this approach took traverse, seems slow:

for in df.index:     j in range(len(df.columns)):                            df.ix[i,j] = 0 

you can use ix access index:

in [67]: df out[67]:         b 0  test1  1 1  test2  4 2  test3  1 3  test4  2  in [68]: df.ix[:,1] out[68]: 0    1 1    4 2    1 3    2 name: b, dtype: int64 

updating code first column:

for index, row in df.iterrows():     row.ix[0] 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -