def info(self, buffer=sys.stdout): """ Concise summary of a DataMatrix, used in __repr__ when very large. """ print >> buffer, 'Index: %s entries' % len(self.index), if len(self.index) > 0: print >> buffer, ', %s to %s' % (self.index[0], self.index[-1]) else: print >> buffer, '' if len(self.columns) == 0: print >> buffer, 'DataMatrix is empty!' print >> buffer, repr(self.index) return print >> buffer, 'Data columns:' space = max([len(str(k)) for k in self.cols()]) + 4 counts = self.count() cols = self.cols() assert (len(cols) == len(counts)) columns = [] for col, count in counts.iteritems(): columns.append('%s%d non-null values' % (common._pfixed(col, space), count)) dtypeLine = '' nf = len(self.columns) df = self.values.dtype if self.objects is not None: no = len(self.objects.columns) do = self.objects.values.dtype dtypeLine = '\ndtypes: %s(%d), %s(%d)' % (df, nf, do, no) else: dtypeLine = '\ndtype: %s(%d)' % (df, nf) buffer.write('\n'.join(columns) + dtypeLine)
def info(self, buffer=sys.stdout): """ Concise summary of a DataMatrix, used in __repr__ when very large. """ print >> buffer, 'Index: %s entries' % len(self.index), if len(self.index) > 0: print >> buffer, ', %s to %s' % (self.index[0], self.index[-1]) else: print >> buffer, '' if len(self.columns) == 0: print >> buffer, 'DataMatrix is empty!' print >> buffer, repr(self.index) return print >> buffer, 'Data columns:' space = max([len(str(k)) for k in self.cols()]) + 4 counts = self.count() cols = self.cols() assert(len(cols) == len(counts)) columns = [] for col, count in counts.iteritems(): columns.append('%s%d non-null values' % (common._pfixed(col, space), count)) dtypeLine = '' nf = len(self.columns) df = self.values.dtype if self.objects is not None: no = len(self.objects.columns) do = self.objects.values.dtype dtypeLine = '\ndtypes: %s(%d), %s(%d)' % (df, nf, do, no) else: dtypeLine = '\ndtype: %s(%d)' % (df, nf) buffer.write('\n'.join(columns) + dtypeLine)
def _myformat(v): return _pfixed(v, col_space, na_rep=self.na_rep, float_format=self.float_format)