Hey everyone.
I need help some data wrangling techniques.
Thanks in advance for your help.
Yoyong
I have a dataset with two columns. I want to compare the two columns to get the additional columns found in Table 2.
Matched_type: 0 = columns did not match, 1 = columns have exact match; 2 = columns have partial match
Matched_response = lists all the matched responses in one column
Matched1, Matched2,...Matchedn = separates the matched responses in different columns
Table 1
Column 1 | Column 2 |
---|---|
a | a |
b | b;d |
c | f |
d;e | e;d |
c;d | d |
a;b | a;e;c |
a;c;e | f;a |
b;c | d |
f | f;g;a |
g;h | g;h |
c;a;b;d | a;d;c;e |
a;f;c;d;e;g | f;a;d;e;h;j |
Table 2
Column 1 | Column 2 | Matched_type | Matched_response | Matched1 | Matched2 | Matched3 | Matched4 |
---|---|---|---|---|---|---|---|
a | a | 1 | a | a | |||
b | b;d | 2 | b | b | |||
c | f | 0 | |||||
d;e | e;d | 1 | d;e | d | e | ||
c;d | d | 2 | d;e | d | |||
a;b | a;e;c | 2 | a | a | |||
a;c;e | f;a | 2 | a | a | |||
b;c | d | 0 | |||||
f | f;g;a | 2 | f | f | |||
g;h | g;h | 1 | g;h | g | h | ||
c;a;b;d | a;d;c;e | 2 | c;a | c | a | ||
a;f;c;d;e;g | f;a;d;e;h;j | 2 | a;f;d;e | a | f | d | e |