Home > Enterprise >  How to remove the number of the Excel row?
How to remove the number of the Excel row?

Time:07-04

So I have to sort certain rows from an Excel file with pandas, save them to a text file and show them on a single page website. This is my code:

dataTopDivision = pd.read_excel("files/Volleybal_Topdivisie_tussenstand.xlsx")
dataTopDivision1 = dataTopDivision[['datum', 'team1', 'team2', 'uitslag', 'scheidsrechter', 'overtredingen']]

data_sorted = dataTopDivision1.sort_values("overtredingen", ascending=False)
top5 = data_sorted.head(5)
blackbook = open("files/examples/zwartboek.txt", "w", encoding="UTF-8")
blackbook.write(bamboo.prettify(top5))
blackbook.close()

On the website the top 5 shows up as desired, but the numbers of the rows are in front of the data like this: numbers of row in front of data

How would I go about removing these numbers? I hope this is clear, I haven't got a lot of experience with this. Many thanks!

CodePudding user response:

Can you try by adding index_col=None

Replace your first line

dataTopDivision = pd.read_excel("files/Volleybal_Topdivisie_tussenstand.xlsx",index_col=None)

CodePudding user response:

It is the index column. If you want to reset it so if gives a reasonable index, you have to reset the index


top5= top5.reset_index(drop=True)

  • Related