0

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.

enter image description here

But i want to delete all "magna" keyword. Can anyone help me out.

Anuj
  • 119
  • 8

1 Answers1

0

You can use the skiprows:

data = pd.read_csv('path-to-csv.csv', skiprows=1)
DirtyBit
  • 16,613
  • 4
  • 34
  • 55