Skip to content

Merging records based on a field #559

Answered by aborruso
masgo asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @masgo , running

mlr --csv label @ then \
reshape -r "[^@]" -o i,v then \
filter -x -S '$v==""' then \
most-frequent -f @,i,v  then \
stats1 -a max -f count -g @,i -s  input.csv | mlr --csv sort -f @,i -nr count_max then \
head -n 1 -g @,i  then \
cut -x -f count,count_max then \
reshape -s i,v then label key

you will have

key,value1,value2,value3
x,4,2,3
y,10,11,15

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@aborruso
Comment options

@masgo
Comment options

@aborruso
Comment options

@aborruso
Comment options

@masgo
Comment options

Answer selected by masgo
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