I have a dataframe with the following columns and corresponding values (forgive my formatting but dont know how to put it in table format):
Src_ip dst_ip V1 V2 V3 top
"A" "B" xx yy zz "V1"
Now I want to add a column, lets say top_value
which takes the value of column corresponding to the string in V1.
Src_ip dst_ip V1 V2 V3 top top_value
"A" "B" xx yy zz "V1" xx
So basically, get the value corresponding to the value in the column "top" and make a new column named "top_value"
I have tried by creating UDFs as well as using the string as an alias but unable to do so. Can anyone please help.