简体   繁体   English

Excel行号怎么去掉?

[英]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.因此,我必须使用 pandas 对 Excel 文件中的某些行进行排序,将它们保存到文本文件并在单页网站上显示。 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在网站上,前 5 个根据需要显示,但行数在数据前面,如下所示:数据前面的行数

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您可以尝试添加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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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