I have created a function as below. This function takes series (a column in dataframe) as parameter and if column values is greater than zero calculates a score (1+column value) else 1/(1-column value).
def znm_score(return_series: pd.Series):
if (return_series > 0):
m_score = 1 + return_series
else:
m_score = 1/(1-return_series)
return pd.DataFrame({
"M-Score": m_score
})
when I call this function
znm_score(restaurants_df["z_score"])
restaurants_df.head()
Error:
"The truth value of a Series is ambiguous.
Use a.empty, a.bool(), a.item(), a.any() or a.all()."