I have one xlsx file and the data contain like this :
I have to remove the "Magna" key" fom the below excel.
My code is :
data = pd.read_excel("abc.xlsx")
data1 = data.replace(np.nan, '', regex=True) #replace NaN with ""
data1.columns = data1.columns.str.replace('Unnamed.*', '') #Removing unNamed
for j in userInputForRemove: #["magna"]
if j in allElementInExcel: #["contail all elements in xlsx"]
pattern = re.compile(r'\b'+j+r'\b', flags=re.IGNORECASE)
data1 = data1.replace(pattern, "", regex=True)
data1.to_excel(i, index=False)
But after delete "magna" keyWord, i am getting below input.
But i want to delete all "magna" keyword. Can anyone help me out.