Get the variable name from a table or column

    :param dict d: Metadata (column)
    :return str var: Variable name
507170
def get_variable_name_col(d):
    
    var = ""
    try:
        var = d["variableName"]
    except KeyError:
        try:
            var = d["name"]
        except KeyError:
            num = "unknown"
            if "number" in d:
                num = d["number"]
            print("Error: column number <{}> is missing a variableName. Please fix.".format(num))
            logger_misc.info("get_variable_name_col: KeyError: missing key")
    return var
1211106
def getvarcol(self, startrow=0, nrow=-1, rowincr=1):
        """"""
        return self._table.getvarcol(self._column, startrow, nrow, rowincr)
1364997
def getvarcol(self, columnname, startrow=0, nrow=-1, rowincr=1):
        
        return self._getvarcol(columnname, startrow, nrow, rowincr)
506066
def getPythonVarName(name):
    
    return SUB_REGEX.sub('', name.replace('+', '_').replace('-', '_').replace('.', '_').replace(' ', '').replace('/', '_')).upper()
725223
def get_expr(self, ctx):
        
        varname = ctx.lookup_variable(self.varname)
        if varname is None:
            val = ctx.lookup_constant(self.varname)
            if val:
                try:
                    return val.generate_code(ctx)
                except AttributeError:
                    return val
            raise MuvError(
                "Undeclared identifier '%s'." % self.varname,
                position=self.position
            )
        if len(self.indexing) == 0:
            return "{var} @".format(
                var=varname,
            )
        if len(self.indexing) == 1:
            return "{var} @ {idx} []".format(
                var=varname,
                idx=self.indexing[0],
            )
        return (
            "{var} @ {{ {idx} }}list array_nested_get".format(
                var=varname,
                idx=" ".join(str(x) for x in self.indexing),
            )
        )
1248111
def get_variables(self, entity = None):
        
        if not entity:
            return self.variables
        else:
            return {
                variable_name: variable
                for variable_name, variable in self.variables.items()
                # TODO - because entities are copied (see constructor) they can't be compared
                if variable.entity.key == entity.key
                }
1081695
def get_param_name(self):
        
        return "__".join([self.table.name, self.name, self.param_name])
1298374
def var(self, ddof=1):
        
        self._prep_pandas_groupby()
        return DataFrame.fromDataFrameRDD(
            self._regroup_mergedRDD().values().map(
                lambda x: x.var(ddof=ddof)), self.sql_ctx)
24334
def _get_variable_name_or_register(var, variables, names, params, prefix):
    '''
    
    '''
    if var not in variables.values():
        vname = prefix
        if var.data in params:
            vname = params[var.data]
        elif var in names:
            vname = names[var]
        vname = _get_unique_variable_name(vname, variables)
        variables[vname] = var
    else:
        vname = list(variables.keys())[list(variables.values()).index(var)]

    return vname
36589
def compute_metavar(kwargs):
    """"""
    metavar = kwargs.get('metavar')
    if not metavar:
      typ = kwargs.get('type', str)
      if typ == list:
        typ = kwargs.get('member_type', str)

      if typ == dict:
        metavar = '"{\'key1\':val1,\'key2\':val2,...}"'
      else:
        type_name = typ.__name__ if typ != newstr else 'str'  # TODO(#6071): drop special case once Py2 removed
        metavar = '<{}>'.format(type_name)

    return metavar
662730
def get_var_name(self, i):
        
        i = c_int(i)
        name = create_string_buffer(MAXSTRLEN)
        self.library.get_var_name.argtypes = [c_int, c_char_p]
        self.library.get_var_name(i, name)
        return name.value
1116654
def get_scoped_variable_m(self, data_port_id):
        
        for scoped_variable_m in self.scoped_variables:
            if scoped_variable_m.scoped_variable.data_port_id == data_port_id:
                return scoped_variable_m
        return None
865525
def get_var(self, name):
        """"""
        # How many dimensions.
        rank = self.get_var_rank(name)
        # The shape array is fixed size
        shape = np.empty((MAXDIMS, ), dtype='int32', order='F')
        shape = self.get_var_shape(name)
        # there should be nothing here...
        assert sum(shape[rank:]) == 0
        # variable type name
        type_ = self.get_var_type(name)

        is_numpytype = type_ in TYPEMAP

        if is_numpytype:
            # Store the data in this type
            arraytype = ndpointer(dtype=TYPEMAP[type_],
                                  ndim=rank,
                                  shape=shape,
                                  flags='F')
        # '' or b''
        elif not type_:
            raise ValueError('type not found for variable {}'.format(name))
        else:
            arraytype = self.make_compound_ctype(name)
        # Create a pointer to the array type
        data = arraytype()
        # The functions get_var_type/_shape/_rank are already wrapped with
        # python function converter, get_var isn't.
        c_name = create_string_buffer(name)
        get_var = self.library.get_var
        get_var.argtypes = [c_char_p, POINTER(arraytype)]
        get_var.restype = None
        # Get the array
        get_var(c_name, byref(data))
        if not data:
            logger.info("NULL pointer returned")
            return None

        if is_numpytype:
            # for now always a pointer, see python-subgrid for advanced examples
            array = np.ctypeslib.as_array(data)
        else:
            array = structs2pandas(data.contents)

        return array
296626
def get_variable_str(self):
        
        if self.var_name is None:
            prefix = ''
        else:
            prefix = self.var_name

        suffix = str(self.var_value)
        if len(suffix) == 0:
            suffix = "''"
        elif len(suffix) > self.__max_str_length_displayed__:
            suffix = ''

        if len(prefix) > 0 and len(suffix) > 0:
            return prefix + '=' + suffix
        else:
            return prefix + suffix
929407
def check_variable_names(self, ds):
        
        msgs = []
        count = 0

        for k, v in ds.variables.items():
            if 'standard_name' in v.ncattrs():
                count += 1
            else:
                msgs.append("Variable '{}' missing standard_name attr".format(k))

        return Result(BaseCheck.MEDIUM, (count, len(ds.variables)), 'Variable Names', msgs)
561244
def _parse_var_dict(self, var_tbl: dict) -> dict:
        
        var_names = var_tbl.copy()
        # check that all of the variables are bound
        for v in self.var_names:
            if v not in var_tbl:
                if self.var_names[v] is None:
                    raise(KeyError("variable " + v + " is unbound"))
                else:
                    var_names[v] = self.var_names[v]
        # squeeze the variables
        return self._squeeze(var_names)
409557
def get_id(self, name, recurse=True):
        
        self._dlog("getting id '{}'".format(name))
        var = self._search("vars", name, recurse)
        return var