def _table_info(self, buf=None): """ Similar to pandas DataFrame.info. Show column names, types, and null counts. Output to stdout by default """ metrics = [self.count().name('nrows')] for col in self.columns: metrics.append(self[col].count().name(col)) metrics = self.aggregate(metrics).execute().loc[0] names = ['Column', '------'] + self.columns types = ['Type', '----'] + [repr(x) for x in self.schema().types] counts = ['Non-null #', '----------'] + [str(x) for x in metrics[1:]] col_metrics = util.adjoin(2, names, types, counts) if buf is None: import sys buf = sys.stdout result = ('Table rows: {0}\n\n' '{1}' .format(metrics[0], col_metrics)) buf.write(result)