Для полноты, теперь есть fct_drop
в пакете forcats
http://forcats.tidyverse.org/reference/fct_drop.html .
Он отличается от droplevels
тем, как он имеет дело с NA
:
f <- factor(c("a", "b", NA), exclude = NULL)
droplevels(f)
# [1] a b
# Levels: a b
forcats::fct_drop(f)
# [1] a b
# Levels: a b
попробуй что-то вроде этого, выглядя глупым, но сработавшим
def getcoor(img,color):
indxs,_=np.where(img==color)
return [indxs[i] for i in range(len(indxs)-2) if indxs[i]==indxs[i+1] and indxs[i+1]==indxs[i+2]]