question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Local test failure pandas.tests.frame.test_analytics

See original GitHub issue

Running

pytest -q --cache-clear pandas/tests/frame/test_analytics.py

Yield the following error:

___________________________ TestDataFrameAnalytics.test_mean_mixed_string_decimal ____________________________
TypeError: unsupported operand type(s) for +: 'int' and 'str'

The above exception was the direct cause of the following exception:

self = Decimal('3351.00'), other = Decimal('572.00'), context = None

    def __add__(self, other, context=None):
        """Returns self + other.
    
        -INF + INF (or the reverse) cause InvalidOperation errors.
        """
>       other = _convert_other(other)

/usr/lib/python3.8/_pydecimal.py:1158: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

other = Decimal('572.00'), raiseit = False, allow_float = False

    def _convert_other(other, raiseit=False, allow_float=False):
        """Convert other to Decimal.
    
        Verifies that it's ok to use in an implicit construction.
        If allow_float is true, allow conversion from float;  this
        is used in the comparison methods (__eq__ and friends).
    
        """
>       if isinstance(other, Decimal):
E       SystemError: <built-in function isinstance> returned a result with an error set

/usr/lib/python3.8/_pydecimal.py:6017: SystemError

The above exception was the direct cause of the following exception:

self = Decimal('3351.00'), other = Decimal('609.00'), context = None

    def __add__(self, other, context=None):
        """Returns self + other.
    
        -INF + INF (or the reverse) cause InvalidOperation errors.
        """
>       other = _convert_other(other)

/usr/lib/python3.8/_pydecimal.py:1158: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

other = Decimal('609.00'), raiseit = False, allow_float = False

    def _convert_other(other, raiseit=False, allow_float=False):
        """Convert other to Decimal.
    
        Verifies that it's ok to use in an implicit construction.
        If allow_float is true, allow conversion from float;  this
        is used in the comparison methods (__eq__ and friends).
    
        """
>       if isinstance(other, Decimal):
E       SystemError: <built-in function isinstance> returned a result with an error set

/usr/lib/python3.8/_pydecimal.py:6017: SystemError

The above exception was the direct cause of the following exception:

self = Decimal('3351.00'), other = Decimal('820.00'), context = None

    def __add__(self, other, context=None):
        """Returns self + other.
    
        -INF + INF (or the reverse) cause InvalidOperation errors.
        """
>       other = _convert_other(other)

/usr/lib/python3.8/_pydecimal.py:1158: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

other = Decimal('820.00'), raiseit = False, allow_float = False

    def _convert_other(other, raiseit=False, allow_float=False):
        """Convert other to Decimal.
    
        Verifies that it's ok to use in an implicit construction.
        If allow_float is true, allow conversion from float;  this
        is used in the comparison methods (__eq__ and friends).
    
        """
>       if isinstance(other, Decimal):
E       SystemError: <built-in function isinstance> returned a result with an error set

/usr/lib/python3.8/_pydecimal.py:6017: SystemError

The above exception was the direct cause of the following exception:

self = <pandas.tests.frame.test_analytics.TestDataFrameAnalytics object at 0x612b1fcb3700>

    def test_mean_mixed_string_decimal(self):
        # GH 11670
        # possible bug when calculating mean of DataFrame?
    
        d = [
            {"A": 2, "B": None, "C": Decimal("628.00")},
            {"A": 1, "B": None, "C": Decimal("383.00")},
            {"A": 3, "B": None, "C": Decimal("651.00")},
            {"A": 2, "B": None, "C": Decimal("575.00")},
            {"A": 4, "B": None, "C": Decimal("1114.00")},
            {"A": 1, "B": "TEST", "C": Decimal("241.00")},
            {"A": 2, "B": None, "C": Decimal("572.00")},
            {"A": 4, "B": None, "C": Decimal("609.00")},
            {"A": 3, "B": None, "C": Decimal("820.00")},
            {"A": 5, "B": None, "C": Decimal("1223.00")},
        ]
    
        df = pd.DataFrame(d)
    
>       result = df.mean()

pandas/tests/frame/test_analytics.py:499: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pandas/core/generic.py:11039: in stat_func
    return self._reduce(
pandas/core/frame.py:7876: in _reduce
    result = f(values)
pandas/core/frame.py:7828: in f
    return op(x, axis=axis, skipna=skipna, **kwds)
pandas/core/nanops.py:127: in f
    result = alt(values, axis=axis, skipna=skipna, **kwds)
pandas/core/nanops.py:560: in nanmean
    the_sum = _ensure_numeric(values.sum(axis, dtype=dtype_sum))
../../Venvs/venv-pandas/lib/python3.8/site-packages/numpy/core/_methods.py:38: in _sum
    return umr_sum(a, axis, dtype, out, keepdims, initial, where)
/usr/lib/python3.8/_pydecimal.py:1158: in __add__
    other = _convert_other(other)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

other = Decimal('1223.00'), raiseit = False, allow_float = False

    def _convert_other(other, raiseit=False, allow_float=False):
        """Convert other to Decimal.
    
        Verifies that it's ok to use in an implicit construction.
        If allow_float is true, allow conversion from float;  this
        is used in the comparison methods (__eq__ and friends).
    
        """
>       if isinstance(other, Decimal):
E       SystemError: <built-in function isinstance> returned a result with an error set

/usr/lib/python3.8/_pydecimal.py:6017: SystemError
1 failed, 90 passed, 1 xfailed in 1.89s

Output of pd.show_versions():

INSTALLED VERSIONS

commit : f6b3e82b5514da97b48918c99bd28a07b754291b python : 3.8.1.final.0 python-bits : 64 OS : Linux OS-release : 5.4.23.a-1-hardened Version : #1 SMP PREEMPT Sun, 01 Mar 2020 18:23:23 +0000 machine : x86_64 processor : byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8

pandas : 1.1.0.dev0+696.gf6b3e82b5 numpy : 1.18.1 pytz : 2019.3 dateutil : 2.8.1 pip : 20.0.2 setuptools : 45.2.0 Cython : 0.29.15 pytest : 5.3.5 hypothesis : 5.6.0 sphinx : 2.4.4 blosc : 1.8.3 feather : None xlsxwriter : 1.2.8 lxml.etree : 4.5.0 html5lib : 1.0.1 pymysql : None psycopg2 : None jinja2 : 2.11.1 IPython : 7.13.0 pandas_datareader: None bs4 : 4.8.2 bottleneck : 1.3.2 fastparquet : 0.3.3 gcsfs : None matplotlib : 3.2.0 numexpr : 2.7.1 odfpy : None openpyxl : 3.0.1 pandas_gbq : None pyarrow : 0.16.0 pytables : None pyxlsb : None s3fs : 0.4.0 scipy : 1.4.1 sqlalchemy : 1.3.13 tables : 3.6.1 tabulate : 0.8.6 xarray : 0.15.0 xlrd : 1.2.0 xlwt : 1.3.0 numba : 0.48.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
ShaharNavehcommented, Mar 6, 2020

I ran the following before posting this issue

python setup.py clean --all
python setup.py build_ext --inplace -j 0
0reactions
mroeschkecommented, Jul 29, 2021

Happy to reopen if this issue if this still persists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pandas Test Failure - python - Stack Overflow
After installing Python 3.6.2 and Pandas on Windows 10 64-bit I ran the test described here. The failures seem to be largely linked...
Read more >
Testing Pandas Code - MungingData
This post explains how to test Pandas code with the built-in test helper methods and with the beavis functions that give more readable...
Read more >
Contributing to the code base — pandas 1.5.2 documentation
During Continuous Integration testing, several tools will be run to check your code for stylistic errors. Generating any warnings will cause the test...
Read more >
Suggestion: remove tests from the distribution · Issue #30741
Would it make sense to remove tests folder from the pandas distribution? It takes roughly 33% of the whole package weight.
Read more >
How to Write Unit Tests and Mock with Pandas - Coderbook
The test suite of a project might need to be executed on a number of different places. You might execute it locally to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found