我同意上述内容,因为诀窍是使用熊猫。下面的示例显示了一个excel文件的创建,每个数组都在不同的工作表中。
import numpy as np import pandas as pd # create two 1 D arrays A1d1 = np.full((5),fill_value=1) B1d2 = np.full((5),fill_value=2) # create one 2 D array C2d3 = np.full((5,5),fill_value=3) # convert to pandas DataFrames A1d1_df = pd.DataFrame(A1d1) B1d2_df = pd.DataFrame(B1d2) C2d3_df = pd.DataFrame(C2d3) # Use pandas Excel Writer to create one Excel file with # a sheet for each array with pd.ExcelWriter('yourexcelfile.xlsx') as writer: A1d1_df.to_excel(writer, sheet_name='A1d1') B1d2_df.to_excel(writer, sheet_name='B1d2') C2d3_df.to_excel(writer, sheet_name='C2d3')
一种解决方案可能是使用pandas包然后创建CSV。
dataframe_array= pandas.dataframe(your_array) dataframe_array.to_csv(your_path)
然后只需在excel中查看csv