Hello!
I am trying to organise a dataset for a project.
the set in question involves 27 variables, with about 27000 rows, not all of which are populated. All 27 variables are populated in unique indices.
I want to generate a new variable that is a single column with all entries from all 27 variables merged together. Some rows will also end up being unpopulated.
Approach tried:
I have implemented a counting for each variable (eg in variable 1, all data is concentrated from row 1-50, in variable 2 data is concentrated from row 51-300, etc.)
Using cumulative summation I have obtained the start and end index of the data within each variable.
However quickly fails, if data is not concentrated, or if there is discontinuity from one variable to the next (eg no data in no variable from rows 500-600.
I am also unsure of how to about using for loops as the data in each variable doesn't span for the same range.
A brief layout of what I am describing can be seen in the below table
The target variable should look like this:
Thanks in advance
Odysseas
I am trying to organise a dataset for a project.
the set in question involves 27 variables, with about 27000 rows, not all of which are populated. All 27 variables are populated in unique indices.
I want to generate a new variable that is a single column with all entries from all 27 variables merged together. Some rows will also end up being unpopulated.
Approach tried:
I have implemented a counting for each variable (eg in variable 1, all data is concentrated from row 1-50, in variable 2 data is concentrated from row 51-300, etc.)
Using cumulative summation I have obtained the start and end index of the data within each variable.
However quickly fails, if data is not concentrated, or if there is discontinuity from one variable to the next (eg no data in no variable from rows 500-600.
I am also unsure of how to about using for loops as the data in each variable doesn't span for the same range.
A brief layout of what I am describing can be seen in the below table
var1 | var2 | var3 | var4 | var5 |
left | . | . | . | . |
left | . | . | . | . |
right | . | . | . | . |
other | . | . | . | . |
left | . | . | . | . |
. | right | . | . | . |
. | left | . | . | . |
. | other | . | . | . |
. | right | . | . | . |
. | left | . | . | . |
. | left | . | . | . |
. | . | right | . | . |
. | . | left | . | . |
. | . | left | . | . |
. | . | other | . | . |
. | . | right | . | . |
. | . | . | . | . |
. | . | . | . | . |
. | . | . | right | . |
. | . | . | other | . |
. | . | . | left | . |
. | . | . | left | . |
. | . | . | center | . |
. | . | . | right | . |
. | . | . | other | . |
. | . | . | . | left |
. | . | . | . | other |
. | . | . | . | right |
. | . | . | . | other |
The target variable should look like this:
Target |
left |
left |
right |
other |
left |
right |
left |
other |
right |
left |
left |
right |
left |
left |
other |
right |
. |
. |
right |
other |
left |
left |
center |
right |
other |
left |
other |
right |
other |
Odysseas
Comment