當前位置: 首頁>>代碼示例>>Python>>正文


Python compat.PY36屬性代碼示例

本文整理匯總了Python中pandas.compat.PY36屬性的典型用法代碼示例。如果您正苦於以下問題:Python compat.PY36屬性的具體用法?Python compat.PY36怎麽用?Python compat.PY36使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在pandas.compat的用法示例。


在下文中一共展示了compat.PY36屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: import_module

# 需要導入模塊: from pandas import compat [as 別名]
# 或者: from pandas.compat import PY36 [as 別名]
def import_module(name):
    # we *only* want to skip if the module is truly not available
    # and NOT just an actual import error because of pandas changes

    if PY36:
        try:
            return importlib.import_module(name)
        except ModuleNotFoundError:  # noqa
            pytest.skip("skipping as {} not available".format(name))

    else:
        try:
            return importlib.import_module(name)
        except ImportError as e:
            if "No module named" in str(e) and name in str(e):
                pytest.skip("skipping as {} not available".format(name))
            raise 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:19,代碼來源:test_downstream.py

示例2: test_assign_order

# 需要導入模塊: from pandas import compat [as 別名]
# 或者: from pandas.compat import PY36 [as 別名]
def test_assign_order(self):
        # GH 9818
        df = DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        result = df.assign(D=df.A + df.B, C=df.A - df.B)

        if PY36:
            expected = DataFrame([[1, 2, 3, -1], [3, 4, 7, -1]],
                                 columns=list('ABDC'))
        else:
            expected = DataFrame([[1, 2, -1, 3], [3, 4, -1, 7]],
                                 columns=list('ABCD'))
        assert_frame_equal(result, expected)
        result = df.assign(C=df.A - df.B, D=df.A + df.B)

        expected = DataFrame([[1, 2, -1, 3], [3, 4, -1, 7]],
                             columns=list('ABCD'))

        assert_frame_equal(result, expected) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:20,代碼來源:test_mutate_columns.py

示例3: _is_unorderable_exception

# 需要導入模塊: from pandas import compat [as 別名]
# 或者: from pandas.compat import PY36 [as 別名]
def _is_unorderable_exception(e):
    """
    Check if the exception raised is an unorderable exception.

    The error message differs for 3 <= PY <= 3.5 and PY >= 3.6, so
    we need to condition based on Python version.

    Parameters
    ----------
    e : Exception or sub-class
        The exception object to check.

    Returns
    -------
    boolean : Whether or not the exception raised is an unorderable exception.
    """

    if PY36:
        return "'>' not supported between instances of" in str(e)

    elif PY3:
        return 'unorderable' in str(e)
    return False 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:25,代碼來源:common.py

示例4: test_constructor_dict_order

# 需要導入模塊: from pandas import compat [as 別名]
# 或者: from pandas.compat import PY36 [as 別名]
def test_constructor_dict_order(self):
        # GH19018
        # initialization ordering: by insertion order if python>= 3.6, else
        # order by value
        d = {'b': 1, 'a': 0, 'c': 2}
        result = SparseSeries(d)
        if PY36:
            expected = SparseSeries([1, 0, 2], index=list('bac'))
        else:
            expected = SparseSeries([0, 1, 2], index=list('abc'))
        tm.assert_sp_series_equal(result, expected) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:13,代碼來源:test_series.py

示例5: test_constructor_dict_order

# 需要導入模塊: from pandas import compat [as 別名]
# 或者: from pandas.compat import PY36 [as 別名]
def test_constructor_dict_order(self):
        # GH19018
        # initialization ordering: by insertion order if python>= 3.6, else
        # order by value
        d = {'b': [2, 3], 'a': [0, 1]}
        frame = SparseDataFrame(data=d)
        if compat.PY36:
            expected = SparseDataFrame(data=d, columns=list('ba'))
        else:
            expected = SparseDataFrame(data=d, columns=list('ab'))
        tm.assert_sp_frame_equal(frame, expected) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:13,代碼來源:test_frame.py

示例6: test_constructor_dict_order

# 需要導入模塊: from pandas import compat [as 別名]
# 或者: from pandas.compat import PY36 [as 別名]
def test_constructor_dict_order(self):
        # GH19018
        # initialization ordering: by insertion order if python>= 3.6, else
        # order by value
        d = {'b': 1, 'a': 0, 'c': 2}
        result = Series(d)
        if PY36:
            expected = Series([1, 0, 2], index=list('bac'))
        else:
            expected = Series([0, 1, 2], index=list('abc'))
        tm.assert_series_equal(result, expected) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:13,代碼來源:test_constructors.py

示例7: dict_keys_to_ordered_list

# 需要導入模塊: from pandas import compat [as 別名]
# 或者: from pandas.compat import PY36 [as 別名]
def dict_keys_to_ordered_list(mapping):
    # when pandas drops support for Python < 3.6, this function
    # can be replaced by a simple list(mapping.keys())
    if PY36 or isinstance(mapping, OrderedDict):
        keys = list(mapping.keys())
    else:
        keys = try_sort(mapping)
    return keys 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:10,代碼來源:common.py

示例8: _dict_keys_to_ordered_list

# 需要導入模塊: from pandas import compat [as 別名]
# 或者: from pandas.compat import PY36 [as 別名]
def _dict_keys_to_ordered_list(mapping):
    # when pandas drops support for Python < 3.6, this function
    # can be replaced by a simple list(mapping.keys())
    if PY36 or isinstance(mapping, OrderedDict):
        keys = list(mapping.keys())
    else:
        keys = _try_sort(mapping)
    return keys 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:10,代碼來源:common.py

示例9: test_transactions

# 需要導入模塊: from pandas import compat [as 別名]
# 或者: from pandas.compat import PY36 [as 別名]
def test_transactions(self):
        if PY36:
            pytest.skip("not working on python > 3.5")
        self._transaction_test() 
開發者ID:securityclippy,項目名稱:elasticintel,代碼行數:6,代碼來源:test_sql.py


注:本文中的pandas.compat.PY36屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。