Closed
Description
Code Sample, a copy-pastable example if possible
The behavior of the following changed with 1.0.0rc0
>>> import pandas as pd
>>> df = pd.DataFrame({"A": [1,2], "B": [3, 4]})
>>> df.A.append(df)
On 0.25.3, we have
0 A B
0 1.0 NaN NaN
1 2.0 NaN NaN
0 NaN 1.0 3.0
1 NaN 2.0 4.0
On 1.0.0rc0, we have
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-9-fde662a5b7c4> in <module>
----> 1 df.A.append(df)
~/sandbox/pandas/pandas/core/series.py in append(self, to_append, ignore_index, verify_integrity)
2541 return self._ensure_type(
2542 concat(
-> 2543 to_concat, ignore_index=ignore_index, verify_integrity=verify_integrity
2544 )
2545 )
~/sandbox/pandas/pandas/core/base.py in _ensure_type(self, obj)
93 Used by type checkers.
94 """
---> 95 assert isinstance(obj, type(self)), type(obj)
96 return obj
97
AssertionError: <class 'pandas.core.frame.DataFrame'>
Problem description
I don't think the behavior of 0.25.3 is necessarily correct. I would expect either a TypeError from passing a DataFrame to Series.append, or something like
In [17]: r
Out[17]:
A B
0 1 3.0
1 2 4.0
0 1 NaN
1 2 NaN
where the name of the Series is aligned with the DataFrame. We clearly document that the elements passed to append should be Series, so IMO we should raise.