Is there any easy way in python to accomplish what the match function does in R?
what match in R does is that it returns a vector of the positions of (first) matches of its first argument in its second.
For example, the following R snippet.
> a <- c(5,4,3,2,1)
> b <- c(2,3)
> match(a,b)
[1] NA NA 2 1 NA
Translate that in python, what I am looking for is a function that does the following
>>> a = [5,4,3,2,1]
>>> b = [2,3]
>>> match(a,b)
[None, None, 2, 1, None]
Thank you!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…