Я хочу установить значение в DataFrame в зависимости от некоторых других столбцов.
Т.е.:< /p>
Код: Выделить всё
(Pdb) df = pd.DataFrame([['cow'], ['dog'], ['trout'], ['salmon']], columns=["animal"])
(Pdb) df
animal
0 cow
1 dog
2 trout
3 salmon
(Pdb) df["animal"] = np.select(df["animal"] == "dog", "canine", "not-canine")
Код: Выделить всё
*** ValueError: list of cases must be same length as list of conditions
(Pdb)
Подробнее здесь: https://stackoverflow.com/questions/791 ... -np-select
Мобильная версия