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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -