1、数组的形状
t8=np.array([random.random() for i in range(10)])
print(“t8=”,t8)
t9=np.round(t8,2)
print(“t9=”,t9)
m5=np.arange(12)
print(“m5=”,m5)
print(m5.shape)
t5=m5.reshape((12,1))
print(t5)
t6=m5.flatten()
print(“t6=”,t6)
2、数组的计算
若相同位置,相应计算(广播机制);若有一维度相同,另一都计算
t7=m5.reshape(3,4)
print(“t7=”,t7)
t8=t7/2
print(“t8=”,t8)
3、numpy读取数据
np.loadtxt(frame,dtype=np.float,delimiter=none,skiprows=0,usecols=none,unpack=false)
代码如下:
import numpy as np
us_file_path="./youtube_video_data/US_video_number.csv"
uk_file_path="./youtube_video_data/GB_video_data_number.csv"
t1=np.loadtxt(us_file_path,delimiter=",",dtype=“int”,unpack=True)
t2=np.loadtxt(us_file_path,delimiter=",",