9
是否有更簡單的方法將excel文件直接加載到Numpy數組中?將Excel文件加載到numpy二維數組中
我已經看過numpy文檔中的numpy.genfromtxt
自動加載功能,但它不直接加載excel文件。
array = np.genfromtxt("Stats.xlsx")
ValueError: Some errors were detected !
Line #3 (got 2 columns instead of 1)
Line #5 (got 5 columns instead of 1)
......
現在我用用openpyxl.reader.excel
讀取Excel文件,然後附加到NumPy的二維數組。這似乎是低效的。 理想情況下,我想不得不excel文件直接加載到numpy 2D數組。
我只是補充說,將數據幀轉換爲Numpy 2D數組,您可以使用np.asarray(your_data_frame_here)。 – Tahlor