I have a data frame with intervals like:
begin end 2 4 6 8 9 11 I want to compare a value to each of such pair of interval. If that value is in the range of any interval, it will be 'yes', else it will be 'no'.
For example: x = 3 => yes (because 2<x<4), x=5 => no
I currently do this with a nested loop through each value of x and each the interval. But I have multiple values of x and multiple intervals, so the nested loop is really slow. Is there any way I can do this efficiently without a loop? Thank you!
https://stackoverflow.com/questions/67223050/compare-a-value-to-every-pair-of-values-in-a-pandas-dataframe April 23, 2021 at 10:05AM
没有评论:
发表评论