Calling a function on a list with Python/Pandas -


i have following simple function:

def sumsubdesc(table,subs):     h2=table[(table['subdivision']==subs)&(table['area']=='260b')]     h3=h2[['list_price','sold_price']]     h4=h3.describe()     return h4 , subs 

and following list of subs:

subsl=['eagle point','heatherwood'] 

i want call sumsubdesc , have print result of function (which pandas describe) each subdivision in list so:

for subsm in subsl:     sumsubdesc(table, subsm)     print h4,subsm 

which gives:

          list_price     sold_price  count     355.000000     166.000000  mean   438701.030986  397962.518072  std    116994.150714  106734.004085  min    164900.000000  150200.000000  25%    359450.000000  330375.000000  50%    429900.000000  380000.000000  75%    499900.000000  458986.500000  max    873240.000000  898492.000000 eagle point            list_price     sold_price  count     355.000000     166.000000  mean   438701.030986  397962.518072  std    116994.150714  106734.004085  min    164900.000000  150200.000000  25%    359450.000000  330375.000000  50%    429900.000000  380000.000000  75%    499900.000000  458986.500000  max    873240.000000  898492.000000 heatherwood 

note name heatherwood , eagle point passed through not used ['subdivision'] table selection (line 2 of function) why data in describe same in both blocks. know i'm doing wrong scope don't know what?

change

for subsm in subsl:     sumsubdesc(table, subsm)     print h4,subsm 

to

for subsm in subsl:     h4, subsm = sumsubdesc(table, subsm)     print h4,subsm 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -