0

I have a xlsx database with translations for different words. I have a simple for loop going through a list of pre-added phrases. Each word on the list matches the first column of the database. The loop goes over the whole first column and whenever a word from the list matches a word in the cell of the database - whole row is appended to a list.

The issue I'm having is that every time a row is appended to the list it comes with the Headers and indexes. Anyone knows how get that removed?

import pandas as pd

excel_file = 'C:/Users/user/Desktop/Translation.xlsx'
file = pd.read_excel(excel_file)

compList = ['Hi', 'Hello', 'Bye']
newComp = []
length = len(compList)
for i in range(length):
    newComp.append(file.loc[file['English'] == compList[i]])
print(newComp)

Result I'm getting is:

 English French German Spanish Italian

0 HiEng    HiFre  HiGer  HiSpa  HiIta,  English French German Spanish Italian

1 HelloEng  HelloFre  HelloSpa  HelloIta, English French German Spanish Italian

2 ByeEng ByeFre ByeSpa ByeIta, English French German Spanish Italian
Massifox
  • 4,369
  • 11
  • 31
babis95
  • 582
  • 6
  • 29

0 Answers0