使用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.to_numeric ( df[‘numbers’], errors=’coerce’) 將非數值型資料轉為NaN? df[‘numbers’].describe() 簡述統計資料 Python: 如何使用pandas.to_numeric ( df[‘numbers’], errors=’coerce’) 將非數值型資料轉為NaN? df[‘numbers’].describe() 簡述統計資料](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2024/05/20240501052102_0.png?quality=90&zoom=2&ssl=1&resize=350%2C233)



![Python: 如何判斷字符串內容是否為數字(整數或浮點數)? isinstance( eval( entry.get() ), (float, int) ) ; str.isdigit() #不包括小數點和負號 ; try~ except ValueError~ ; 正則表示法 regular expression ; pattern = ‘^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$’ Python: 如何判斷字符串內容是否為數字(整數或浮點數)? isinstance( eval( entry.get() ), (float, int) ) ; str.isdigit() #不包括小數點和負號 ; try~ except ValueError~ ; 正則表示法 regular expression ; pattern = ‘^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$’](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2023/05/20230512152430_3.png?quality=90&zoom=2&ssl=1&resize=350%2C233)



近期留言