use value of column/index within pandas DataFrame applymap function?

64 views
Skip to first unread message

Colin Dillard

unread,
Jun 17, 2016, 12:59:20 PM6/17/16
to PyData
Hi,

I would like to reference the value of the column 'name' within a function applied to a pandas DataFrame via applymap.  Is there a way to do this?  If not, it is useful functionality that I would recommend adding to applymap and apply.

Here's an example:

rates = [0.05, 0.5]
draws = DataFrame(numpy.random.random([10, len(rates)]), columns=rates)
successes = draws.applymap(lambda x: x < rate)
#where I would like rate to be equal to the corresponding value from draws.columns for each column

Thanks!  Colin
Reply all
Reply to author
Forward
0 new messages