You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In [2]: s1 = pd.Series({'a': 1.5}, name=np.int64(190))
In [3]: s2 = pd.Series([], name=(43, 0))
In [4]: pd.concat([s1, s2])
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-4-5f754290d56c> in <module>()
----> 1 pd.concat([s1, s2])
~/scipy/pandas/pandas/core/reshape/concat.py in concat(objs, axis, join, join_axes, ignore_index, keys, levels, names, verify_integrity, sort, copy)
224 verify_integrity=verify_integrity,
225 copy=copy, sort=sort)
--> 226 return op.get_result()
227
228
~/scipy/pandas/pandas/core/reshape/concat.py in get_result(self)
385 # stack blocks
386 if self.axis == 0:
--> 387 name = com._consensus_name_attr(self.objs)
388
389 mgr = self.objs[0]._data.concat([x._data for x in self.objs],
~/scipy/pandas/pandas/core/common.py in _consensus_name_attr(objs)
56 name = objs[0].name
57 for obj in objs[1:]:
---> 58 if obj.name != name:
59 return None
60 return name
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
It looks maybe a bit of a strange corner case, but you can get both cases rather easily (the one from selecting from Int64Index axis (not default RangeIndex), the other from MultiIndex axis), for example:
In [15]: df1 = pd.DataFrame([[1, 2], [3, 4]], columns=['a', 'b'], index=[0, 1])
In [16]: df2 = pd.DataFrame([[5, 6], [7, 8]], columns=['c', 'd'], index=pd.MultiIndex.from_tuples([(0, 0), (1, 1)]))
In [17]: pd.concat([df1.iloc[0], df2.iloc[0]])
...
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
The reason for the error is that if you compare a tuple and a numpy scalar, it gives an array as result:
It looks maybe a bit of a strange corner case, but you can get both cases rather easily (the one from selecting from Int64Index axis (not default RangeIndex), the other from MultiIndex axis), for example:
The reason for the error is that if you compare a tuple and a numpy scalar, it gives an array as result:
The text was updated successfully, but these errors were encountered: