看板 Python 關於我們 聯絡資訊
df=pd.read_excel('Homework7.xlsx',sheet_name=[0],index_col=0) 讀取進來之後 a=df[0].values 轉成矩陣 [[-10. 0.01338601] [ -9.98 0.01365458] [ -9.96 0.0139285 ] 變成矩陣之後,可是我想要分割成兩個矩陣 但是是要 a=[[-10][-9.98]......] b=[[0.0133][0.01365458]......] 一般分割好像不能變成上面那樣 請問有什麼方法可以做到嗎 謝謝各位大大 ----- Sent from JPTT on my iPhone -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 39.13.69.64 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1565087827.A.CF5.html ※ 編輯: canon760d (39.13.69.64 臺灣), 08/06/2019 18:39:47
tsaiminghan: 我沒用過pandas, 但是這個看起來自行轉好像滿容易的? 08/06 20:42
tsaiminghan: 我指寫code去轉,看起來不難。 08/06 20:43
iphone2003: a[:,[0]]和a[:,[1]]就可以了 08/06 21:13
canon760d: 謝謝樓上大大回答 不過我是想要分成a,b兩個的話有辦法 08/06 22:58
canon760d: 嗎 08/06 22:58
iphone2003: b=a[:,[1]] a=a[:[0]] 這樣吧 08/07 01:41
iphone2003: a=a[:,[0]]才對 剛剛忘了加逗號 08/07 01:42
ichere: 可以試試a.index.values把第一行提取出來 08/07 03:45
sherees: iphone大正解 08/07 12:52