Returns a column name that isn't in the specified DataFrame
    Parameters:
    df - DataFrame
        DataFrame to analyze
    col_name - string, default 'unnamed_col'
        Column name to use as the base value for the generated column name
430295
def colname_gen(df,col_name = 'unnamed_col'):
    
    if col_name not in df.keys():
        yield col_name
    id_number = 0
    while True:
        col_name = col_name + str(id_number)
        if col_name in df.keys():
            id_number+=1
        else:
            return col_name
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
1174896
def required(col_name, arg, dm, df, *args):
    
    if col_name in df.columns:
        return None
    else:
        return '"{}" column is required'.format(col_name)
1034807
def _extract_colnum(self, col):
        
        if isinteger(col):
            colnum = col

            if (colnum < 0) or (colnum > (self._ncol-1)):
                raise ValueError(
                    "column number should be in [0,%d]" % (0, self._ncol-1))
        else:
            colstr = mks(col)
            try:
                if self.case_sensitive:
                    mess = "column name '%s' not found (case sensitive)" % col
                    colnum = self._colnames.index(colstr)
                else:
                    mess \
                        = "column name '%s' not found (case insensitive)" % col
                    colnum = self._colnames_lower.index(colstr.lower())
            except ValueError:
                raise ValueError(mess)
        return int(colnum)
967822
def drop(self, *cols):
        
        try:
            index = self.df.columns.values
            for col in cols:
                if col not in index:
                    self.warning("Column", col, "not found. Aborting")
                    return
                self.df = self.df.drop(col, axis=1)
        except Exception as e:
            self.err(e, self.drop, "Can not drop column")
499244
def normalize_col_name(self, col_name, used_column_names, is_relation):
        
        field_params = {}
        field_notes = []

        new_name = col_name.lower()
        if new_name != col_name:
            field_notes.append('Field name made lowercase.')

        if is_relation:
            if new_name.endswith('_id'):
                new_name = new_name[:-3]
            else:
                field_params['db_column'] = col_name

        new_name, num_repl = re.subn(r'\W', '_', new_name)
        if num_repl > 0:
            field_notes.append('Field renamed to remove unsuitable characters.')

        if new_name.find('__') >= 0:
            while new_name.find('__') >= 0:
                new_name = new_name.replace('__', '_')
            if col_name.lower().find('__') >= 0:
                # Only add the comment if the double underscore was in the original name
                field_notes.append("Field renamed because it contained more than one '_' in a row.")

        if new_name.startswith('_'):
            new_name = 'field%s' % new_name
            field_notes.append("Field renamed because it started with '_'.")

        if new_name.endswith('_'):
            new_name = '%sfield' % new_name
            field_notes.append("Field renamed because it ended with '_'.")

        if keyword.iskeyword(new_name):
            new_name += '_field'
            field_notes.append('Field renamed because it was a Python reserved word.')

        if new_name[0].isdigit():
            new_name = 'number_%s' % new_name
            field_notes.append("Field renamed because it wasn't a valid Python identifier.")

        if new_name in used_column_names:
            num = 0
            while '%s_%d' % (new_name, num) in used_column_names:
                num += 1
            new_name = '%s_%d' % (new_name, num)
            field_notes.append('Field renamed because of name conflict.')

        if col_name != new_name and field_notes:
            field_params['db_column'] = col_name

        return new_name, field_params, field_notes
992238
def columns_exist(inspect_dataset):
    

    # Attempt to get column names. For pandas, columns is just a list of strings
    if not hasattr(inspect_dataset, "columns"):
        warnings.warn(
            "No columns list found in dataset; no autoinspection performed.")
        return
    elif isinstance(inspect_dataset.columns[0], string_types):
        columns = inspect_dataset.columns
    elif isinstance(inspect_dataset.columns[0], dict) and "name" in inspect_dataset.columns[0]:
        columns = [col['name'] for col in inspect_dataset.columns]
    else:
        raise AutoInspectError(
            "Unable to determine column names for this dataset.")

    create_multiple_expectations(
        inspect_dataset, columns, "expect_column_to_exist")
644132
def col_name2cat(column):
    
    column_string = ''.join(s for s in column.replace(' ', '_') if s.isalnum() or '_' == s)
    return column_string
1217251
def column(self, col):
        
        if type(col) is str:
            for c in self._cols:
                if c.name == col:
                    return c
        else:
            return self._cols[col]
117712
def _get_index_name_by_column(table, column_name):
    
    protected_name = metadata.protect_name(column_name)
    possible_index_values = [protected_name, "values(%s)" % protected_name]
    for index_metadata in table.indexes.values():
        options = dict(index_metadata.index_options)
        if options.get('target') in possible_index_values:
            return index_metadata.name
1177063
def clean_colnames(df):
    
    col_list = []
    for index in range(_dutils.cols(df)):
        col_list.append(df.columns[index].strip().lower().replace(' ','_'))
    df.columns = col_list
1307577
def getColumnByColumnAlias(self, name):
        
        result = None
        for column in self.__columns:
            columnAlias = column.getColumnAlias()
            if columnAlias == name:
                result = column
                break
        return result
1083765
def constraint_df(self):
        
        df = pd.DataFrame()
        for name,c in self.constraints.items():
            df[name] = c.ok
        for name,c in self.hidden_constraints.items():
            df[name] = c.ok
        return df
767638
def ColumnAttr(name='', attr=None, **kwargs):
    ''
    return Column(name,
                  expr=attr if attr is not None else name,
                  getter=lambda col,row: getattrdeep(row, col.expr),
                  setter=lambda col,row,val: setattrdeep(row, col.expr, val),
                  **kwargs)
781417
private static String getColumnName(ResultSetMetaData metaData, int idx, EColumnNameCase nameCase) throws SQLException {
		String colName = metaData.getColumnName(idx);
		switch (nameCase) {
			case LOWER:
				colName = colName.toLowerCase();
				break;
			case UPPER:
				colName = colName.toUpperCase();
				break;
		}

		return colName;
	}
584375
def rename_cols(df,names,renames=None,prefix=None,suffix=None):
    
    if not prefix is None:
        renames=[ "%s%s" % (prefix,s) for s in names]
    if not suffix is None:    
        renames=[ "%s%s" % (s,suffix) for s in names]
    if not renames is None:
        for i,name in enumerate(names):
#             names=[renames[i] if s==names[i] else s for s in names]    
            rename=renames[i]    
            df.loc[:,rename]=df.loc[:,name]
        df=df.drop(names,axis=1)
        return df
910525
def get_name_id_interactive(stop, df):
    

    # this is very fast, but searching in a list of ca. 2900 tuples might be also
    # fast enough, and that would mean removing some repeated preprocessing...

    # pick only entries containing the given stop substring in column stop_name
    df1 = df[df.stop_name.apply(lambda cell: stop.lower() in cell.lower())]
    df1 = df1.sort_values(by=['stop_name'])
    df1_len = len(df1)
    if df1_len == 1:
        result = {
            'stop_id': df1.iloc[0].stop_id,
            'stop_name': df1.iloc[0].stop_name
        }
        return result
    elif df1_len > 1:
        msg = 'Please pick one of the following matching stop names:'
        termcolor.cprint(msg, attrs=['bold'])
        fmt = '%%%dd. %%s' % len(str(df1_len))
        for i, (index, _id, stop_name) in enumerate(df1.itertuples()):
            print(fmt % (i, stop_name))

        try:
            msg = 'Please select index of desired stop '\
                  'in list above (0-%d): ' % (df1_len - 1)
            msg = termcolor.colored(msg, attrs=['bold'])
            result = raw_input(msg)
        except KeyboardInterrupt:
            print('')
            return

        try:
            i = int(result)
        except ValueError:
            msg = "'%s' is not an integer number." % result
            termcolor.cprint(msg, 'red', attrs=['bold'])
            return

        if not 0 <= i <= df1_len - 1:
            msg = 'Invalid index.'
            termcolor.cprint(msg, 'red', attrs=['bold'])
            return

        result = {
            'stop_id': df1.iloc[i].stop_id,
            'stop_name': df1.iloc[i].stop_name
        }
        return result