當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。