Skip to content

Commit f61deb9

Browse files
christopherzimmermanWillAyd
authored andcommitted
BUG: Fix Series.append raises TypeError with tuple of Series (#28412)
1 parent eb8cce0 commit f61deb9

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

doc/source/whatsnew/v1.0.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ Other
240240
- Trying to set the ``display.precision``, ``display.max_rows`` or ``display.max_columns`` using :meth:`set_option` to anything but a ``None`` or a positive int will raise a ``ValueError`` (:issue:`23348`)
241241
- Using :meth:`DataFrame.replace` with overlapping keys in a nested dictionary will no longer raise, now matching the behavior of a flat dictionary (:issue:`27660`)
242242
- :meth:`DataFrame.to_csv` and :meth:`Series.to_csv` now support dicts as ``compression`` argument with key ``'method'`` being the compression method and others as additional compression options when the compression method is ``'zip'``. (:issue:`26023`)
243-
-
243+
- :meth:`Series.append` will no longer raise a ``TypeError`` when passed a tuple of ``Series`` (:issue:`28410`)
244244

245245
.. _whatsnew_1000.contributors:
246246

pandas/core/series.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2730,7 +2730,8 @@ def append(self, to_append, ignore_index=False, verify_integrity=False):
27302730
from pandas.core.reshape.concat import concat
27312731

27322732
if isinstance(to_append, (list, tuple)):
2733-
to_concat = [self] + to_append
2733+
to_concat = [self]
2734+
to_concat.extend(to_append)
27342735
else:
27352736
to_concat = [self, to_append]
27362737
return concat(

pandas/tests/series/test_combine_concat.py

+11
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ def test_append_duplicates(self):
5454
with pytest.raises(ValueError, match=msg):
5555
pd.concat([s1, s2], verify_integrity=True)
5656

57+
def test_append_tuples(self):
58+
# GH 28410
59+
s = pd.Series([1, 2, 3])
60+
list_input = [s, s]
61+
tuple_input = (s, s)
62+
63+
expected = s.append(list_input)
64+
result = s.append(tuple_input)
65+
66+
tm.assert_series_equal(expected, result)
67+
5768
def test_combine_scalar(self):
5869
# GH 21248
5970
# Note - combine() with another Series is tested elsewhere because

0 commit comments

Comments
 (0)