Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Pandas Series: unexpected error while doing difference (_maybe_match_name) #22041

Closed
@pietrotortella

Description

@pietrotortella

pandas version is 0.22.0, numpy version is 1.14.0

While performing the following:

a = pd.Series([1, 2, 3])
a.name = np.int64(123)

b = pd.Series([4, 5, 6])
b.name = (123, 789)

a - b

I obtain the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-63-e4efbf202d3c> in <module>()
----> 1 one - two

~/venv/lib/python3.4/site-packages/pandas/core/ops.py in wrapper(left, right, name, na_op)
    727 
    728         if isinstance(rvalues, ABCSeries):
--> 729             name = _maybe_match_name(left, rvalues)
    730             lvalues = getattr(lvalues, 'values', lvalues)
    731             rvalues = getattr(rvalues, 'values', rvalues)

~/venv/lib/python3.4/site-packages/pandas/core/common.py in _maybe_match_name(a, b)
    137     b_has = hasattr(b, 'name')
    138     if a_has and b_has:
--> 139         if a.name == b.name:
    140             return a.name
    141         else:

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNumeric OperationsArithmetic, Comparison, and Logical operations

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions