I am trying the create a new column in Pandas. I have an existing column of text and I want this new column to contain the value contained in another column where the row value partially matches the column name. It's similar to this thread but in my case I would only have a partial match:
Python: pandas: match row value to column name/ key's value
My table would look like this as an example
Field UKA_rf4 UKB UKDdsdf
UKA 1 4 54
UKB 2 5 7787
UKD 97 54 765656
And what I would like it to look like is:
Field UKA_rf4 UKB UKDdsdf Value
UKA 1 4 54 1
UKB 2 5 7787 5
UKD 97 54 765656 765656
The first row results in a 1 because 'UKA' is contained in the column name 'UKA_rf4'
The second row matches exactly to a column name and the third column is a partial match.
Any suggestions?