I am trying to create a new column Trend by writing this code
df_cal['Trend'] = np.where((df_cal['75% Quantile'] > df_cal['Shift 75% Quantile']) & (df_cal['25% Quantile'] > df_cal['Shift 25% Quantile']), "Up",
np.where(df_cal['75% Quantile'] < df_cal['Shift 75% Quantile']) & (df_cal['25% Quantile'] < df_cal['Shift 25% Quantile']), "Down","Flat")
However when I run the code it give me this error
ValueError: setting an array element with a sequence.
Is there anyway to solve this?
A sample of the table is shown below.
DateTime 75% Quantile 25% Quantile Shift 75% Quantile Shift 25% Quantile
0 2020-12-18 15:00 2.0 -4.0 NaN NaN
1 2020-12-18 16:00 4.0 -4.0 2.0 -4.0
2 2020-12-18 17:00 -4.0 -10.0 4.0 -4.0
3 2020-12-18 18:00 8.0 8.0 -4.0 -10.0
4 2020-12-18 19:00 0.0 -4.0 8.0 8.0
5 2020-12-18 20:00 0.0 0.0 0.0 -4.0
6 2020-12-19 08:00 8.0 8.0 0.0 0.0
7 2020-12-19 09:00 -2.0 -6.0 8.0 8.0
8 2020-12-19 10:00 4.0 -8.0 -2.0 -6.0
9 2020-12-19 11:00 0.0 -4.0 4.0 -8.0
10 2020-12-19 12:00 4.0 -4.0 0.0 -4.0