简体   繁体   中英

How to remove the number of the Excel row?

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

Can you try by adding index_col=None

Replace your first line

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM