![](/img/trans.png)
[英]Need to delete complete blank rows and columns by python script from xlsx file which is having multiple sheets
[英]Delete single column from multiple xlsx sheets using python
誰能知道如何使用python從多個xlsx工作表中刪除相同的單列?
之后,這些工作表將其保存到相同的路徑。
首先,您應該使用 Excel 工作簿創建一個列表,並將其保存在名為“files”的變量中:
dfs = []
for file in files:
df = pd.read_excel(file, sheet_name = None)
dfs.append(df)
col_to_delete = ['Your columns']
for df in dfs:
#Here you delete one by one
df.drop(labels = col_to_delete, inplace = True)
之后,我不知道你是要合並所有的 .xlsx 還是覆蓋,但這是另一個問題,查看 pd.Write() 的文檔以保存文件
希望能幫助到你
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.