xlrd读入矩阵,转化为numpy.array
import xlrd
import numpy as np
def exceltondarray(path):#输入路径
data = xlrd.open_workbook(path)
table = data.sheets()[0]#打开表格第1一个页面
nrows = table.nrows # 行数
ncols = table.ncols # 列数
datamatrix = np.zeros((nrows, ncols))#生成行数*列数的数组
for i in range(ncols):#遍历每列数据
cols = table.col_values(i)#将列数据读入
datamatrix[:, i] = cols #将列数据赋值给ndarray
return datamatrix #返回数组
pathX = '113.xlsx' # 113.xlsx 在当前文件夹下
x = excel2matrix(pathX)
print(x)
print(x.shape)