Feb-12-2019, 07:30 PM
Hello all,
I'm have loaded a csv file into a dataframe using pandas. I want to compare the numbers in two columns, if col A is the same as col b, do this. If Col a is > col b, do this. and so on.
I'm pretty sure there is a shorter way to do this. Here is my code:
Thanks!!
I'm have loaded a csv file into a dataframe using pandas. I want to compare the numbers in two columns, if col A is the same as col b, do this. If Col a is > col b, do this. and so on.
I'm pretty sure there is a shorter way to do this. Here is my code:
Thanks!!
for index,row in puntos.iterrows(): if row["localGoals"] > row["visitorGoals"]: puntos["PuntosLocal"] = 3 puntos["PuntosVisitante"] = 0 print(row["localGoals"]) elif row["localGoals"] < row["visitorGoals"]: puntos['PuntosLocal'] = 0 puntos['PuntosVisitante'] = 3 else: puntos['PuntosLocal'] = 1 puntos['PuntosVisitante'] = 1