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


Python lib.is_bool_array方法代码示例

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


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

示例1: is_bool_indexer

# 需要导入模块: from pandas._libs import lib [as 别名]
# 或者: from pandas._libs.lib import is_bool_array [as 别名]
def is_bool_indexer(key):
    if isinstance(key, (ABCSeries, np.ndarray, ABCIndex)):
        if key.dtype == np.object_:
            key = np.asarray(_values_from_object(key))

            if not lib.is_bool_array(key):
                if isna(key).any():
                    raise ValueError('cannot index with vector containing '
                                     'NA / NaN values')
                return False
            return True
        elif key.dtype == np.bool_:
            return True
    elif isinstance(key, list):
        try:
            arr = np.asarray(key)
            return arr.dtype == np.bool_ and len(arr) == len(key)
        except TypeError:  # pragma: no cover
            return False

    return False 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:23,代码来源:common.py

示例2: is_bool

# 需要导入模块: from pandas._libs import lib [as 别名]
# 或者: from pandas._libs.lib import is_bool_array [as 别名]
def is_bool(self):
        """ we can be a bool if we have only bool values but are of type
        object
        """
        return lib.is_bool_array(self.values.ravel())

    # TODO: Refactor when convert_objects is removed since there will be 1 path 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:9,代码来源:blocks.py

示例3: is_bool_indexer

# 需要导入模块: from pandas._libs import lib [as 别名]
# 或者: from pandas._libs.lib import is_bool_array [as 别名]
def is_bool_indexer(key):
    # type: (Any) -> bool
    """
    Check whether `key` is a valid boolean indexer.

    Parameters
    ----------
    key : Any
        Only list-likes may be considered boolean indexers.
        All other types are not considered a boolean indexer.
        For array-like input, boolean ndarrays or ExtensionArrays
        with ``_is_boolean`` set are considered boolean indexers.

    Returns
    -------
    bool

    Raises
    ------
    ValueError
        When the array is an object-dtype ndarray or ExtensionArray
        and contains missing values.
    """
    na_msg = 'cannot index with vector containing NA / NaN values'
    if (isinstance(key, (ABCSeries, np.ndarray, ABCIndex)) or
            (is_array_like(key) and is_extension_array_dtype(key.dtype))):
        if key.dtype == np.object_:
            key = np.asarray(values_from_object(key))

            if not lib.is_bool_array(key):
                if isna(key).any():
                    raise ValueError(na_msg)
                return False
            return True
        elif is_bool_dtype(key.dtype):
            # an ndarray with bool-dtype by definition has no missing values.
            # So we only need to check for NAs in ExtensionArrays
            if is_extension_array_dtype(key.dtype):
                if np.any(key.isna()):
                    raise ValueError(na_msg)
            return True
    elif isinstance(key, list):
        try:
            arr = np.asarray(key)
            return arr.dtype == np.bool_ and len(arr) == len(key)
        except TypeError:  # pragma: no cover
            return False

    return False 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:51,代码来源:common.py


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