df = pd.read_csv('data/eurusd_dukascopy.csv')
df.columns = ['timestamp', 'open', 'high', 'low', 'close', 'volume']
df['oc'] = df.close - df.open
df['uptail'] = df['oc'].apply(lambda x: (df.high - df.close) if x >= 0 else (df.high - df.open))
Gives an error: ValueError: Wrong number of items passed 2963, placement implies 1
I just want to do the following: if df.oc is a positive number, then df.uptail = (df.high - df.close) ...else df.uptail = (df.high - df.open)
How can I crank this out?
np.wherebut it's not clear exactly how it works for your example.