When running the line
conditions = [
(df['a']>=4 & df['a']<=7),
(df['a']>=8 & df['a']<=15)
]
The compiler return
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
May I know why this happen?
import pandas as pd
import numpy as np
df=pd.DataFrame([1,3,6,2,4,10,4,5,15],columns=['a'])
conditions = [
(df['a']>=4 & df['a']<=7),
(df['a']>=8 & df['a']<=15)
]
#
choices = [1,2]
#
df['points'] = np.select(conditions, choices, default=0)