samedi 5 mai 2018

IF else flow control in Python 3

I am new to python and is working on logical statement. My objective is to count the goal score by teams. (i.e. if a team scored a goal, i will assign 1 and the opponent will be assigned -1).Below is the snap shot of the data. Data is below

I wrote logical statement as follow:

if data['team']== data['hometeam_team1']: data['run_score'] = 1 else: data['run_score'] = -1

but it threw me value error "ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()."

Can anyone advise? Your help is much appreciated. Thanks Aung

Aucun commentaire:

Enregistrer un commentaire