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


Python common.is_bool方法代码示例

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


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

示例1: validate_ordered

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_bool [as 别名]
def validate_ordered(ordered):
        """
        Validates that we have a valid ordered parameter. If
        it is not a boolean, a TypeError will be raised.

        Parameters
        ----------
        ordered : object
            The parameter to be verified.

        Raises
        ------
        TypeError
            If 'ordered' is not a boolean.
        """
        from pandas.core.dtypes.common import is_bool
        if not is_bool(ordered):
            raise TypeError("'ordered' must either be 'True' or 'False'") 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:dtypes.py

示例2: _validate_ordered

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_bool [as 别名]
def _validate_ordered(ordered):
        """
        Validates that we have a valid ordered parameter. If
        it is not a boolean, a TypeError will be raised.

        Parameters
        ----------
        ordered : object
            The parameter to be verified.

        Raises
        ------
        TypeError
            If 'ordered' is not a boolean.
        """
        from pandas.core.dtypes.common import is_bool
        if not is_bool(ordered):
            raise TypeError("'ordered' must either be 'True' or 'False'") 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:20,代码来源:dtypes.py

示例3: validate_cum_func_with_skipna

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_bool [as 别名]
def validate_cum_func_with_skipna(skipna, args, kwargs, name):
    """
    If this function is called via the 'numpy' library, the third
    parameter in its signature is 'dtype', which takes either a
    'numpy' dtype or 'None', so check if the 'skipna' parameter is
    a boolean or not
    """
    if not is_bool(skipna):
        args = (skipna,) + args
        skipna = True

    validate_cum_func(args, kwargs, fname=name)
    return skipna 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:15,代码来源:function.py

示例4: test_identical

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_bool [as 别名]
def test_identical(self):
        # see gh-10546
        x = 1
        result = pd.eval('x', engine=self.engine, parser=self.parser)
        assert result == 1
        assert is_scalar(result)

        x = 1.5
        result = pd.eval('x', engine=self.engine, parser=self.parser)
        assert result == 1.5
        assert is_scalar(result)

        x = False
        result = pd.eval('x', engine=self.engine, parser=self.parser)
        assert not result
        assert is_bool(result)
        assert is_scalar(result)

        x = np.array([1])
        result = pd.eval('x', engine=self.engine, parser=self.parser)
        tm.assert_numpy_array_equal(result, np.array([1]))
        assert result.shape == (1, )

        x = np.array([1.5])
        result = pd.eval('x', engine=self.engine, parser=self.parser)
        tm.assert_numpy_array_equal(result, np.array([1.5]))
        assert result.shape == (1, )

        x = np.array([False])  # noqa
        result = pd.eval('x', engine=self.engine, parser=self.parser)
        tm.assert_numpy_array_equal(result, np.array([False]))
        assert result.shape == (1, ) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:34,代码来源:test_eval.py

示例5: _check_for_default_values

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_bool [as 别名]
def _check_for_default_values(fname, arg_val_dict, compat_args):
    """
    Check that the keys in `arg_val_dict` are mapped to their
    default values as specified in `compat_args`.

    Note that this function is to be called only when it has been
    checked that arg_val_dict.keys() is a subset of compat_args

    """
    for key in arg_val_dict:
        # try checking equality directly with '=' operator,
        # as comparison may have been overridden for the left
        # hand object
        try:
            v1 = arg_val_dict[key]
            v2 = compat_args[key]

            # check for None-ness otherwise we could end up
            # comparing a numpy array vs None
            if (v1 is not None and v2 is None) or \
               (v1 is None and v2 is not None):
                match = False
            else:
                match = (v1 == v2)

            if not is_bool(match):
                raise ValueError("'match' is not a boolean")

        # could not compare them directly, so try comparison
        # using the 'is' operator
        except ValueError:
            match = (arg_val_dict[key] is compat_args[key])

        if not match:
            raise ValueError(("the '{arg}' parameter is not "
                              "supported in the pandas "
                              "implementation of {fname}()".
                              format(fname=fname, arg=key))) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:40,代码来源:_validators.py

示例6: validate_bool_kwarg

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_bool [as 别名]
def validate_bool_kwarg(value, arg_name):
    """ Ensures that argument passed in arg_name is of type bool. """
    if not (is_bool(value) or value is None):
        raise ValueError('For argument "{arg}" expected type bool, received '
                         'type {typ}.'.format(arg=arg_name,
                                              typ=type(value).__name__))
    return value 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:9,代码来源:_validators.py

示例7: _check_for_default_values

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_bool [as 别名]
def _check_for_default_values(fname, arg_val_dict, compat_args):
    """
    Check that the keys in `arg_val_dict` are mapped to their
    default values as specified in `compat_args`.

    Note that this function is to be called only when it has been
    checked that arg_val_dict.keys() is a subset of compat_args

    """
    for key in arg_val_dict:
        # try checking equality directly with '=' operator,
        # as comparison may have been overridden for the left
        # hand object
        try:
            v1 = arg_val_dict[key]
            v2 = compat_args[key]

            # check for None-ness otherwise we could end up
            # comparing a numpy array vs None
            if (v1 is not None and v2 is None) or \
               (v1 is None and v2 is not None):
                match = False
            else:
                match = (v1 == v2)

            if not is_bool(match):
                raise ValueError("'match' is not a boolean")

        # could not compare them directly, so try comparison
        # using the 'is' operator
        except:
            match = (arg_val_dict[key] is compat_args[key])

        if not match:
            raise ValueError(("the '{arg}' parameter is not "
                              "supported in the pandas "
                              "implementation of {fname}()".
                              format(fname=fname, arg=key))) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:40,代码来源:_validators.py

示例8: _check_for_default_values

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_bool [as 别名]
def _check_for_default_values(fname, arg_val_dict, compat_args):
    """
    Check that the keys in `arg_val_dict` are mapped to their
    default values as specified in `compat_args`.

    Note that this function is to be called only when it has been
    checked that arg_val_dict.keys() is a subset of compat_args

    """
    for key in arg_val_dict:
        # try checking equality directly with '=' operator,
        # as comparison may have been overriden for the left
        # hand object
        try:
            v1 = arg_val_dict[key]
            v2 = compat_args[key]

            # check for None-ness otherwise we could end up
            # comparing a numpy array vs None
            if (v1 is not None and v2 is None) or \
               (v1 is None and v2 is not None):
                match = False
            else:
                match = (v1 == v2)

            if not is_bool(match):
                raise ValueError("'match' is not a boolean")

        # could not compare them directly, so try comparison
        # using the 'is' operator
        except:
            match = (arg_val_dict[key] is compat_args[key])

        if not match:
            raise ValueError(("the '{arg}' parameter is not "
                              "supported in the pandas "
                              "implementation of {fname}()".
                              format(fname=fname, arg=key))) 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:40,代码来源:_validators.py


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