jeudi 8 novembre 2018

Python Pandas If Else Return multiple values DataFrame value

I am trying to do the following:

  1. Pass Dataframe[['ID']['Team'] to function
  2. If Team is Blue, return 'Y' to 'Can he play?' and also return the value 'Blue' to 'Why?'

Below is my attempt at the code.

def play(df):
if df['Team'] in list(['Blue']):
    return 'Exclude','**************'  

df['Can he play?'],df['Why?'] = df.apply(play, axis = 1)

I do not know how to return the dataframe value from the conditional statement

How do I return 'Blue' (the value in df['Team'])

enter image description here

Aucun commentaire:

Enregistrer un commentaire