Skip to content

Series.append raises TypeError with tuple of Series #28410

Closed
@simonjayhawkins

Description

@simonjayhawkins

mypy error:

pandas\core\series.py:2733:25: error: Unsupported operand types for + ("List[Any]" and "Tuple[Any, ...]")
pandas\core\series.py:2733:25: note: Right operand is of type "Union[List[Any], Tuple[Any, ...]]"

Code Sample, a copy-pastable example if possible

>>> import pandas as pd
>>> pd.__version__
'0.25.0+332.g261c3a667'
>>>
>>> ser = pd.Series([1,2,3])
>>>
>>> ser
0    1
1    2
2    3
dtype: int64
>>>
>>> ser.append(ser)
0    1
1    2
2    3
0    1
1    2
2    3
dtype: int64
>>>
>>> ser.append([ser,ser])
0    1
1    2
2    3
0    1
1    2
2    3
0    1
1    2
2    3
dtype: int64
>>>
>>> ser.append((ser,ser))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\simon\OneDrive\code\pandas-simonjayhawkins\pandas\core\series.py", line 2733, in append
    to_concat = [self] + to_append
TypeError: can only concatenate list (not "tuple") to list

Problem description

The docstring for Series.append states to_append : Series or list/tuple of Series. Appending a tuple of Series raises TypeError: can only concatenate list (not "tuple") to list

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions