找回密碼
 註冊
搜索
查看: 529|回復: 0

[教學] Pandas 讀取TXT後,用 iloc ˊ只抓取某行的數值(字串)

[複製鏈接]
發表於 2024-10-14 22:35:57 | 顯示全部樓層 |閱讀模式
 
Push to Facebook
  1. import pandas as pd
  2. # 給表頭標籤
  3. header = ['Device','Phase','Data','Description','Cmd.Phase']
  4. # 讀取檔案成dataframe
  5. df = pd.read_fwf("xxx.txt")

  6. # print(type(df))
  7. # print(df)
  8. # print(df.iloc[:,1:7])
  9. # 從dataframe取DATA那行
  10. first_col_cut=df.iloc[:,1:7]
  11. #print(type(first_col_cut))

複製代碼


 
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Archiver|手機版|小黑屋|TShopping

GMT+8, 2025-6-16 02:54 , Processed in 0.023779 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回復 返回頂部 返回列表