Utility method that returns totals for database statistics.
        
        @param headers: List of columns in query result.
        @param rows:    List of rows in query result.
        @return:        Dictionary of totals for each statistics column.
775420
def _createTotalsDict(self, headers, rows):
        
        totals = [sum(col) for col in zip(*rows)[1:]]
        return dict(zip(headers[1:], totals))
480989
public function table(array $headers, array $rows, $tableStyle = 'default', array $columnStyles = [])
    {
        $this->output->table($headers, $rows, $tableStyle, $columnStyles);
    }
609647
def get_hours_data(self, entries, date_headers):
        """"""
        project_totals = get_project_totals(
            entries, date_headers, total_column=False) if entries else []

        data_map = {}
        for rows, totals in project_totals:
            for user, user_id, periods in rows:
                for period in periods:
                    day = period['day']
                    if day not in data_map:
                        data_map[day] = {'billable': 0, 'nonbillable': 0}
                    data_map[day]['billable'] += period['billable']
                    data_map[day]['nonbillable'] += period['nonbillable']

        return data_map
729024
public static String extractSqlColumns(final String[] headers)
	{
		final StringBuffer sqlColumns = new StringBuffer();
		sqlColumns.append("");
		for (int i = 0; i < headers.length; i++)
		{
			sqlColumns.append(headers[i]);
			if (i < headers.length - 1)
			{
				sqlColumns.append(", ");
			}
			else
			{
				sqlColumns.append("");
			}
		}
		return sqlColumns.toString();
	}
1045334
def padded_rows
      rows = @rows.map do |row|
        CSV::Row.new(row.cells.keys, row.cells.values)
      end

      table = CSV::Table.new(rows)
      table.values_at(*@header.columns)
    end
1287411
protected function writeTable(array $headers, array $rows)
    {
        $columnCount = count($headers);
        $rowCount = count($rows) + 1;
        $columns = array_fill(0, $columnCount, 0);
        $tables = [];

        foreach (array_merge([$headers], $rows) as $row) {
            $i = -1;
            $newRow = [];
            foreach ($row as $col) {
                $newRow[++$i] = StringParser::create($col)->getParsed();
                $newRow[$i]['len'] = 0;
                foreach ($newRow[$i] as $part) {
                    $newRow[$i]['len'] += strlen($part['original']);
                }
                $columns[$i] = max($columns[$i], $newRow[$i]['len']);
            }
            $tables[] = $newRow;
        }

        $i = -1;
        $line = str_repeat('-', array_sum($columns) + $columnCount + 2);
        foreach ($tables as $row) {
            if (++$i === 0) {
                echo $line . PHP_EOL;
            }
            $j = -1;
            foreach ($row as $col) {
                ++$j;
                $len = array_pop($col);
                foreach ($col as $part) {
                    echo ' ' . $part['colored'];
                    echo str_repeat(' ', $columns[$j] - $len + 1);
                }
            }

            if ($i === 0) {
                echo PHP_EOL;
                echo $line;
            }

            echo PHP_EOL;
            if ($i === $rowCount - 1) {
                echo $line . PHP_EOL;
            }
        }
    }
562076
private static int getDataRows(Chunk[] chunks, Frame f, int[] chunksIds, int cols) {
        double totalRows = 0;
        if(null != chunks) {
            for (Chunk ch : chunks) {
                totalRows += ch.len();
            }
        } else {
            for(int chunkId : chunksIds) {
                totalRows += f.anyVec().chunkLen(chunkId);
            }
        }
        return (int) Math.ceil(totalRows * cols / SPARSE_MATRIX_DIM);
    }
1282495
def with_headers(self, headers):
        
        for key, value in headers.items():
            self.with_header(key, value)
        return self
1296557
def _iostats_dict(header, stats):
    '''
    
    '''
    stats = [float((sum(stat) / len(stat)).quantize(decimal.Decimal('.01'))) for stat in zip(*stats)]
    stats = dict(zip(header, stats))
    return stats
302905
public AbstractSheet<TRow, TColumn, TCell> setRows(List<TRow> rows) {
        this.rows = rows;
        return this;
    }
558414
private static byte[] writeCsv(String[] columnHeaders, List<String[]> rows) throws IOException {
    return writeCsv(columnHeaders, rows.stream().toArray(String[][]::new));
  }
230225
private void setupMappingColumns(final String[] headers) {
        
        final List<ColumnMapping> columnMappingList = beanMapping.getColumns();
        final HeaderMapper headerMapper = beanMapping.getHeaderMapper();
        
        // 一致するラベルがあれば、カラムの番号を補完する
        final int headerSize = headers.length;
        for(int i=0; i < headerSize;i ++) {
            
            final String header = headers[i];
            
            /*
             * 番号が決まっておらず、ラベルが一致するカラム情報を抽出する。
             * ※既に番号が決まっているが、ラベルが一致しないのものは、後からチェックする。
             */
            List<ColumnMapping> undeterminedColumnList = columnMappingList.stream()
                .filter(col -> !col.isDeterminedNumber())
                .filter(col -> headerMapper.toMap(col, beanMapping.getConfiguration(), beanMapping.getGroups()).equals(header))
                .collect(Collectors.toList());
            
            final int columnNumber = i+1;
            undeterminedColumnList.forEach(col -> col.setNumber(columnNumber));
            
        }
        
        // カラムの番号順に並び変える
        columnMappingList.sort(null);
        
        /* 
         * ヘッダーでは指定されていない番号が未決定のカラムについて、空いている番号に振る
         * ・@CsvPartialで指定した場合とかぶらないようにすべき？
         */
        final Optional<CsvPartial> partialAnno = Optional.ofNullable(beanMapping.getType().getAnnotation(CsvPartial.class));
        final List<ColumnMapping> undeterminedColumnList = columnMappingList.stream()
                .filter(col -> !col.isDeterminedNumber())
                .collect(Collectors.toList());
        
        if(!undeterminedColumnList.isEmpty()) {
            final Set<Integer> determinedNumbers = columnMappingList.stream()
                    .filter(col -> col.isDeterminedNumber())
                    .map(col -> col.getNumber())
                    .collect(Collectors.toSet());
            
            // @CsvParitalで定義されているカラムは、決定されている番号として処理する。
            partialAnno.ifPresent(anno -> Arrays.stream(anno.headers()).forEach(header -> determinedNumbers.add(header.number())));
            
            int counter = 1;
            for(ColumnMapping col : undeterminedColumnList) {
                while(true) {
                    if(!determinedNumbers.contains(counter)) {
                        break;
                    }
                    counter++;
                }
                
                col.setNumber(counter);
                determinedNumbers.add(counter);
            }
            
            // 第度カラムの番号順に並び変える
            columnMappingList.sort(null);
        
        }
        
        // 決定していないカラム番号のチェック
        BeanMappingFactoryHelper.validateNonDeterminedColumnNumber(beanMapping.getType(), columnMappingList, headers);
        
        // 重複しているカラム番号のチェック
        BeanMappingFactoryHelper.validateDuplicatedColumnNumber(beanMapping.getType(), columnMappingList);
        
        // 不足しているカラム番号の補完
        BeanMappingFactoryHelper.supplyLackedNumberMappingColumn(beanMapping.getType(), columnMappingList, partialAnno, headers);
        
        beanMapping.setColumns(columnMappingList);
        
    }
672724
public function addTable($rows, $headers = false)
	{
		// Figure out some items we need to know
		$maxLengths = [];

		foreach ($rows as $i => $row)
		{
			foreach ($row as $k => $field)
			{
				$maxLengths[$k] = isset($maxLengths[$k]) ? $maxLengths[$k] : 0;
				$maxLengths[$k] = strlen($field) > $maxLengths[$k] ? strlen($field) : $maxLengths[$k];
			}
		}

		// Compute the total length of the table
		$width = array_sum($maxLengths) + ((count($row) - 1) * 3) + 2;

		// Add the top border
		$this->addLine('/' . str_repeat('-', ($width)) . '\\');

		// Draw the rows
		foreach ($rows as $i => $row)
		{
			$styles = ($i == 0 && $headers) ? ['format' => 'underline'] : null;
			foreach ($row as $k => $field)
			{
				$padding = $maxLengths[$k] - strlen($field);
				$this->addString('| ');
				$this->addString($field, $styles);
				$this->addString(' ' . str_repeat(' ', $padding));
			}

			$this->addLine('|');
		}

		// Add the bottom border
		$this->addLine('\\' . str_repeat('-', ($width)) . '/');
	}
1358121
def getDatabaseStats(self):
        
        headers = ('datname', 'numbackends', 'xact_commit', 'xact_rollback', 
                   'blks_read', 'blks_hit', 'tup_returned', 'tup_fetched', 
                   'tup_inserted', 'tup_updated', 'tup_deleted', 'disk_size')
        cur = self._conn.cursor()
        cur.execute("SELECT %s, pg_database_size(datname) FROM pg_stat_database;" 
                    % ",".join(headers[:-1]))
        rows = cur.fetchall()
        dbstats = self._createStatsDict(headers, rows)
        totals = self._createTotalsDict(headers, rows)
        return {'databases': dbstats, 'totals': totals}
803140
private function calculateNumberOfColumns($rows)
    {
        $columns = [0];
        foreach ($rows as $row) {
            if ($row instanceof TableSeparator) {
                continue;
            }

            $columns[] = $this->getNumberOfColumns($row);
        }

        $this->numberOfColumns = max($columns);
    }
542995
def get_database_rows(self, tables=None, database=None):
        """"""
        # Get table data and columns from source database
        source = database if database else self.database
        tables = tables if tables else self.tables

        # Get database select queries
        commands = self._get_select_commands(source, tables)

        # Execute select commands
        return self._execute_select_commands(source, commands)
210574
def get_stats_of_rows(rows):
    """"""
    count_true = count_false = max_score = 0
    for row in rows:
        if not row.properties:
            logging.info('Missing property for %s.', row.filename)
            continue
        if len(row.properties) > 1:
            # multiple properties not yet supported
            count_true = count_false = max_score = 0
            break
        expected_result = row.expected_results.get(row.properties[0].name)
        if not expected_result:
            continue
        if expected_result.result is True:
            count_true += 1
        elif expected_result.result is False:
            count_false += 1
        for prop in row.properties:
            max_score += prop.max_score(expected_result)

    return max_score, count_true, count_false