python-numpy基础学习
import numpy as np list = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]] df = np.array(list) print(df) df[:,1:3] #取第二列和第三列 df[:,[1,3]] #取第二列和第四列 df[df<10] = 0 #小于等于10的数替换为0 df[df>10] = 20 #大于10的数替换为2 t = np.where(df<=10,0,20) #(条件,满足条件的替换值,不满足条件的替换值) print(t) df[np.isnan(df)] = 888 #修改nan为888 print(df.dtype) #float64 print(np.nan == np.nan) #false print(np.count_nonzero(df!=df)) #统计nan个数