凤凰求蛊
考虑到以下作为输入数据帧,我已经执行了操作。 name val0 a 11 * 22 b NaN3 d 14 g ?5 t 36 h 4import numpy as npimport pandas as pdf=pd.read_csv('data_file.csv')f=pd.DataFrame(f)#the below loop will provide you with the location of null values. i.e. "NaN"for i,j in zip(*np.where(pd.isnull(f))): print("{},{}".format(i,j))o/p: 2,1#similarly finding location of '*' and '?'special=['*','?']for k in special: print(np.where(f.applymap(lambda x: x == k)),'location for ',k)o/p: (array([1], dtype=int64), array([0], dtype=int64)) location for *(array([4], dtype=int64), array([1], dtype=int64)) location for ?eg:i/n: f.iloc[1,0]o/p: '*'