使用pandas.DataFrame.to_excel(r “路徑\檔名.xlsx”)
輸出的excel檔會含有0,1,2,3…的index跟欄標籤:

如果將該excel檔用read_excel() 讀進來後
dfHVT = pd.read_excel(r”C:\radome\base\dfHVT.xlsx”)

原本index的那一欄多了出來
欄標籤為: “Unnamed: 0”
如何去除該欄?
dfHVT1 = dfHVT.drop( “Unnamed: 0”, axis = 1)
該欄的欄標籤就是 “Unnamed: 0”
不要懷疑
axis = 1表示刪除直欄
axis = 0則會刪除橫列

推薦hahow線上學習python: https://igrape.net/30afN







![Python:如何用pandas.concat() 合併兩個DataFrame並重置index? pd.concat([df1, df2]) .reset_index(drop=True) ; pd.concat([df1, df2], ignore_index=True) Python:如何用pandas.concat() 合併兩個DataFrame並重置index? pd.concat([df1, df2]) .reset_index(drop=True) ; pd.concat([df1, df2], ignore_index=True)](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2023/03/20230311123232_5.png?quality=90&zoom=2&ssl=1&resize=350%2C233)


近期留言