|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
非常感谢你在百忙之中抽空为我解答。
以下是两列和三列单元格中随机抽取N个单元格的算法,如果要在四列,五列中随机抽取N个单元格该怎么改?
def check(sample,data2,index,around): #在两列中抽取
res=[]
for i in sample:
if around!=-1:
temp=[j for j in data2 if i[index[0]]==j[index[0]] and abs(i[index[1]]-j[index[1]])<=around]
else:
temp=[j for j in data2 if i[index[0]]==j[index[0]] and i[index[1]]==j[index[1]]]
if len(temp):
res.append(temp[0])
else:
break
else:
return(res)
return([])
def check(sample,data2,index,around): #在三列中抽取
res=[]
for i in sample:
if around!=-1:
temp=[j for j in data2 if i[index[0]]==j[index[0]] and i[index[1]]==j[index[1]] and abs(i[index[2]]-j[index[2]])<=around]
else:
temp=[j for j in data2 if i[index[0]]==j[index[0]] and i[index[1]]==j[index[1]] and i[index[2]]==j[index[2]]]
if len(temp):
res.append(temp[0])
else:
break
else:
return(res)
return([])
以下是四列和五列:
def check(sample,data2,index,around): #在四列中抽取
def check(sample,data2,index,around): #在五列中抽取
|
|