Add columns of table t1 to table t0.
762926
def add_columns(t0, t1):
    """"""

    for colname in t1.colnames:
        col = t1.columns[colname]
        if colname in t0.columns:
            continue
        new_col = Column(name=col.name, length=len(t0), dtype=col.dtype)  # ,
        # shape=col.shape)
        t0.add_column(new_col)
982337
def add(self, entries, table=None, columns=None, ignore=False):
        """"""
        # Default table and columns #
        if table is None:   table   = self.main_table
        if columns is None: columns = self.get_columns_of_table(table)
        # Default columns #
        question_marks = ','.join('?' for c in columns)
        cols           = ','.join('"' + c + '"' for c in columns)
        ignore         = " OR IGNORE" if ignore else ""
        sql_command    = 'INSERT%s into "%s"(%s) VALUES (%s);'
        sql_command    = sql_command % (ignore, table, cols, question_marks)
        # Possible errors we want to catch #
        errors  = (sqlite3.OperationalError, sqlite3.ProgrammingError)
        errors += (sqlite3.IntegrityError, sqlite3.InterfaceError, ValueError)
        # Do it #
        try:
            new_cursor = self.own_connection.cursor()
            new_cursor.executemany(sql_command, entries)
        except errors as err:
            raise Exception(self.detailed_error(sql_command, columns, entries, err))
        except KeyboardInterrupt as err:
            print("You interrupted the data insertion.")
            print("Committing everything done up to this point.")
            self.own_connection.commit()
            raise err
713876
def insert_empty_columns(self, x: int, amount: int = 1) -> None:
        """"""
        def transform_columns(
                column: Union[int, float],
                row: Union[int, float]
        ) -> Tuple[Union[int, float], Union[int, float]]:
            return column + (amount if column >= x else 0), row
        self._transform_coordinates(transform_columns)
883271
def Union(self, t2, off):
        """"""
        assert type(t2) is Table
        N.enforce_number(off, N.UOffsetTFlags)

        off += self.Pos
        t2.Pos = off + self.Get(N.UOffsetTFlags, off)
        t2.Bytes = self.Bytes
38224
@Override
  public void modifyColumnFamily(TableName tableName, ColumnFamilyDescriptor columnFamilyDesc)
      throws IOException {
    modifyColumns(tableName, columnFamilyDesc.getNameAsString(), "modify",
        ModifyTableBuilder.newBuilder(tableName).modify(TableAdapter2x.toHColumnDescriptor(columnFamilyDesc)));
  }
11006
private void addJoinColumnToInfo(String joinColumn, TableInfo targetTableInfo, List<TableInfo> targetTableInfos,
            EntityMetadata m)
    {
        if (!joinColumn.equals(targetTableInfo.getIdColumnName()))
        {

            if (!targetTableInfos.isEmpty() && targetTableInfos.contains(targetTableInfo))
            {
                int idx = targetTableInfos.indexOf(targetTableInfo);
                targetTableInfo = targetTableInfos.get(idx);
                ColumnInfo columnInfoOfJoinColumn = getJoinColumn(targetTableInfo, joinColumn,
                        m.getIdAttribute().getBindableJavaType());
                if (!targetTableInfo.getColumnMetadatas().contains(columnInfoOfJoinColumn))
                {
                    targetTableInfo.addColumnInfo(columnInfoOfJoinColumn);
                }
            }
            else
            {
                ColumnInfo columnInfoOfJoinColumn = getJoinColumn(targetTableInfo, joinColumn,
                        m.getIdAttribute().getBindableJavaType());
                if (!targetTableInfo.getColumnMetadatas().contains(columnInfoOfJoinColumn))
                {
                    targetTableInfo.addColumnInfo(columnInfoOfJoinColumn);
                }
                targetTableInfos.add(targetTableInfo);
            }
        }
    }
49390
def diff_table(self, table1, table2):
        
        changes = 0
        table_differences = TableDiff(table1.get_name())
        table_differences.from_table = table1

        table1_columns = table1.get_columns()
        table2_columns = table2.get_columns()

        # See if all the fields in table1 exist in table2
        for column_name, column in table2_columns.items():
            if not table1.has_column(column_name):
                table_differences.added_columns[column_name] = column
                changes += 1

        # See if there are any removed fields in table2
        for column_name, column in table1_columns.items():
            if not table2.has_column(column_name):
                table_differences.removed_columns[column_name] = column
                changes += 1
                continue

            # See if column has changed properties in table2
            changed_properties = self.diff_column(
                column, table2.get_column(column_name)
            )

            if changed_properties:
                column_diff = ColumnDiff(
                    column.get_name(),
                    table2.get_column(column_name),
                    changed_properties,
                )
                column_diff.from_column = column
                table_differences.changed_columns[column.get_name()] = column_diff
                changes += 1

        self.detect_column_renamings(table_differences)

        table1_indexes = table1.get_indexes()
        table2_indexes = table2.get_indexes()

        # See if all the fields in table1 exist in table2
        for index_name, index in table2_indexes.items():
            if (
                index.is_primary() and not table1.has_primary_key()
            ) or table1.has_index(index_name):
                continue

            table_differences.added_indexes[index_name] = index
            changes += 1

        # See if there are any removed fields in table2
        for index_name, index in table1_indexes.items():
            if (index.is_primary() and not table2.has_primary_key()) or (
                not index.is_primary() and not table2.has_index(index_name)
            ):
                table_differences.removed_indexes[index_name] = index
                changes += 1
                continue

            # See if index has changed in table 2
            if index.is_primary():
                table2_index = table2.get_primary_key()
            else:
                table2_index = table2.get_index(index_name)

            if self.diff_index(index, table2_index):
                table_differences.changed_indexes[index_name] = index
                changes += 1

        self.detect_index_renamings(table_differences)

        from_fkeys = OrderedDict([(k, v) for k, v in table1.get_foreign_keys().items()])
        to_fkeys = OrderedDict([(k, v) for k, v in table2.get_foreign_keys().items()])

        for key1, constraint1 in table1.get_foreign_keys().items():
            for key2, constraint2 in table2.get_foreign_keys().items():
                if self.diff_foreign_key(constraint1, constraint2) is False:
                    del from_fkeys[key1]
                    del to_fkeys[key2]
                else:
                    if constraint1.get_name().lower() == constraint2.get_name().lower():
                        table_differences.changed_foreign_keys.append(constraint2)
                        changes += 1
                        del from_fkeys[key1]
                        del to_fkeys[key2]

        for constraint1 in from_fkeys.values():
            table_differences.removed_foreign_keys.append(constraint1)
            changes += 1

        for constraint2 in to_fkeys.values():
            table_differences.added_foreign_keys.append(constraint2)
            changes += 1

        if changes:
            return table_differences

        return False
461307
def putcolslice(self, value, blc, trc, inc=[], startrow=0, nrow=-1, rowincr=1):
        """"""
        return self._table.putcolslice(self._column, value, blc, trc, inc, startrow, nrow, rowincr)
415922
def _set_renamed_columns(self, table_diff, command, column):
        
        new_column = Column(command.to, column.get_type(), column.to_dict())

        table_diff.renamed_columns = {command.from_: new_column}

        return table_diff
664288
protected List appendListOfColumns(String[] columns, StringBuffer stmt)
    {
        ArrayList columnList = new ArrayList();

        for (int i = 0; i < columns.length; i++)
        {
            if (i > 0)
            {
                stmt.append(",");
            }
            stmt.append(columns[i]);
            columnList.add(columns[i]);
        }
        return columnList;

    }
1203617
def merge(cls, tables, fillna=False):
        """"""
        cols = set(itertools.chain(*[table.dtype.descr for table in tables]))

        tables_to_merge = []
        for table in tables:
            missing_cols = cols - set(table.dtype.descr)

            if missing_cols:
                if fillna:
                    n = len(table)
                    n_cols = len(missing_cols)
                    col_names = []
                    for col_name, col_dtype in missing_cols:
                        if 'f' not in col_dtype:
                            raise ValueError(
                                "Cannot create NaNs for non-float"
                                " type column '{}'".format(col_name)
                            )
                        col_names.append(col_name)

                    table = table.append_columns(
                        col_names, np.full((n_cols, n), np.nan)
                    )
                else:
                    raise ValueError(
                        "Table columns do not match. Use fill_na=True"
                        " if you want to append missing values with NaNs"
                    )
            tables_to_merge.append(table)

        first_table = tables_to_merge[0]

        merged_table = sum(tables_to_merge[1:], first_table)

        merged_table.h5loc = first_table.h5loc
        merged_table.h5singleton = first_table.h5singleton
        merged_table.split_h5 = first_table.split_h5
        merged_table.name = first_table.name

        return merged_table
308724
def _with_columns(self, columns):
        """"""
        table = type(self)()
        for label, column in zip(self.labels, columns):
            self._add_column_and_format(table, label, column)
        return table
363858
def _swap_columns(self, side):
        """"""
        displayed_cols = self._displayed_cols
        i1 = self._dragged_col_index
        i2 = i1 + 1 if side == 'right' else i1 - 1
        if 0 <= i2 < len(displayed_cols):
            # there is a neighbor, swap columns:
            displayed_cols[i1] = displayed_cols[i2]
            displayed_cols[i2] = self._dragged_col
            self["displaycolumns"] = displayed_cols
            if side == 'left':
                right = self._dragged_col_neighbor_widths[0]
                self._dragged_col_x -= right  # update dragged column x coordinate
                # set new left neighbor width
                if i2 > 0:
                    left = ttk.Treeview.column(self, displayed_cols[i2 - 1], 'width')
                else:
                    left = None
            else:
                left = self._dragged_col_neighbor_widths[1]
                self._dragged_col_x += left  # update x coordinate of dragged column
                # set new right neighbor width
                if i2 < len(displayed_cols) - 1:
                    right = ttk.Treeview.column(self, displayed_cols[i2 + 1], 'width')
                else:
                    right = None
            self._dragged_col_index = i2  # update dragged column index
            self._dragged_col_neighbor_widths = (left, right)
1034850
def multiply(self, a, b):
    
    if a is None or b is None: return None
    m, n = len(a), len(b[0])
    if len(b) != n:
        raise Exception("A's column number must be equal to B's row number.")
    l = len(b[0])
    table_a, table_b = {}, {}
    for i, row in enumerate(a):
        for j, ele in enumerate(row):
            if ele:
                if i not in table_a: table_a[i] = {}
                table_a[i][j] = ele
    for i, row in enumerate(b):
        for j, ele in enumerate(row):
            if ele:
                if i not in table_b: table_b[i] = {}
                table_b[i][j] = ele
    c = [[0 for j in range(l)] for i in range(m)]
    for i in table_a:
        for k in table_a[i]:
            if k not in table_b: continue
            for j in table_b[k]:
                c[i][j] += table_a[i][k] * table_b[k][j]
    return c
272431
public AbstractSheet<TRow, TColumn, TCell> setColumns(List<TColumn> columns) {
        this.columns = columns;
        return this;
    }
306170
def diff_table(self, table1, table2):
        
        changes = 0
        table_differences = TableDiff(table1.get_name())
        table_differences.from_table = table1

        table1_columns = table1.get_columns()
        table2_columns = table2.get_columns()

        # See if all the fields in table1 exist in table2
        for column_name, column in table2_columns.items():
            if not table1.has_column(column_name):
                table_differences.added_columns[column_name] = column
                changes += 1

        # See if there are any removed fields in table2
        for column_name, column in table1_columns.items():
            if not table2.has_column(column_name):
                table_differences.removed_columns[column_name] = column
                changes += 1
                continue

            # See if column has changed properties in table2
            changed_properties = self.diff_column(column, table2.get_column(column_name))

            if changed_properties:
                column_diff = ColumnDiff(column.get_name(),
                                         table2.get_column(column_name),
                                         changed_properties)
                column_diff.from_column = column
                table_differences.changed_columns[column.get_name()] = column_diff
                changes += 1

        self.detect_column_renamings(table_differences)

        # table1_indexes = table1.get_indexes()
        # table2_indexes = table2.get_indexes()
        #
        # # See if all the fields in table1 exist in table2
        # for index_name, index in table2_indexes.items():
        #     if (index.is_primary() and table1.has_primary_key()) or table1.has_index(index_name):
        #         continue
        #
        #     table_differences.added_indexes[index_name] = index
        #     changes += 1
        #
        # # See if there are any removed fields in table2
        # for index_name, index in table1_indexes.items():
        #     if (index.is_primary() and not table2.has_primary_key())\
        #             or (not index.is_primary() and not table2.has_index(index_name)):
        #         table_differences.removed_indexes[index_name] = index
        #         changes += 1
        #         continue
        #
        #     if index.is_primary():
        #         table2_index = table2.get_primary_key()
        #     else:
        #         table2_index = table2.get_index(index_name)
        #
        #     if self.diff_index(index, table2_index):
        #         table_differences.changed_indexes[index_name] = index
        #         changes += 1
        #
        # self.detect_index_renamings(table_differences)
        #
        # from_fkeys = table1.get_foreign_keys()
        # to_fkeys = table2.get_foreign_keys()
        #
        # for key1, constraint1 in from_fkeys.items():
        #     for key2, constraint2 in to_fkeys.items():
        #         if self.diff_foreign_key(constraint1, constraint2) is False:
        #             del from_fkeys[key1]
        #             del to_fkeys[key2]
        #         else:
        #             if constraint1.get_name().lower() == constraint2.get_name().lower():
        #                 table_differences.changed_foreign_keys.append(constraint2)
        #                 changes += 1
        #                 del from_fkeys[key1]
        #                 del to_fkeys[key2]
        #
        # for constraint1 in from_fkeys.values():
        #     table_differences.removed_foreign_keys.append(constraint1)
        #     changes += 1
        #
        # for constraint2 in to_fkeys.values():
        #     table_differences.added_foreign_keys.append(constraint2)
        #     changes += 1

        if changes:
            return table_differences

        return False
1355211
public static void swapCols(DenseDoubleMatrix2D matrix, long col1, long col2) {
		double temp = 0;
		long rows = matrix.getRowCount();
		for (long row = 0; row < rows; row++) {
			temp = matrix.getDouble(row, col1);
			matrix.setDouble(matrix.getDouble(row, col2), row, col1);
			matrix.setDouble(temp, row, col2);
		}
	}