python删除excel指定行_Python-熊猫删除Excel中的特定行/列

本文介绍了如何使用Pandas在Python中删除Excel文件的指定行(如空行)和首列。通过drop函数,可以有效地清理数据,以便进一步处理。
摘要由CSDN通过智能技术生成

1586010002-jmsa.png

i have the following excel file, and i would like to clean specific rows/columns so that i can further process the file.

HDy2c.png

I have tried this, but i have not managed to remove any of the blank lines, i ve only managed to trim from those containing data. Here, i was trying to only save the data from the third row and on.

xl = pd.ExcelFile("MRD.xlsx")

df = xl.parse("Sheet3")

df2 = df.iloc[3:]

writer4 = pd.ExcelWriter('pandas3.out.no3lines.xlsx', engine='xlsxwriter')

table5 = pd.DataFrame(df2)

table5.to_excel(writer4, sheet_name='Sheet1')

writer4.save()

I specifically want to remove rows 1, 3 (the empty ones) and the first column, so that i can pivo

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值