当前位置: 首页>>代码示例>>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;未经允许,请勿转载。