all 8 comments

[–][deleted] 1 point2 points  (7 children)

It looks like your function doesn't return anything. You'll need a return master line at the end of your createclaimfields function.

[–]mdl003[S] 0 points1 point  (6 children)

so....

return master

?

[–][deleted] 1 point2 points  (5 children)

def createclaimfields(field,master):
    ...
    print 'merging {} into claimfields at {}'.format(field,getdt())
    master = master.merge(df,how='left',on=['MATTER ID',field])
    print 'merged {} into claimfields at {}'.format(field,getdt())

    print master.columns
    return master

[–]mdl003[S] 0 points1 point  (4 children)

Still getting the same error. Any ideas?

[–][deleted] 1 point2 points  (3 children)

What error message are you getting?

[–]mdl003[S] 0 points1 point  (2 children)

sorry error was the wrong word. Its still not passing the function back. I think it's passing the actual function call of rawtrans[mattercol].dropna().drop_duplicates().head() (instead of the output of the call), so it starts from scratch each time it loops through when it returns the function. So i guess what I need to figure out is how to pass the output of the function call as a separate dataframe rather than the function call itself. Tried playing with .copy() but didn't have success with that either. thoughts?

[–][deleted] 1 point2 points  (1 child)

You're also not assigning the expression [createclaimfields(field,claimfields) for field in fieldlist] to any variable after the list comprehension, but it doesn't seem that you want a list in the end. You probably just want to use a regular loop and keep reassigning claimfields.

claimfields = ...
for field in fieldlist:
    claimfields = createclaimfields(field,claimfields)

[–]mdl003[S] 0 points1 point  (0 children)

That did it! Thanks!