Return a new :class:`PseudoTable` with pseudos sorted by Z
779444
def sort_by_z(self):
        """"""
        return self.__class__(sorted(self, key=lambda p: p.Z))
1144376
def preprocess(self):
        '''
        
        '''
        self.processed_tables = []
        self.flags_by_table = []
        self.units_by_table = []
        for worksheet, rtable in enumerate(self.raw_tables):
            ptable, flags, units = self.preprocess_worksheet(rtable, worksheet)
            self.processed_tables.append(ptable)
            self.flags_by_table.append(flags)
            self.units_by_table.append(units)

        return self.processed_tables
322195
def build_sort(self, **kwargs):
        '''  '''
        sort = []
        order = kwargs.get('order_by', None)
        if order:
            if type(order) is list:
                order = order[0]
            if order[:1] == '-':
                sort.append((order[1:], -1))
            else:
                sort.append((order, 1))
        return sort
286211
def table(self,x,*args,**kwargs):
        
        reduce_func = kwargs.get('reduce',lambda x: x)
        data = []
        for i,d in enumerate(self.generate(*args)):
            if len(d) > 0:
                data.append(reduce_func(d[x]))
            else:
                data.append(0)
        try:
            return np.reshape(data,[len(self.space(a)) for a in args])
        except:
            return np.reshape(data,[-1]+[len(self.space(a)) for a in args])
1119804
def table_print(classes, table):
    
    classes_len = len(classes)
    table_list = []
    for key in classes:
        table_list.extend(list(table[key].values()))
    table_list.extend(classes)
    table_max_length = max(map(len, map(str, table_list)))
    shift = "%-" + str(7 + table_max_length) + "s"
    result = shift % "Predict" + shift * \
        classes_len % tuple(map(str, classes)) + "\n"
    result = result + "Actual\n"
    classes.sort()
    for key in classes:
        row = [table[key][i] for i in classes]
        result += shift % str(key) + \
            shift * classes_len % tuple(map(str, row)) + "\n\n"
    if classes_len >= CLASS_NUMBER_THRESHOLD:
        result += "\n" + "Warning : " + CLASS_NUMBER_WARNING + "\n"
    return result
358080
public void sortDeclarations(Element el, PseudoElementType pseudo)
    {
        List<Declaration> list = get(el, pseudo);
        if (list != null)
            Collections.sort(list);
    }
264539
def table_output(data):
    ''''''
    if type(data) == DictType:
        data = data.items()
    headings = [ item[0] for item in data ]
    rows = [ item[1] for item in data ]
    columns = zip(*rows)
    if len(columns):
        widths = [ max([ len(str(y)) for y in row ]) for row in rows ]
    else:
        widths = [ 0 for c in headings ]
    for c, heading in enumerate(headings):
        widths[c] = max(widths[c], len(heading))
    column_count = range(len(rows))
    table = [ ' '.join([ headings[c].ljust(widths[c]) for c in column_count ]) ]
    table.append(' '.join([ '=' * widths[c] for c in column_count ]))
    for column in columns:
        table.append(' '.join([ str(column[c]).ljust(widths[c]) for c in column_count ]))
    return '\n'.join(table)
1175383
def make_geohash_tables(table,listofprecisions,**kwargs):
	'''
	
	'''
	return_squares = False
	sort_by = 'COUNT'
	# logic for accepting kwarg inputs
	for key,value in kwargs.iteritems():
		if key == 'sort_by':
			sort_by = value
		if key == 'return_squares':
			return_squares = value

	# getting header
	header = df2list(table)[0]

	# getting columns
	columns = header[10:]

	# getting original table
	originaltable = table
	if not sort_by == 'COUNT':
		originaltable = originaltable.sort([sort_by],ascending=[0])




	listofprecisions = sorted(listofprecisions,reverse=True)
	# making total table to hold a list of dfs
	if return_squares == True and listofprecisions[-1] == 8:
		total_list = [table]
	elif return_squares == True:
		total_list = []

	for row in listofprecisions:
		precision = int(row)
		table = originaltable
		table['GEOHASH'] = table.GEOHASH.str[:precision]
		table = table[['GEOHASH','COUNT']+columns].groupby(['GEOHASH'],sort=True).sum()
		table = table.sort([sort_by],ascending=[0])
		table = table.reset_index()

		newsquares = [header]
		# iterating through each square here 
		for row in df2list(table)[1:]:
			# getting points
			points = get_points_geohash(row[0])
			
			# making new row
			newrow = [row[0]] + points + row[1:]
			
			# appending to newsquares 
			newsquares.append(newrow)

		# taking newsquares to dataframe
		table = list2df(newsquares)

		if return_squares == True:
			total_list.append(table)
		else:
			table.to_csv('squares' + str(precision) + '.csv',index=False)

	if return_squares == True:
		return total_list
	else:
		print 'Wrote output squares tables to csv files.'
621123
def appendbcolz(table, obj, check_names=True):
    

    import bcolz
    import numpy as np

    if isinstance(obj, string_types):
        ctbl = bcolz.open(obj, mode='a')
    else:
        assert hasattr(obj, 'append') and hasattr(obj, 'names'), \
            'expected rootdir or ctable, found %r' % obj
        ctbl = obj

    # setup
    dtype = ctbl.dtype
    it = iter(table)
    hdr = next(it)
    flds = list(map(text_type, hdr))

    # check names match
    if check_names:
        assert tuple(flds) == tuple(ctbl.names), 'column names do not match'

    # fill chunk-wise
    chunklen = sum(ctbl.cols[name].chunklen
                   for name in ctbl.names) // len(ctbl.names)
    while True:
        data = list(itertools.islice(it, chunklen))
        data = np.array(data, dtype=dtype)
        ctbl.append(data)
        if len(data) < chunklen:
            break

    ctbl.flush()
    return ctbl
160748
def _format_list_objects(result):
    """"""

    all_keys = set()
    for item in result:
        all_keys = all_keys.union(item.keys())

    all_keys = sorted(all_keys)
    table = Table(all_keys)

    for item in result:
        values = []
        for key in all_keys:
            value = iter_to_table(item.get(key))
            values.append(value)

        table.add_row(values)

    return table
757629
def csv_matrix_print(classes, table):
    
    result = ""
    classes.sort()
    for i in classes:
        for j in classes:
            result += str(table[i][j]) + ","
        result = result[:-1] + "\n"
    return result[:-1]
308724
def _with_columns(self, columns):
        """"""
        table = type(self)()
        for label, column in zip(self.labels, columns):
            self._add_column_and_format(table, label, column)
        return table
104019
def sort_by(ascending=true, &block)
      return self.to_enum(:sort_by) unless block_given?
      order = self.map(&block).to_darr.sorted_indices
      order.reverse! unless ascending
      data = @data.map{|darr| darr.sort_by.with_index{|val, i| order.index(i)}}
      index = @index.sort_by.with_index{|val, i| order.index(i)}
      Mikon::DataFrame.new(data, {index: index, labels: @labels})
    end
1048945
def index(self, sort=True):
        """"""
        from casacore.tables import tableindex
        return tableindex(self._table, [self._column], sort)
153462
def sort_by_key(self, keys=None):
        
        keys = keys or self.key_on
        keys = keys if isinstance(keys, (list, tuple)) else [keys]
        for key in reversed(keys):
            reverse, key = (True, key[1:]) if key[0] == '-' else (False, key)
            self.table.sort(key=lambda row: row[key], reverse=reverse)
526586
def pretty_print_table_instance(table):
    """"""
    assert isinstance(table, Table)

    def pretty_print_row(styled, plain):
        """Pretty print a row."""
        click.secho(
            " | ".join(
                v + " " * (table.column_widths[k] - len(plain[k]))
                for k, v in enumerate(styled)
            )
        )

    pretty_print_row(table.headers, table.plain_headers)
    for k, row in enumerate(table.rows):
        pretty_print_row(row, table.plain_rows[k])
100036
def _TableFactory(tag, stream, offset, length):
    
    TableClass = {
        'head': _HeadTable,
        'name': _NameTable,
    }.get(tag, _BaseTable)
    return TableClass(tag, stream, offset, length)