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


Python errors.UnsupportedFunctionCall方法代碼示例

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


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

示例1: validate_groupby_func

# 需要導入模塊: from pandas import errors [as 別名]
# 或者: from pandas.errors import UnsupportedFunctionCall [as 別名]
def validate_groupby_func(name, args, kwargs, allowed=None):
    """
    'args' and 'kwargs' should be empty, except for allowed
    kwargs because all of
    their necessary parameters are explicitly listed in
    the function signature
    """
    if allowed is None:
        allowed = []

    kwargs = set(kwargs) - set(allowed)

    if len(args) + len(kwargs) > 0:
        raise UnsupportedFunctionCall((
            "numpy operations are not valid "
            "with groupby. Use .groupby(...)."
            "{func}() instead".format(func=name))) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:19,代碼來源:function.py

示例2: test_numpy_compat

# 需要導入模塊: from pandas import errors [as 別名]
# 或者: from pandas.errors import UnsupportedFunctionCall [as 別名]
def test_numpy_compat(self, method):
        # see gh-12811
        e = rwindow.EWM(Series([2, 4, 6]), alpha=0.5)

        msg = "numpy operations are not valid with window objects"

        with pytest.raises(UnsupportedFunctionCall, match=msg):
            getattr(e, method)(1, 2, 3)
        with pytest.raises(UnsupportedFunctionCall, match=msg):
            getattr(e, method)(dtype=np.float64)


# gh-12373 : rolling functions error on float32 data
# make sure rolling functions works for different dtypes
#
# NOTE that these are yielded tests and so _create_data
# is explicitly called.
#
# further note that we are only checking rolling for fully dtype
# compliance (though both expanding and ewm inherit) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:22,代碼來源:test_window.py

示例3: test_numpy_compat

# 需要導入模塊: from pandas import errors [as 別名]
# 或者: from pandas.errors import UnsupportedFunctionCall [as 別名]
def test_numpy_compat(self, method):
        # see gh-12811
        e = rwindow.EWM(Series([2, 4, 6]), alpha=0.5)

        msg = "numpy operations are not valid with window objects"

        tm.assert_raises_regex(UnsupportedFunctionCall, msg,
                               getattr(e, method), 1, 2, 3)
        tm.assert_raises_regex(UnsupportedFunctionCall, msg,
                               getattr(e, method), dtype=np.float64)


# gh-12373 : rolling functions error on float32 data
# make sure rolling functions works for different dtypes
#
# NOTE that these are yielded tests and so _create_data
# is explicitly called.
#
# further note that we are only checking rolling for fully dtype
# compliance (though both expanding and ewm inherit) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:22,代碼來源:test_window.py

示例4: validate_window_func

# 需要導入模塊: from pandas import errors [as 別名]
# 或者: from pandas.errors import UnsupportedFunctionCall [as 別名]
def validate_window_func(name, args, kwargs):
    numpy_args = ('axis', 'dtype', 'out')
    msg = ("numpy operations are not "
           "valid with window objects. "
           "Use .{func}() directly instead ".format(func=name))

    if len(args) > 0:
        raise UnsupportedFunctionCall(msg)

    for arg in numpy_args:
        if arg in kwargs:
            raise UnsupportedFunctionCall(msg) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:14,代碼來源:function.py

示例5: validate_rolling_func

# 需要導入模塊: from pandas import errors [as 別名]
# 或者: from pandas.errors import UnsupportedFunctionCall [as 別名]
def validate_rolling_func(name, args, kwargs):
    numpy_args = ('axis', 'dtype', 'out')
    msg = ("numpy operations are not "
           "valid with window objects. "
           "Use .rolling(...).{func}() instead ".format(func=name))

    if len(args) > 0:
        raise UnsupportedFunctionCall(msg)

    for arg in numpy_args:
        if arg in kwargs:
            raise UnsupportedFunctionCall(msg) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:14,代碼來源:function.py

示例6: validate_expanding_func

# 需要導入模塊: from pandas import errors [as 別名]
# 或者: from pandas.errors import UnsupportedFunctionCall [as 別名]
def validate_expanding_func(name, args, kwargs):
    numpy_args = ('axis', 'dtype', 'out')
    msg = ("numpy operations are not "
           "valid with window objects. "
           "Use .expanding(...).{func}() instead ".format(func=name))

    if len(args) > 0:
        raise UnsupportedFunctionCall(msg)

    for arg in numpy_args:
        if arg in kwargs:
            raise UnsupportedFunctionCall(msg) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:14,代碼來源:function.py

示例7: validate_resampler_func

# 需要導入模塊: from pandas import errors [as 別名]
# 或者: from pandas.errors import UnsupportedFunctionCall [as 別名]
def validate_resampler_func(method, args, kwargs):
    """
    'args' and 'kwargs' should be empty because all of
    their necessary parameters are explicitly listed in
    the function signature
    """
    if len(args) + len(kwargs) > 0:
        if method in RESAMPLER_NUMPY_OPS:
            raise UnsupportedFunctionCall((
                "numpy operations are not valid "
                "with resample. Use .resample(...)."
                "{func}() instead".format(func=method)))
        else:
            raise TypeError("too many arguments passed in") 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:16,代碼來源:function.py

示例8: test_numpy_compat

# 需要導入模塊: from pandas import errors [as 別名]
# 或者: from pandas.errors import UnsupportedFunctionCall [as 別名]
def test_numpy_compat(func):
    # see gh-12811
    df = pd.DataFrame({'A': [1, 2, 1], 'B': [1, 2, 3]})
    g = df.groupby('A')

    msg = "numpy operations are not valid with groupby"

    with pytest.raises(UnsupportedFunctionCall, match=msg):
        getattr(g, func)(1, 2, 3)
    with pytest.raises(UnsupportedFunctionCall, match=msg):
        getattr(g, func)(foo=1) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:13,代碼來源:test_function.py

示例9: test_numpy_compat

# 需要導入模塊: from pandas import errors [as 別名]
# 或者: from pandas.errors import UnsupportedFunctionCall [as 別名]
def test_numpy_compat(func):
    # see gh-12811
    s = Series([1, 2, 3, 4, 5], index=date_range(
        '20130101', periods=5, freq='s'))
    r = s.resample('2s')

    msg = "numpy operations are not valid with resample"

    with pytest.raises(UnsupportedFunctionCall, match=msg):
        getattr(r, func)(func, 1, 2, 3)
    with pytest.raises(UnsupportedFunctionCall, match=msg):
        getattr(r, func)(axis=1) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:14,代碼來源:test_datetime_index.py

示例10: test_numpy_compat

# 需要導入模塊: from pandas import errors [as 別名]
# 或者: from pandas.errors import UnsupportedFunctionCall [as 別名]
def test_numpy_compat(self):
        # see gh-12811
        s = Series([1, 2, 3, 4, 5], index=date_range(
            '20130101', periods=5, freq='s'))
        r = s.resample('2s')

        msg = "numpy operations are not valid with resample"

        for func in ('min', 'max', 'sum', 'prod',
                     'mean', 'var', 'std'):
            tm.assert_raises_regex(UnsupportedFunctionCall, msg,
                                   getattr(r, func),
                                   func, 1, 2, 3)
            tm.assert_raises_regex(UnsupportedFunctionCall, msg,
                                   getattr(r, func), axis=1) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:17,代碼來源:test_resample.py

示例11: test_numpy_compat

# 需要導入模塊: from pandas import errors [as 別名]
# 或者: from pandas.errors import UnsupportedFunctionCall [as 別名]
def test_numpy_compat():
    # see gh-12811
    df = pd.DataFrame({'A': [1, 2, 1], 'B': [1, 2, 3]})
    g = df.groupby('A')

    msg = "numpy operations are not valid with groupby"

    for func in ('mean', 'var', 'std', 'cumprod', 'cumsum'):
        tm.assert_raises_regex(UnsupportedFunctionCall, msg,
                               getattr(g, func), 1, 2, 3)
        tm.assert_raises_regex(UnsupportedFunctionCall, msg,
                               getattr(g, func), foo=1) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:14,代碼來源:test_function.py


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