I'm currently trying to apply the concept of vectorization using Pandas. I've been successfully able to use crude looping, but on the same code, when I try to vectorize and pass the entire Series to a function I get
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
My function is rather simple:
def price_function(x):
if x >= 50:
return "High"
else:
return "low"
And I'm calling it with the price
Series of a Dataframe with the following:
listing_price = price_function(listings_dataframe_big['price'])
And the error is being triggered by the following line:
if x >= 50:
Any idea on why is this happening and how to fix this?