From 'Column Title' to 'Column_x0020_Title
320413
def _convert_to_internal(self, data):
        """'"""
        for _dict in data:
            keys = list(_dict.keys())[:]
            for key in keys:
                if key not in self._disp_cols:
                    raise Exception(key + ' not a column in current List.')
                _dict[self._disp_cols[key]['name']] = self._sp_type(key, _dict.pop(key))
150848
def outitem(title, elems, indent=4):
    """"""
    out(title)
    max_key_len = max(len(key) for key, _ in elems) + 1
    for key, val in elems:
        key_spaced = ('%s:' % key).ljust(max_key_len)
        out('%s%s %s' % (indent * ' ', key_spaced, val))
    out()
541057
def convert_column(self, values):
        """"""
        assert all(values >= 0), 'Cannot normalize a column with negatives'
        total = sum(values)
        if total > 0:
            return values / total
        else:
            return values
963065
def transform(self, col):
        
        out = pd.DataFrame(index=col.index)
        out[self.col_name] = col.fillna(self.default_value)
        out[self.new_name] = (pd.notnull(col) * 1).astype(int)
        return out
318968
def transform(self, X):
        

        for i, col in enumerate(X.columns):
            X.loc[:, col] = self._transform_col(X[col], i)

        return X
539450
def _sel_to_text(self, cell_range):
        """"""
        if not cell_range:
            return
        row_min, row_max, col_min, col_max = get_idx_rect(cell_range)
        if col_min == 0 and col_max == (self.model().cols_loaded-1):
            # we've selected a whole column. It isn't possible to
            # select only the first part of a column without loading more, 
            # so we can treat it as intentional and copy the whole thing
            col_max = self.model().total_cols-1
        if row_min == 0 and row_max == (self.model().rows_loaded-1):
            row_max = self.model().total_rows-1
        
        _data = self.model().get_data()
        if PY3:
            output = io.BytesIO()
        else:
            output = io.StringIO()
        try:
            np.savetxt(output, _data[row_min:row_max+1, col_min:col_max+1],
                       delimiter='\t', fmt=self.model().get_format())
        except:
            QMessageBox.warning(self, _("Warning"),
                                _("It was not possible to copy values for "
                                  "this array"))
            return
        contents = output.getvalue().decode('utf-8')
        output.close()
        return contents
127053
def title_translations2marc(self, key, value):
    """"""
    return {
        'a': value.get('title'),
        'b': value.get('subtitle'),
        '9': value.get('source'),
    }
53108
def translate_table(data):
    
    headers = sorted(data.get("Headers", []))
    table = '\\FloatBarrier \n \\section{$NAME} \n'.replace('$NAME', data.get("Title", "table"))
    table += '\\begin{table}[!ht] \n \\begin{center}'

    # Set the number of columns
    n_cols = "c"*(len(headers)+1)
    table += '\n \\begin{tabular}{$NCOLS} \n'.replace("$NCOLS", n_cols)

    # Put in the headers
    for header in headers:
        table += ' $HEADER &'.replace('$HEADER', header).replace('%', '\%')
    table = table[:-1] + ' \\\\ \n \hline \n'

    # Put in the data
    for header in headers:
        table += ' $VAL &'.replace("$VAL", str(data["Data"][header]))
    table = table[:-1] + ' \\\\ \n \hline'
    table += '\n \end{tabular} \n \end{center} \n \end{table}\n'
    return table
356291
def title_slug
      value = (@options['slug'] || @options['title']).downcase
      value.gsub!(/[^\x00-\x7F]/u, '')
      value.gsub!(/(&amp;|&)+/, 'and')
      value.gsub!(/[']+/, '')
      value.gsub!(/\W+/, ' ')
      value.strip!
      value.gsub!(' ', '-')
      value
    end
991084
def convert_value_to_text r, count
      if r == :separator
        return separator
      elsif r == :columns
        return "??" unless @columns # column was requested but not supplied
        # FIXME putting entire header into this, take care of hidden
        r = []
        @columns.each_with_index { |e, i| r << e unless get_column(i).hidden  }
        return @headerfmtstr % r if @numbering
      end
      str = ""

      if @numbering
        #r = r.dup
        #r.insert 0, count+1
        # TODO get the width
        str << "%*d |"%  [2, count + 1]
      end
      # unroll r, get width and align
      # This is to truncate column to requested width
      fmta = []
      r.each_with_index { |e, i| 
        next if get_column(i).hidden == true
        #w = @pw[i] || @cw[i]  # XXX
        #$log.debug "WIDTH XXX  #{i} w= #{w} , #{@pw[i]}, #{@cw[i]} :: #{e} " if $log.debug? 
        w = @cw[i]
        l = e.to_s.length
        fmt = "%-#{w}s "
        # if value is longer than width, then truncate it
        if l > w
          fmt = "%.#{w}s "
        else
          # ack we don;t need to recalc this we can pull out of hash FIXME
          case @calign[i]
          when :right
            fmt = "%#{w}s "
          else
            fmt = "%-#{w}s "
          end
        end
        str << fmt % e
        fmta << fmt
      }
      #fmstr = fmta.join(@y)
      #return fmstr % r; # FIXME hidden column still goes int 
      return str
    end
644132
def col_name2cat(column):
    
    column_string = ''.join(s for s in column.replace(' ', '_') if s.isalnum() or '_' == s)
    return column_string
90816
def column_alias(cell, names):
    
    column = slugify(cell.column or '', sep='_')
    column = column.strip('_')
    column = 'column' if not len(column) else column
    name, i = column, 2
    # de-dupe: column, column_2, column_3, ...
    while name in names:
        name = '%s_%s' % (name, i)
        i += 1
    return name
827295
def rename_column(self, model, old_name, new_name):
        """"""
        field = model._meta.fields[old_name]
        if isinstance(field, pw.ForeignKeyField):
            old_name = field.column_name
        self.__del_field__(model, field)
        field.name = field.column_name = new_name
        model._meta.add_field(new_name, field)
        if isinstance(field, pw.ForeignKeyField):
            field.column_name = new_name = field.column_name + '_id'
        self.ops.append(self.migrator.rename_column(model._meta.table_name, old_name, new_name))
        return model
484446
function(title) {
  var logChar = "#";
  var row1 = "";
  var row2 = " " + title + " ";
  var row3 = "";
  while(row1.length < row2.length) {
    row1 = row1 + logChar;
    row3 = row3 + logChar;
  }
  for (var i = 0; i < 10; i++) {
    row1 = logChar + row1 + logChar;
    row2 = logChar + row2 + logChar;
    row3 = logChar + row3 + logChar;
  }

  return "\n\n" + [row1, row2, row3].join("\n") + "\n\n";
}
937356
def rename_column(old, nu)
      col = @origin.columns[old.to_s]

      definition = col[:type]
      definition += ' NOT NULL' unless col[:is_nullable]
      definition += " DEFAULT #{@connection.quote(col[:column_default])}" if col[:column_default]

      ddl('alter table `%s` change column `%s` `%s` %s' % [@name, old, nu, definition])
      @renames[old.to_s] = nu.to_s
    end
1341947
def _fill_column_holes(self):
        '''
        
        '''
        for column_index in range(self.start[1], self.end[1]):
            table_column = TableTranspose(self.table)[column_index]
            column_start = table_column[self.start[0]]
            if is_text_cell(column_start):
                self._check_fill_title_column(column_index)
521256
def _nicetitle(coord, value, maxchar, template):
    
    prettyvalue = format_item(value, quote_strings=False)
    title = template.format(coord=coord, value=prettyvalue)

    if len(title) > maxchar:
        title = title[:(maxchar - 3)] + '...'

    return title