I want to return multiple values from the function and print them separately (not as tuple).Multiple return is simple function (first part od code is ok), but I am not able to return two values in conditional function. can I return multiple values and print them separately (for the second part)?
dataset = {'A': [6, 2, 3, 4, 5, 5, 7, 8, 9, 7],
'B': [5, 1, 2, 3, 4, 4, 6, 7, 8, 6],
'C': [0, 1, 0, 1, 1, 0, 1, 0, 1, 0]}
data = pd.DataFrame(dataset)
#this part of code is ok to return muntiple values
def quanta():
return ((data['A']+data['B']),(data['A']-data['B']))
a, b = quanta()
print(a)
print(b)
#I want to return two values a and b with the if condition. I just add the if statement to the above code it doesn't work.
def quanta():
if data['C'] > 0:
return ((data['A']+data['B']),(data['A']-data['B']))
a, b = quanta()
print(a)
print(b)
#ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), #a.any() or a.all().