vendredi 3 juillet 2020

How to correct code? Trying to output using list comprehension with lambda if/else statement using pandas

would like to know why is my output for the following code pointers and not the values 1 or 0. How can it be corrected (using 1 line of list comprehension)?

Code:

winner_A = new['Winner']==new['A']
new['Winner_integer'] = [(lambda x: 1 if winner_A[row] is True else 0) for row in range(len(winner_A))]

Current output:

array([<function <listcomp>.<lambda> at 0x0000018DB48B8828>,
   <function <listcomp>.<lambda> at 0x0000018DB48B8798>,
   <function <listcomp>.<lambda> at 0x0000018DB48B8678>, ...,
   <function <listcomp>.<lambda> at 0x0000018DB57D7708>,
   <function <listcomp>.<lambda> at 0x0000018DB57D7798>,
   <function <listcomp>.<lambda> at 0x0000018DB57D7828>]

Aucun commentaire:

Enregistrer un commentaire