Skip to content

How to calculate a windowed rank function? #2280

Answered by midichef
daviewales asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, yes, you can do this with Visidata. It took me a while to remember how. I did it with your method: mark the start of the group. The other key steps are:

  1. Get the row number, using i (addcol-incr). Rename that column to i: ^ i
  2. Let each row see the row number of the start of its group:
    a) Make a window with addcol-window to use the value of the previous row and the value on the current row: w 1 0
    b) Then, make an expression coumn that will be called first. The expression to use has changed as of September 4, 2024.
    For older visidata versions than that, like visidata <= 3.0.2:
    i) Make an expression column which will be called first: = w[0] != w[1] if len(w) == 2 else True and rename it: ^

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@daviewales
Comment options

Answer selected by daviewales
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants