Append an ID column to current DataFrame.

        :param str id_col_name: name of appended ID field.
        :param str cols: fields contained in output. All fields by default.

        :return: DataFrame with ID field
        :rtype: DataFrame
769328
def append_id(self, id_col_name='append_id', cols=None):
        
        from .. import preprocess
        if id_col_name in self.schema:
            raise ValueError('ID column collides with existing columns.')
        append_id_obj = getattr(preprocess, '_AppendID')(id_col=id_col_name, selected_cols=cols)
        return append_id_obj.transform(self)
143690
function addCol($col_data, $col_id = 0, $row_id = 0) {
        foreach ($col_data as $col_cell) {
            $this->_data[$row_id++][$col_id] = $col_cell;
        }

        $this->_updateRowsCols();
        $this->_max_cols = max($this->_max_cols, $col_id + 1);
    }
39541
def _addColumn(cat, col):
    
    # First check if the metadata column already exists
    if col not in cat.schema():
        try:
            cat.addColumn(col)
            logger.info('Column %s added to %s.' % (col, cat.id))
            return True
        except:
            logger.error(
                'Catalog column %s error while adding to %s.' % (col, cat.id))
    return False
38660
def append_text_column(self, text: str, index: int):
        
        width = self.columns[index]["width"]
        return f"{text:<{width}}"
1253279
public static void appendColumns(StringBuilder s, String[] columns) {
        int n = columns.length;

        for (int i = 0; i < n; i++) {
            String column = columns[i];

            if (column != null) {
                if (i > 0) {
                    s.append(", ");
                }
                s.append(column);
            }
        }
        s.append(' ');
    }
447581
function getColumnWithNameOrId(nameOrId, columns) {
  for (var i = 0; i < columns.length; i++) {
    if (columns[i].name === nameOrId || columns[i].id === nameOrId) {
      return columns[i];
    }
  }
}
654058
def add(self, col: str, value):
        
        try:
            self.df[col] = value
        except Exception as e:
            self.err(e, self.add, "Can not add column")
248490
def add_column(column_name, definition)
      attributes = column_attributes(column_name, definition)
      migration.add_column(*attributes)
    end
453502
def row_append(self, row_key, value_list):
        
        if row_key in self._row_keys:
            raise KeyError('Key %s already exists in row keys.' % row_key)
        if not len(value_list) == len(self._col_keys):
            raise ValueError('Length of data to set does not meet expected row length of %i' % len(self._col_keys))
        self._row_keys.append(row_key)
        for c, v in zip(self._col_keys, value_list):
            self[row_key, c] = v
1046928
def _idx_col_by_num(table):
    
    _columns = []
    try:
        # Create an empty list that matches the length of the column dictionary
        _columns = [None for i in range(0, len(table["columns"]))]

        # Loop and start placing data in the output list based on its "number" entry
        for _name, _dat in table["columns"].items():
            try:
                # Special case for ensemble table "numbers" list
                if isinstance(_dat["number"], list):
                    _columns.append(_dat)
                # Place at list index based on its column number
                else:
                    # cast number to int, just in case it's stored as a string.
                    n = int(_dat["number"])
                    _columns[n - 1] = _dat
            except KeyError as ke:
                print("Error: idx_col_by_num: {}".format(ke))
                logger_jsons.error("idx_col_by_num: KeyError: missing number key: {}, {}".format(_name, ke))
            except Exception as e:
                print("Error: idx_col_by_num: {}".format(e))
                logger_jsons.error("idx_col_by_num: Exception: {}".format(e))

        table["columns"] = _columns
    except Exception as e:
        logger_jsons.error("idx_col_by_num: {}".format(e))
        print("Error: idx_col_by_num: {}".format(e))

    return table
626740
def rename_columns(self, col):
        
        try:
            self.cleaned_data.columns = col
        except Exception as e:
            raise e
897987
def _idx_col2rowm(d):
    """"""
    if 0 == len(d):
        return 1
    if 1 == len(d):
        return np.arange(d[0])
    # order='F' indicates column-major ordering
    idx = np.array(np.arange(np.prod(d))).reshape(d, order='F').T
    return idx.flatten(order='F')
1024291
def add_column(name, column_properties = {})
      validate_column_absence(name)
      create_column_properties(name, column_properties)
      @data_rows.each{|x|
        x << (yield Row.new(@column_indexes, x))
      }
      @column_indexes[name] = @column_indexes.size
      self # enable chaining
    end
1358383
def add_columns(self, model, **fields):
        """"""
        for name, field in fields.items():
            model._meta.add_field(name, field)
            self.ops.append(self.migrator.add_column(
                model._meta.table_name, field.column_name, field))
            if field.unique:
                self.ops.append(self.migrator.add_index(
                    model._meta.table_name, (field.column_name,), unique=True))
        return model
397131
def add_row(self, label, row_data, columns=""):
        
        # use provided column order, making sure you don't lose any values
        # from self.df.columns
        if len(columns):
            if sorted(self.df.columns) == sorted(columns):
                self.df.columns = columns
            else:
                new_columns = []
                new_columns.extend(columns)
                for col in self.df.columns:
                    if col not in new_columns:
                        new_columns.append(col)
        # makes sure all columns have data or None
        if sorted(row_data.keys()) != sorted(self.df.columns):
            # add any new column names
            for key in row_data:
                if key not in self.df.columns:
                    self.df[key] = None
            # add missing column names into row_data
            for col_label in self.df.columns:
                if col_label not in list(row_data.keys()):
                    row_data[col_label] = None

        # (make sure you are working with strings)
        self.df.index = self.df.index.astype(str)
        label = str(label)

        # create a new row with suffix "new"
        # (this ensures that you get a unique, new row,
        #  instead of adding on to an existing row with the same label)
        self.df.loc[label + "new"] = pd.Series(row_data)
        # rename it to be correct
        self.df.rename(index={label + "new": label}, inplace=True)
        # use next line to sort index inplace
        #self.df.sort_index(inplace=True)
        return self.df
1081359
def colAdd(self,name="",desc="",unit="",comment="",coltype=0,data=[],pos=None):
        
        if pos is None:
            pos=len(self.colNames)
        self.colNames.insert(pos,name)
        self.colDesc.insert(pos,desc)
        self.colUnits.insert(pos,unit)
        self.colComments.insert(pos,comment)
        self.colTypes.insert(pos,coltype)
        self.colData.insert(pos,data)
        return
1152498
def filter_by_cols(self, cols, ID=None):
        
        rows = to_list(cols)
        fil = lambda x: x in rows
        applyto = {k: self._positions[k][1] for k in self.keys()}
        if ID is None:
            ID = self.ID + '.filtered_by_cols'
        return self.filter(fil, applyto=applyto, ID=ID)