mardi 3 mars 2020

How to replace data in csv file based on criteria?

I want to replace all data in WinorLoss column from W/L to 1/0 (1 if W and 0 if L)..

WinorLoss is a column in my csv file which is populated with W's or L's for corresponding games

I have tried the following:

if df.WinorLoss == "W":
 df.WinorLoss == "1"
else:
 df.WinorLoss == "0"

Got the following error: ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

I am new to python so am not 100% how to go about to do this.. any help would be appreciated?

Aucun commentaire:

Enregistrer un commentaire