comparing columns pandas python
csv, multiple-columns, numpy, pandas, python
Solution
The problem with your code is that `df[3] > df[1]` returns a `pandas.Series` of booleans and as the message says `The truth value of a Series is ambiguous`.
Try this:
df[6] = df[0] #sets default value
df.loc[df[3]>df[1],6] = df[2] #change when second wins
Then you can do `print df` or `print df[6]`.
Also you can do the reading part more easy: `df = read_csv('games.csv', delim_whitespace=True,header=None)`
Problem
I have a csv file with 5 columns and many rows in the following format: ``` BAL 27 DEN 49 2013-09-05T20:30:00 ``` I want to compare the 2 scores and return the name of the winner as a 6th column I tried this: ``` from pandas import read_csv Games = open("games.csv","rb") df = read_csv(Games, header=None) #print df #print df[0] if df[3] > df[1]: print df[2] else: print df[0] ``` I am getting an `ValueError: The truth value of a Series is ambiguous` Any ideas how I can accomplish my goal?