Python pandas.errors.UnsupportedFunctionCall() Examples

The following are 30 code examples of pandas.errors.UnsupportedFunctionCall(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pandas.errors , or try the search function .
Example #1
Source File: function.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
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))) 
Example #2
Source File: function.py    From Splunking-Crime with GNU Affero General Public License v3.0 6 votes vote down vote up
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))) 
Example #3
Source File: function.py    From recruit with Apache License 2.0 6 votes vote down vote up
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))) 
Example #4
Source File: test_window.py    From twitter-stock-recommendation with MIT License 6 votes vote down vote up
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) 
Example #5
Source File: function.py    From coffeegrindsize with MIT License 6 votes vote down vote up
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))) 
Example #6
Source File: test_window.py    From recruit with Apache License 2.0 6 votes vote down vote up
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) 
Example #7
Source File: function.py    From elasticintel with GNU General Public License v3.0 6 votes vote down vote up
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))) 
Example #8
Source File: function.py    From twitter-stock-recommendation with MIT License 6 votes vote down vote up
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))) 
Example #9
Source File: test_window.py    From vnpy_crypto with MIT License 6 votes vote down vote up
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) 
Example #10
Source File: test_window.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
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) 
Example #11
Source File: function.py    From vnpy_crypto with MIT License 6 votes vote down vote up
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))) 
Example #12
Source File: test_window.py    From coffeegrindsize with MIT License 6 votes vote down vote up
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) 
Example #13
Source File: test_window.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_numpy_compat(self, method):
        # see gh-12811
        r = rwindow.Rolling(Series([2, 4, 6]), window=2)

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

        tm.assert_raises_regex(UnsupportedFunctionCall, msg,
                               getattr(r, method), 1, 2, 3)
        tm.assert_raises_regex(UnsupportedFunctionCall, msg,
                               getattr(r, method), dtype=np.float64) 
Example #14
Source File: function.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
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) 
Example #15
Source File: test_function.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
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) 
Example #16
Source File: test_resample.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
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) 
Example #17
Source File: test_window.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_numpy_compat(self, method):
        # see gh-12811
        e = rwindow.Expanding(Series([2, 4, 6]), window=2)

        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) 
Example #18
Source File: function.py    From coffeegrindsize with MIT License 5 votes vote down vote up
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) 
Example #19
Source File: function.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
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") 
Example #20
Source File: function.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
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) 
Example #21
Source File: function.py    From coffeegrindsize with MIT License 5 votes vote down vote up
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") 
Example #22
Source File: test_groupby.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def test_numpy_compat(self):
        # 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) 
Example #23
Source File: test_resample.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #24
Source File: test_window.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def test_numpy_compat(self):
        # see gh-12811
        e = rwindow.EWM(Series([2, 4, 6]), alpha=0.5)

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

        for func in ('std', 'mean', 'var'):
            tm.assert_raises_regex(UnsupportedFunctionCall, msg,
                                   getattr(e, func), 1, 2, 3)
            tm.assert_raises_regex(UnsupportedFunctionCall, msg,
                                   getattr(e, func), dtype=np.float64) 
Example #25
Source File: test_window.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def test_numpy_compat(self):
        # see gh-12811
        e = rwindow.Expanding(Series([2, 4, 6]), window=2)

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

        for func in ('std', 'mean', 'sum', 'max', 'min', 'var'):
            tm.assert_raises_regex(UnsupportedFunctionCall, msg,
                                   getattr(e, func), 1, 2, 3)
            tm.assert_raises_regex(UnsupportedFunctionCall, msg,
                                   getattr(e, func), dtype=np.float64) 
Example #26
Source File: test_window.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def test_numpy_compat(self):
        # see gh-12811
        r = rwindow.Rolling(Series([2, 4, 6]), window=2)

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

        for func in ('std', 'mean', 'sum', 'max', 'min', 'var'):
            tm.assert_raises_regex(UnsupportedFunctionCall, msg,
                                   getattr(r, func), 1, 2, 3)
            tm.assert_raises_regex(UnsupportedFunctionCall, msg,
                                   getattr(r, func), dtype=np.float64) 
Example #27
Source File: function.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
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") 
Example #28
Source File: function.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #29
Source File: function.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #30
Source File: function.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
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)