使用Pandas删除指定行之后的所有行

使用Pandas删除指定行之后的所有行

问题

img

删除['汇总信息']行及之后所有行

1.如图所示,本表格存在1、2两个部分的表格。

2.1、2部分中行数不确定,也就是单纯定位索引的方式无法确定位置。

希望使用Python pandas删除['汇总信息']行及之后所有行。


df=pd.read_excel(r'e:\1.xlsx')
for index,row in df.iterrows():
    if row[0]=='汇总信息':
        print(index)
        dd=df.drop(index=df.index[index:])
        break