I have a dataframe like this:
item_A item_B item_C
x z y
z x y
y x z
z y x
where all values are a string and I only know the value of x and y but i need to get the value of z. The problem is that z is not always in the same column. I want to add a column only with the value of z. I tried concatenating the columns and extract the others strings that I know but I don't know how to keep z (with a main_pattern = r'x|y' ?)
Here is what I tried but isn't working
pattern_full = r'(('+ main_pattern+'),)'
df = df.withColumn("vale_z", regexp_extract("columns_concatenated", pattern_full, 1)