I have written a python script for Excel automation. I am stuck in between a point during this automation. I want to apply regular Expression in a column of a dataframe. Tried many ways but not able to produce exactly desired result as I wants. I have dataframe like following(short sample example) -
This is sample dataframe and this has large number of columns. I want to apply regular expression in column C named as ID column. I want to split data in this dataframe based upon $, & separator but also wants to ignore(delete) all the values between * and & or * and $. Row where we find empty cell in column C(ID) can be deleted or ignore. Following is example of output dataframe that I want-
I am have tried following-
import pandas as pd
import re
df = pd.read_excel("Deal Id Part Comparison Master File.xlsx", "Data Dump", header=1)
splits= []
for i in df['ID']:
s = str(i)
splits.append(re.split('\$|\&',s))
print(f' final list {splits}')
Above code is able to split data based upon $ and & and storing them in list. But data between * and $ or * and & is not ignored. Also I want to explode the data.
I am sure that there can be one liner to achieve this task but not able to generate final output

