Check the given dataframe for the required columns
762101
def check_dataframe(self, dataframe):
        
        required_columns = (
            'a',
            'b',
            'm',
            'n',
            'r',
        )
        for column in required_columns:
            if column not in dataframe:
                raise Exception('Required column not in dataframe: {0}'.format(
                    column
                ))
155708
def check(self, feature):
        """"""
        mapper = feature.as_dataframe_mapper()
        X = mapper.fit_transform(self.X, y=self.y)
        assert not np.any(np.isnan(X))
870300
def columns_are_indexed(self, columns):
        
        for index in self._indexes.values():
            if index.spans_columns(columns):
                return True

        return False
556151
function requireValidColumns (model, extraColumns) {
    assert.equal(typeof extraColumns, 'object', 'columns must be object')
    // clone arg since it may be modified
    extraColumns = _.cloneDeep(extraColumns)
    // validate each column definition
    _.each(extraColumns, (spec, name) => {
        // check if name is a default column name
        var defaultColumnName = model.columnName(name)
        // spec is for default column
        if (defaultColumnName) {
            // if spec is false then remove default column
            if (spec === false) {
                // delete all entries for default column
                delete model.columns[defaultColumnName]
                delete model.defaultColumnsInverse[model.defaultColumns[defaultColumnName]]
                delete model.defaultColumns[defaultColumnName]
                // delete original entry in extra columns
                delete extraColumns[name]
            }
            // otherwise override default values with spec
            else {
                // merge spec over default
                _.merge(model.columns[defaultColumnName], spec)
                // delete original entry in extra columns
                delete extraColumns[name]
            }
        }
        // spec is for extra column
        else {
            // get validated spec
            extraColumns[name] = requireValidColumn(name, spec)
        }
    })

    // return validated columns
    return extraColumns
}
417222
def main(df):
  '''
  
  '''
  import numpy as np
  from ast import literal_eval as make_tuple

  test = {}
  test['row'] = df['mat'].index.tolist()
  test['col'] = df['mat'].columns.tolist()

  # if type( test_row ) is not str and type( test_row ) is not tuple:

  found_tuple = {}
  found_number = {}
  for inst_rc in ['row','col']:

    inst_name = test[inst_rc][0]

    found_tuple[inst_rc] = False
    found_number[inst_rc] = False

    if type(inst_name) != tuple:

      if type(inst_name) is int or type(inst_name) is float or type(inst_name) is np.int64:
        found_number[inst_rc] = True

      else:
        check_open = inst_name[0]
        check_comma = inst_name.find(',')
        check_close = inst_name[-1]

        if check_open == '(' and check_close == ')' and check_comma > 0 \
          and check_comma < len(inst_name):
          found_tuple[inst_rc] = True

  # convert to tuple if necessary
  #################################################
  if found_tuple['row']:
    row_names = df['mat'].index.tolist()
    row_names = [make_tuple(x) for x in row_names]
    df['mat'].index = row_names

  if found_tuple['col']:
    col_names = df['mat'].columns.tolist()
    col_names = [make_tuple(x) for x in col_names]
    df['mat'].columns = col_names

  # convert numbers to string if necessary
  #################################################
  if found_number['row']:
    row_names = df['mat'].index.tolist()
    row_names = [str(x) for x in row_names]
    df['mat'].index = row_names

  if found_number['col']:
    col_names = df['mat'].columns.tolist()
    col_names = [str(x) for x in col_names]
    df['mat'].columns = col_names

  return df
443319
def is_not_null(df: DataFrame, col_name: str) -> bool:
    
    if (
        isinstance(df, pd.DataFrame)
        and col_name in df.columns
        and df[col_name].notnull().any()
    ):
        return True
    else:
        return False
916475
def _item_check(self, dim_vals, data):
        
        if not self._check_items:
            return
        elif self.data_type is not None and not isinstance(data, self.data_type):
            if isinstance(self.data_type, tuple):
                data_type = tuple(dt.__name__ for dt in self.data_type)
            else:
                data_type = self.data_type.__name__
            raise TypeError('{slf} does not accept {data} type, data elements have '
                            'to be a {restr}.'.format(slf=type(self).__name__,
                                                      data=type(data).__name__,
                                                      restr=data_type))
        elif not len(dim_vals) == self.ndims:
            raise KeyError('The data contains keys of length %d, but the kdims '
                           'only declare %d dimensions. Ensure that the number '
                           'of kdims match the length of the keys in your data.'
                           % (len(dim_vals), self.ndims))
550116
def requiredIfGroup(col_name, arg, dm, df, *args):
    
    group_name = arg
    groups = set()
    columns = df.columns
    for col in columns:
        if col not in dm.index:
            continue
        group = dm.loc[col]['group']
        groups.add(group)
    if group_name in groups:
        if col_name in columns:
            return None
        else:
            return "{} column is required if column group {} is used".format(col_name, group_name)
    return None
235274
def _check_query(self, query, style_cols=None):
        """"""
        try:
            self.sql_client.send(
                utils.minify_sql((
                    'EXPLAIN',
                    'SELECT',
                    '  {style_cols}{comma}',
                    '  the_geom, the_geom_webmercator',
                    'FROM ({query}) _wrap;',
                )).format(query=query,
                          comma=',' if style_cols else '',
                          style_cols=(','.join(style_cols)
                                      if style_cols else '')),
                do_post=False)
        except Exception as err:
            raise ValueError(('Layer query `{query}` and/or style column(s) '
                              '{cols} are not valid: {err}.'
                              '').format(query=query,
                                         cols=', '.join(['`{}`'.format(c)
                                                         for c in style_cols]),
                                         err=err))
232159
def _verify_column_data(self, colnum, data):
        
        this_dt = data.dtype.descr[0]

        if len(data.shape) > 2:
            this_shape = data.shape[1:]
        elif len(data.shape) == 2 and data.shape[1] > 1:
            this_shape = data.shape[1:]
        else:
            this_shape = ()

        this_npy_type = this_dt[1][1:]

        npy_type, isvar, istbit = self._get_tbl_numpy_dtype(colnum)
        info = self._info['colinfo'][colnum]

        if npy_type[0] in ['>', '<', '|']:
            npy_type = npy_type[1:]

        col_name = info['name']
        col_tdim = info['tdim']
        col_shape = _tdim2shape(
            col_tdim, col_name, is_string=(npy_type[0] == 'S'))

        if col_shape is None:
            if this_shape == ():
                this_shape = None

        if col_shape is not None and not isinstance(col_shape, tuple):
            col_shape = (col_shape,)

        """
        print('column name:',col_name)
        print(data.shape)
        print('col tdim', info['tdim'])
        print('column dtype:',npy_type)
        print('input dtype:',this_npy_type)
        print('column shape:',col_shape)
        print('input shape:',this_shape)
        print()
        """

        # this mismatch is OK
        if npy_type == 'i1' and this_npy_type == 'b1':
            this_npy_type = 'i1'

        if isinstance(self, AsciiTableHDU):
            # we don't enforce types exact for ascii
            if npy_type == 'i8' and this_npy_type in ['i2', 'i4']:
                this_npy_type = 'i8'
            elif npy_type == 'f8' and this_npy_type == 'f4':
                this_npy_type = 'f8'

        if this_npy_type != npy_type:
            raise ValueError(
                "bad input data for column '%s': "
                "expected '%s', got '%s'" % (
                    col_name, npy_type, this_npy_type))

        if this_shape != col_shape:
            raise ValueError(
                "bad input shape for column '%s': "
                "expected '%s', got '%s'" % (col_name, col_shape, this_shape))
1341133
def _validate_input(self, table: pd.DataFrame, failed_only=False) -> pd.DataFrame:
        """"""
        return self._do_validation_set(
            table=table,
            columns=self.input_columns,
            validation_type="input",
            failed_only=failed_only,)
551598
def _by_columns(self, columns):
        
        return columns if self.isstr(columns) else self._backtick_columns(columns)
1112410
def _validate_columns(self):
        '''
        
        '''
        for column_index in range(self.start[1], self.end[1]):
            table_column = TableTranspose(self.table)[column_index]

            column_type = None
            if self.end[0] > self.start[0]:
                column_type = get_cell_type(table_column[self.start[0]])

            num_type_changes = 0
            for row_index in range(self.start[0], self.end[0]):
                if not check_cell_type(table_column[row_index], column_type):
                    column_type = get_cell_type(table_column[row_index])
                    num_type_changes += 1
                if num_type_changes > 1:
                    self.flag_change(self.flags, 'warning', (row_index-1, column_index),
                                     self.worksheet, self.FLAGS['unexpected-change'])
                    # Decrement this to catch other cells which change again
                    num_type_changes -= 1
1291274
private boolean verifyWithOfColumns(ColumnState[] columnStates, TextTableInfo tableInfo) {

    int tableWidth = tableInfo.getWidth();
    if (tableWidth != TextColumnInfo.WIDTH_AUTO_ADJUST) {
      int calculatedWidth = 0;
      for (ColumnState columnState : columnStates) {
        if (columnState.width < 0) {
          throw new AssertionError("columnWidth=" + columnState.width);
          // return false;
        }
        calculatedWidth = calculatedWidth + columnState.width + columnState.getColumnInfo().getBorderWidth();
      }
      if (calculatedWidth != tableWidth) {
        throw new AssertionError("with=" + tableWidth + ", sum-of-columns=" + calculatedWidth);
        // return false;
      }
    }
    return true;
  }
636482
def check_shapes(pfeed, *, as_df=False, include_warnings=False):
    
    table = 'shapes'
    problems = []

    # Preliminary checks
    if pfeed.shapes is None:
        return problems

    f = pfeed.shapes.copy()
    problems = check_for_required_columns(problems, table, f)
    if problems:
        return gt.format_problems(problems, as_df=as_df)

    if include_warnings:
        problems = check_for_invalid_columns(problems, table, f)

    # Check shape_id
    problems = gt.check_column(problems, table, f, 'shape_id', gt.valid_str)

    # Check geometry
    v = lambda x: isinstance(x, sg.LineString) and not x.is_empty
    problems = gt.check_column(problems, table, f, 'geometry', v)

    return gt.format_problems(problems, as_df=as_df)
1133038
def validate_image_col_row(image , col , row):
    """"""
    SPLIT_LIMIT = 99

    try:
        col = int(col)
        row = int(row)
    except:
        raise ValueError('columns and rows values could not be cast to integer.')

    if col < 2:
        raise ValueError('Number of columns must be between 2 and {} (you \
                          asked for {}).'.format(SPLIT_LIMIT, col))
    if row < 2 :
        raise ValueError('Number of rows must be between 2 and {} (you \
                          asked for {}).'.format(SPLIT_LIMIT, row))
1348413
void checkAddColumn(ColumnSchema col) {

        if (table.isText() && !table.isEmpty(session)) {
            throw Error.error(ErrorCode.X_S0521);
        }

        if (table.findColumn(col.getName().name) != -1) {
            throw Error.error(ErrorCode.X_42504);
        }

        if (col.isPrimaryKey() && table.hasPrimaryKey()) {
            throw Error.error(ErrorCode.X_42530);
        }

        if (col.isIdentity() && table.hasIdentityColumn()) {
            throw Error.error(ErrorCode.X_42525);
        }

        if (!table.isEmpty(session) && !col.hasDefault()
                && (!col.isNullable() || col.isPrimaryKey())
                && !col.isIdentity()) {
            throw Error.error(ErrorCode.X_42531);
        }
    }