import numpy as np import pandas as pd
a = np.array(3)
a = np.array([3, 15])
array = np.array([[1, 2, 3], [1, 2, 3]]) print("输出数组") print(array)
print("输出维数", array.ndim)
print("矩阵的行列值:", array.shape)
print("输出矩阵的元素个数:", array.size)
array = np.array([1, 2, 3]) print("创建数组:", array)
array = np.array([1, 2, 3], dtype=np.int64) print(array, "数组元素数据类型为", array.dtype)
array = np.array([1, 2, 3], dtype=np.int32) print(array, "数组元素数据类型为", array.dtype)
array = np.array([1, 2, 3], dtype=np.float64) print(array, "数组元素数据类型为", array.dtype)
array = np.array([1, 2, 3], dtype=np.float32) print(array, "数组元素数据类型为", array.dtype)
a = np.array([[2, 3, 4], [5, 6, 7]]) print(a)
a = np.zeros((3, 4)) print(a)
a = np.ones((3, 4)) print(a)
b = np.empty((3, 4)) print(b)
a = np.arange(10, 20, 2) print(a)
a = np.arange(12).reshape((3, 4)) print(a)
a = np.linspace(1, 10, 20) print(a)
a = np.linspace(1, 10, 20).reshape(3, 4) print(a)
|