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


Python common.is_integer方法代码示例

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


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

示例1: test_where_numeric_with_string

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_integer [as 别名]
def test_where_numeric_with_string():
    # GH 9280
    s = pd.Series([1, 2, 3])
    w = s.where(s > 1, 'X')

    assert not is_integer(w[0])
    assert is_integer(w[1])
    assert is_integer(w[2])
    assert isinstance(w[0], str)
    assert w.dtype == 'object'

    w = s.where(s > 1, ['X', 'Y', 'Z'])
    assert not is_integer(w[0])
    assert is_integer(w[1])
    assert is_integer(w[2])
    assert isinstance(w[0], str)
    assert w.dtype == 'object'

    w = s.where(s > 1, np.array(['X', 'Y', 'Z']))
    assert not is_integer(w[0])
    assert is_integer(w[1])
    assert is_integer(w[2])
    assert isinstance(w[0], str)
    assert w.dtype == 'object' 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:26,代码来源:test_boolean.py

示例2: test_where_numeric_with_string

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_integer [as 别名]
def test_where_numeric_with_string(self):
        # GH 9280
        s = pd.Series([1, 2, 3])
        w = s.where(s > 1, 'X')

        assert not is_integer(w[0])
        assert is_integer(w[1])
        assert is_integer(w[2])
        assert isinstance(w[0], str)
        assert w.dtype == 'object'

        w = s.where(s > 1, ['X', 'Y', 'Z'])
        assert not is_integer(w[0])
        assert is_integer(w[1])
        assert is_integer(w[2])
        assert isinstance(w[0], str)
        assert w.dtype == 'object'

        w = s.where(s > 1, np.array(['X', 'Y', 'Z']))
        assert not is_integer(w[0])
        assert is_integer(w[1])
        assert is_integer(w[2])
        assert isinstance(w[0], str)
        assert w.dtype == 'object' 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:26,代码来源:test_indexing.py

示例3: validate_argsort_with_ascending

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_integer [as 别名]
def validate_argsort_with_ascending(ascending, args, kwargs):
    """
    If 'Categorical.argsort' is called via the 'numpy' library, the
    first parameter in its signature is 'axis', which takes either
    an integer or 'None', so check if the 'ascending' parameter has
    either integer type or is None, since 'ascending' itself should
    be a boolean
    """

    if is_integer(ascending) or ascending is None:
        args = (ascending,) + args
        ascending = True

    validate_argsort_kind(args, kwargs, max_fname_arg_count=3)
    return ascending 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:17,代码来源:function.py

示例4: test_float_subtype

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_integer [as 别名]
def test_float_subtype(self, start, end, freq):
        # Has float subtype if any of start/end/freq are float, even if all
        # resulting endpoints can safely be upcast to integers

        # defined from start/end/freq
        index = interval_range(start=start, end=end, freq=freq)
        result = index.dtype.subtype
        expected = 'int64' if is_integer(start + end + freq) else 'float64'
        assert result == expected

        # defined from start/periods/freq
        index = interval_range(start=start, periods=5, freq=freq)
        result = index.dtype.subtype
        expected = 'int64' if is_integer(start + freq) else 'float64'
        assert result == expected

        # defined from end/periods/freq
        index = interval_range(end=end, periods=5, freq=freq)
        result = index.dtype.subtype
        expected = 'int64' if is_integer(end + freq) else 'float64'
        assert result == expected

        # GH 20976: linspace behavior defined from start/end/periods
        index = interval_range(start=start, end=end, periods=5)
        result = index.dtype.subtype
        expected = 'int64' if is_integer(start + end) else 'float64'
        assert result == expected 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:29,代码来源:test_interval_range.py

示例5: test_quantile_interpolation_dtype

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_integer [as 别名]
def test_quantile_interpolation_dtype(self):
        # GH #10174

        # interpolation = linear (default case)
        q = pd.Series([1, 3, 4]).quantile(0.5, interpolation='lower')
        assert q == np.percentile(np.array([1, 3, 4]), 50)
        assert is_integer(q)

        q = pd.Series([1, 3, 4]).quantile(0.5, interpolation='higher')
        assert q == np.percentile(np.array([1, 3, 4]), 50)
        assert is_integer(q) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:13,代码来源:test_quantile.py

示例6: test_single_element_ix_dont_upcast

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_integer [as 别名]
def test_single_element_ix_dont_upcast(self):
        self.frame['E'] = 1
        assert issubclass(self.frame['E'].dtype.type, (int, np.integer))

        with catch_warnings(record=True):
            simplefilter("ignore", DeprecationWarning)
            result = self.frame.ix[self.frame.index[5], 'E']
            assert is_integer(result)

        result = self.frame.loc[self.frame.index[5], 'E']
        assert is_integer(result)

        # GH 11617
        df = pd.DataFrame(dict(a=[1.23]))
        df["b"] = 666

        with catch_warnings(record=True):
            simplefilter("ignore", DeprecationWarning)
            result = df.ix[0, "b"]
        assert is_integer(result)
        result = df.loc[0, "b"]
        assert is_integer(result)

        expected = Series([666], [0], name='b')
        with catch_warnings(record=True):
            simplefilter("ignore", DeprecationWarning)
            result = df.ix[[0], "b"]
        assert_series_equal(result, expected)
        result = df.loc[[0], "b"]
        assert_series_equal(result, expected) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:32,代码来源:test_indexing.py

示例7: _random_state

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_integer [as 别名]
def _random_state(state=None):
    """
    Helper function for processing random_state arguments.

    Parameters
    ----------
    state : int, np.random.RandomState, None.
        If receives an int, passes to np.random.RandomState() as seed.
        If receives an np.random.RandomState object, just returns object.
        If receives `None`, returns np.random.
        If receives anything else, raises an informative ValueError.
        Default None.

    Returns
    -------
    np.random.RandomState
    """

    if is_integer(state):
        return np.random.RandomState(state)
    elif isinstance(state, np.random.RandomState):
        return state
    elif state is None:
        return np.random
    else:
        raise ValueError("random_state must be an integer, a numpy "
                         "RandomState, or None") 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:29,代码来源:common.py

示例8: is_integer_slice

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_integer [as 别名]
def is_integer_slice(x):
    if not is_slice(x):
        return False
    for pos in [x.start, x.stop, x.step]:
        if not ((pos is None) or is_integer(pos)):
            return False  # one position is neither None nor int
    return True 
开发者ID:modin-project,项目名称:modin,代码行数:9,代码来源:indexing.py

示例9: _check_dtypes

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_integer [as 别名]
def _check_dtypes(self, locator):
        is_int = is_integer(locator)
        is_int_slice = is_integer_slice(locator)
        is_int_list = is_list_like(locator) and all(map(is_integer, locator))
        is_bool_arr = is_boolean_array(locator)

        if not any([is_int, is_int_slice, is_int_list, is_bool_arr]):
            raise ValueError(_ILOC_INT_ONLY_ERROR) 
开发者ID:modin-project,项目名称:modin,代码行数:10,代码来源:indexing.py


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