python - Pandas issue iterating over DataFrame -


i'm using pandas scrape web page , iterate through dataframe object. here's function i'm calling:

def getteamroster(teamurl):     teamplayers = []     table = pd.read_html(requests.get(teamurl).content)[4]     nametitle = '\n\t\t\t\tplayers\n\t\t\t'      ratingtitle = 'singlesrating'     finaltable = table[[nametitle, ratingtitle]][:-1]     print(finaltable)     index, row in finaltable:         print(index, row) 

i'm using syntax advocated here:

http://www.swegler.com/becky/blog/2014/08/06/useful-pandas-snippets/ 

however, i'm getting error:

file "squashscraper.py", line 46, in getteamroster     index, row in finaltable: valueerror: many values unpack (expected 2) 

for it's worth, finaltable prints this:

   \n\t\t\t\tplayers\n\t\t\t  singlesrating 0                browne,noah           5.56 1             ellis,thornton           4.27 2                 line,james           4.25 3          desantis,scott j.           5.08 4           bahadori,cameron           4.97 5              groot,michael           4.76 6              ehsani,darian           4.76 7                 kardon,max           4.83 8                 van,jeremy           4.66 9     southmayd,alexander t.           4.91 10        cacouris,stephen           4.68 11         groot,christopher           4.62 12       mack,peter d. (sub)           3.94 13      shrager,nathaniel o.           0.00 14       woolverton,peter c.           4.06 

which looks right me.

any idea why python doesn't syntax?

thanks help, bclayman

you want try this:

for index, row in finaltable.iterrows():     print(index, row) 

Comments

Popular posts from this blog

html - How can i make an element from a bottom stacking context stays in front of another higher stacking context? -

python - TypeError: start must be a integer -

html - href attribute breaking an element -