'Numpy array mask using values from successive rows, in one line
I'd like to make a numpy mask to select only rows from an array where a value from one column in a row is equal to the value in the same column from the next row.
Yes, the mask is easy to do with a for loop, but I'd like to know if there's some on-line python syntax I can use, the idea being something like this:
data=SomeNumpyArray
filtered=data[(data[thisRowAndColumn] == data[nextRowAndSameColumn])]
This seems like the sort of thing that can probably be done with numpy in one line. Copy the array but shift it up and make the comparison, or something?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
