一,轴的概念
可根据数组的shape属性返回的元组长度判断为几维数组
一维数组: o轴(个数)
二维数组: o轴(行),1轴(列)
三维数组: o轴(块),1轴(行),2轴(列)
二,numpy读取数组
(一般不用,一般使用pandas从数据库、剪切板中读取)
import numpy as np
file_dir = './number.csv'
# file_dir表示文件位置;delimiter表示数据之间的间隔符;dtype表示数据类型;
# unpack表示转置 按列数逐行的读取数据;
t1 = np.loadtxt(file_dir,delimiter=',',dtype='int',unpack=True)
t2 = np.loadtxt(file_dir,delimiter=',',dtype='int')
print(t1)
print('-'*50)
print(t2)
三,具体参数介绍


本文深入解析NumPy数组的轴概念,包括一维、二维和三维数组的轴标识,以及如何使用NumPy从CSV文件中读取数据的具体参数配置。了解不同轴在数组中的作用,掌握np.loadtxt函数的使用技巧。
501

被折叠的 条评论
为什么被折叠?



