We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b7fcb54 commit c82b88dCopy full SHA for c82b88d
pandas/core/frame.py
@@ -7023,6 +7023,8 @@ def append(
7023
"""
7024
if isinstance(other, (Series, dict)):
7025
if isinstance(other, dict):
7026
+ if not ignore_index:
7027
+ raise TypeError("Can only append a dict if ignore_index=True")
7028
other = Series(other)
7029
if other.name is None and not ignore_index:
7030
raise TypeError(
pandas/tests/frame/methods/test_append.py
@@ -50,6 +50,10 @@ def test_append_series_dict(self):
50
)
51
tm.assert_frame_equal(result, expected.loc[:, result.columns])
52
53
+ msg = "Can only append a dict if ignore_index=True"
54
+ with pytest.raises(TypeError, match=msg):
55
+ df.append(series.to_dict())
56
+
57
# can append when name set
58
row = df.loc[4]
59
row.name = 5
0 commit comments