Applying regex to pandas column based on different pos of same character
8
I have a dataframe like as shown below tdf = pd.DataFrame({'text_1':['value: 1.25MG - OM - PO/TUBE - ashaf', 'value:2.5 MG - OM - PO/TUBE -test','value: 18 UNITS(S)','value: 850 MG - TDS AFTER FOOD - SC (SUBCUTANEOUS) -had', 'value: 75 MG - OM - PO/TUBE']}) I would like to apply regex and create two columns based on rules given below col val should store all text after value: and before first hyphen col Adm should store all text after third hyphen I tried the below but it doesn't work accurately tdf['text_1'].str.findall('[.0-9]+\s*[mgMG/lLcCUNIT]+')
python regex pandas string dataframe
...