Quantipy / quantipy

Python for people data
MIT License
66 stars 14 forks source link

Split delimited set into N-mentions+others #1297

Closed jamesrkg closed 5 years ago

jamesrkg commented 5 years ago

Assuming data in a delimited set variable, where we know the response data is ordered, such as:

6;56;3;40;22;21;36;1;12;43;11;18;15;17;27;25;48;57;55;62;

It would be good to be able split the variable into N+1 new variables where N is the number of single-response mentions from the first, with all mentions beyond N ending up in a delimited set with all other responses.

This will let us transform ordered delimited set data into first/second/third/etc. mentions + other mentions.

alextanski commented 5 years ago

signature will be: nfirst(ds, name, n_first=3, others='others', reduce_values=False)

alextanski commented 5 years ago

Docstring not yet in, therefore parameters:

alextanski commented 5 years ago

Hell, I simply fixed the variable labels quickly.

alextanski commented 5 years ago

Clean-up needed, code has some smaller redundancies.

alextanski commented 5 years ago

Docstring still needed.

alextanski commented 5 years ago

all done. closed.