Notebook
groups=pd.read_csv('/data/eolson/results/MEOPAR/clusterGroups/cluster_consolidated.csv') cset0=set([(ii,jj) for ii,jj in groups.loc[:,['I','j']].values]) pdlist=list() cset1=set() for i,row in groups.iterrows(): for ii in range(-5,5): for jj in range(-5,5): if not (row['I']+ii,row['j']+jj) in cset0|cset1: pdlist.append((row['I']+ii,row['j']+jj,row['Cluster_ID'])) cset1.add((row['I']+ii,row['j']+jj)) newpd=pd.DataFrame(columns=['I', 'j', 'Cluster_ID'],data=pdlist) data2=pd.merge(data,pd.concat((newpd,groups)),how='inner',left_on=['i','j'],right_on=['I','j'])