Im trying to write a function takes the X Coordinate from an existing column and multiplies it by negative 1 if certain conditions are met. The function compiles fine, but I keep getting hit with the The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
error message once I apply it to the column of interest.
My function:
def xCoordFlip(xCoord):
for xCoord in df['xCoord']:
if df.loc[(df.period == 2) & (df.period == 4) & (df.name == 'A')]:
return df['xCoord'] *-1
if df.loc[(df.period == 1) & (df.period == 3) & (df.name == 'A')]:
return df['xCoord']
if df.loc[(df.period == 2) & (df.name == 'B')]:
return df['xCoord'] *-1
if df.loc[(df.period == 1) & (df.period == 3) & (df.name == 'B')]:
return df['xCoord']
Basically I want to write a function that takes an X Coordinate and flips it if certain conditions are met. I'm guessing my understanding of Boolean conditions and their applications is way off, so any help would be most appreciated.