How to get index of a word in the list and can we extract the value based on index?
Hi All!
My dataset has six columns. All columns are in the list format.
first column(list) has common words which are present in 2nd(ch_1) and 3rd(ch_2) columns. The respective values are present in 4th(va_1) and 5th(va_2) columns. So, I need to loop over the each word present in "list" column and extract the index of that particular in ch_1& ch_2 and get the respective values in va_1&va_2. After getting va_1 and va_2, I have to compare if va_1 not equal to va_2 flag "mis" value becomes "1" else "0".
Source:
list ch_1 ch_2 va_1 va_2
typ,shap typ,shap,fgh typ,fgi,shap 8,"ghk",90 8,97, "oki"
----here typ,shap are common words in ch_1&ch_2 and their respective indexes are (0,1)in ch_1 and (0,2) in ch_2. so, I need values from va_1&va_2 based on indexes. As (0,1) in ch_1, need to extract (0,1) values from va_1 and in the same way (0,2) are indexes of ch_2, need to get values of (0,2) from va_2.
Required output:
list ch_1 ch_2 va_1 va_2 mis
typ,shap typ,shap,fgh typ,fgi,shap 8,"ghk",90 8,97, "oki" 1
----"mis" value is "1" because for the "typ"----va_1=8 and va_2=8 matched in the case.
But for the "shap"----va_1="ghk" and va_2="oki", here the values are mismatched. so, If one value is mismatched, then the flag should be "1".
Can anyone help me?
Thanks in Advance!