writing a function that should meet a condition on a row basis and return the expected results
def bt_quantity(df):
    df = bt_level(df)
    df['Marker_change'] = df['Marker'] - df['Marker'].shift(1).fillna(0).round(0).astype(int)
    df['Action'] = np.where(df['Marker_change'] > 0, "BUY", "")
    def turtle_split(row):
        if df['Action'] == 'Buy':
            return baseQ * (turtle ** row['Marker'] - 1) // (turtle - 1)
        else:
            return 0
    df['Traded_q'] = df.apply(turtle_split, axis=1).round(0).astype(int)
    df['Net_q'] = df['Traded_q'].cumsum().round(0).astype(int)
    print(df.head(39))
    return df
This is a common issue, and I am not using any "and" or "or" in the code. still getting the below error
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
I tried changing str to int(BUY >> 1), no progress. P.S. the data set is huge and I am using multiple modules and functions to work on this project.
 
    