I have a Python Pandas dataframe with a column named "codes". This column is very messy and contains the following values:
codes output 1234A, C (1AAA1), D, E 1234A 1234C 1234D 1234E 34240 & 1 & 3 34240 34241 34243 PS1A;D;E PS1A PS1D PS1E CE11A, C & 2452D CE11A CD11C 2352D EOPSDCE11A, C & 2452D EOPSDCE11A EOPSDCD11C 2352D
Basically, what we need is to complete the single letter/number (i.e. C) with the full code excluding the last char (i.e. 1234 in the first line), remove the phrase in the parenthesis, keep the code if it's a full code (length between 2-10), and use space as delimiter.
I have tried to use str.replace but was not able to manage to write the regex correctly.
Thanks for the help in advance!