当前位置: 首页>>代码示例>>Python>>正文


Python common.flatten方法代码示例

本文整理汇总了Python中pandas.core.common.flatten方法的典型用法代码示例。如果您正苦于以下问题:Python common.flatten方法的具体用法?Python common.flatten怎么用?Python common.flatten使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pandas.core.common的用法示例。


在下文中一共展示了common.flatten方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _align

# 需要导入模块: from pandas.core import common [as 别名]
# 或者: from pandas.core.common import flatten [as 别名]
def _align(terms):
    """Align a set of terms"""
    try:
        # flatten the parse tree (a nested list, really)
        terms = list(com.flatten(terms))
    except TypeError:
        # can't iterate so it must just be a constant or single variable
        if isinstance(terms.value, pd.core.generic.NDFrame):
            typ = type(terms.value)
            return typ, _zip_axes_from_type(typ, terms.value.axes)
        return np.result_type(terms.type), None

    # if all resolved variables are numeric scalars
    if all(term.isscalar for term in terms):
        return np.result_type(*(term.value for term in terms)).type, None

    # perform the main alignment
    typ, axes = _align_core(terms)
    return typ, axes 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:21,代码来源:align.py

示例2: get_attr_values

# 需要导入模块: from pandas.core import common [as 别名]
# 或者: from pandas.core.common import flatten [as 别名]
def get_attr_values(self, attrlist):
        """
        Get value corresponding to each given attribute.

        :param str | Iterable[str] attrlist: names of attributes to
            retrieve values for
        :return list | NoneType: value (or empty string) corresponding to
            each named attribute; null if this Sample's value for the
            attribute given by the argument to the "attrlist" parameter is
            empty/null, or if this Sample lacks the indicated attribute
        """
        from pandas.core.common import flatten
        # If attribute is None, then value is also None.
        if not attrlist:
            return None
        if not isinstance(attrlist, list):
            attrlist = [attrlist]
        # Strings contained here are appended later so shouldn't be null.
        return list(flatten([getattr(self, attr, "") for attr in attrlist])) 
开发者ID:pepkit,项目名称:peppy,代码行数:21,代码来源:sample.py

示例3: __init__

# 需要导入模块: from pandas.core import common [as 别名]
# 或者: from pandas.core.common import flatten [as 别名]
def __init__(self, where, queryables=None, encoding=None, scope_level=0):

        where = _validate_where(where)

        self.encoding = encoding
        self.condition = None
        self.filter = None
        self.terms = None
        self._visitor = None

        # capture the environment if needed
        local_dict = DeepChainMap()

        if isinstance(where, Expr):
            local_dict = where.env.scope
            where = where.expr

        elif isinstance(where, (list, tuple)):
            for idx, w in enumerate(where):
                if isinstance(w, Expr):
                    local_dict = w.env.scope
                else:
                    w = _validate_where(w)
                    where[idx] = w
            where = ' & '.join(map('({})'.format, com.flatten(where)))  # noqa

        self.expr = where
        self.env = Scope(scope_level + 1, local_dict=local_dict)

        if queryables is not None and isinstance(self.expr, string_types):
            self.env.queryables.update(queryables)
            self._visitor = ExprVisitor(self.env, queryables=queryables,
                                        parser='pytables', engine='pytables',
                                        encoding=encoding)
            self.terms = self.parse() 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:37,代码来源:pytables.py

示例4: names

# 需要导入模块: from pandas.core import common [as 别名]
# 或者: from pandas.core.common import flatten [as 别名]
def names(self):
        """Get the names in an expression"""
        if is_term(self.terms):
            return frozenset([self.terms.name])
        return frozenset(term.name for term in com.flatten(self.terms)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:expr.py

示例5: return_type

# 需要导入模块: from pandas.core import common [as 别名]
# 或者: from pandas.core.common import flatten [as 别名]
def return_type(self):
        # clobber types to bool if the op is a boolean operator
        if self.op in (_cmp_ops_syms + _bool_ops_syms):
            return np.bool_
        return _result_type_many(*(term.type for term in com.flatten(self))) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:ops.py

示例6: operand_types

# 需要导入模块: from pandas.core import common [as 别名]
# 或者: from pandas.core.common import flatten [as 别名]
def operand_types(self):
        return frozenset(term.type for term in com.flatten(self)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:4,代码来源:ops.py

示例7: __init__

# 需要导入模块: from pandas.core import common [as 别名]
# 或者: from pandas.core.common import flatten [as 别名]
def __init__(self, lhs, rhs, truediv, *args, **kwargs):
        super(Div, self).__init__('/', lhs, rhs, *args, **kwargs)

        if not isnumeric(lhs.return_type) or not isnumeric(rhs.return_type):
            raise TypeError("unsupported operand type(s) for {0}:"
                            " '{1}' and '{2}'".format(self.op,
                                                      lhs.return_type,
                                                      rhs.return_type))

        if truediv or PY3:
            # do not upcast float32s to float64 un-necessarily
            acceptable_dtypes = [np.float32, np.float_]
            _cast_inplace(com.flatten(self), acceptable_dtypes, np.float_) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:15,代码来源:ops.py

示例8: return_type

# 需要导入模块: from pandas.core import common [as 别名]
# 或者: from pandas.core.common import flatten [as 别名]
def return_type(self):
        # clobber types to bool if the op is a boolean operator
        if self.op in (_cmp_ops_syms + _bool_ops_syms):
            return np.bool_
        return np.result_type(*(term.type for term in com.flatten(self))) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:ops.py

示例9: __init__

# 需要导入模块: from pandas.core import common [as 别名]
# 或者: from pandas.core.common import flatten [as 别名]
def __init__(self, lhs, rhs, truediv=True, *args, **kwargs):
        super(Div, self).__init__('/', lhs, rhs, *args, **kwargs)

        if truediv or PY3:
            _cast_inplace(com.flatten(self), np.float_) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:ops.py

示例10: setwrap

# 需要导入模块: from pandas.core import common [as 别名]
# 或者: from pandas.core.common import flatten [as 别名]
def setwrap(value: Any) -> Set[str]:
    """
    Returns a flattened and stringified set from the given object or iterable.

    For use in public functions which accept argmuents or kwargs that can be
    one object or a list of objects.
    """
    return set(map(str, set(flatten([value])))) 
开发者ID:remix,项目名称:partridge,代码行数:10,代码来源:utilities.py


注:本文中的pandas.core.common.flatten方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。