def set_partition(df, index, divisions, max_branch=32, drop=True, shuffle=None, compute=None):
 if np.isscalar(index):
  partitions = df[index].map_partitions(set_partitions_pre, divisions=divisions, meta=pd.Series([0]))
  df2 = df.assign(_partitions=partitions)
 else:
  partitions = index.map_partitions(set_partitions_pre, divisions=divisions, meta=pd.Series([0]))
  df2 = df.assign(_partitions=partitions, _index=index)
 df3 = rearrange_by_column(df2, '_partitions', max_branch=max_branch, npartitions=(len(divisions) - 1), shuffle=shuffle, compute=compute)
 if np.isscalar(index):
  df4 = df3.map_partitions(set_index_post_scalar, index_name=index, drop=drop, column_dtype=df.columns.dtype)
 else:
  df4 = df3.map_partitions(set_index_post_series, index_name=index.name, drop=drop, column_dtype=df.columns.dtype)
 df4.divisions = divisions
 return df4.map_partitions(M.sort_index)

def set_partition ( df , index , divisions , max_branch = 32 , drop = True , shuffle = None , compute = None ) : if np . isscalar ( index ) : partitions = df [ index ] . map_partitions ( set_partitions_pre , divisions = divisions , meta = pd . Series ( [ 0 ] ) ) df2 = df . assign ( _partitions = partitions ) else : partitions = index . map_partitions ( set_partitions_pre , divisions = divisions , meta = pd . Series ( [ 0 ] ) ) df2 = df . assign ( _partitions = partitions , _index = index ) df3 = rearrange_by_column ( df2 , '_partitions' , max_branch = max_branch , npartitions = ( len ( divisions ) - 1 ) , shuffle = shuffle , compute = compute ) if np . isscalar ( index ) : df4 = df3 . map_partitions ( set_index_post_scalar , index_name = index , drop = drop , column_dtype = df . columns . dtype ) else : df4 = df3 . map_partitions ( set_index_post_series , index_name = index . name , drop = drop , column_dtype = df . columns . dtype ) df4 . divisions = divisions return df4 . map_partitions ( M . sort_index )
extract a partition from a list of tuples this should be correctly called select largest disjoint sets .