Skip to content

Improve error message for DataFrame.append(<dict-like>) #30871

Closed
@simonjayhawkins

Description

@simonjayhawkins

Code Sample, a copy-pastable example if possible

>>> import pandas as pd
>>>
>>> pd.__version__
'0.26.0.dev0+1731.g3ddd495e4'
>>>
>>> df = pd.DataFrame({"Name": ["Alice"], "Gender": ["F"]})
>>> df
    Name Gender
0  Alice      F
>>>
>>> df.append({"Name": "Bob", "Gender": "M"})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\simon\pandas\pandas\core\frame.py", line 7013, in append
    "Can only append a Series if ignore_index=True "
TypeError: Can only append a Series if ignore_index=True or if the Series has a name

>>>

Problem description

dict-like is valid type for other parameter of DataFrame.append

Expected Output

ValueError: Can only append a dict-like if ignore_index=True

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error ReportingIncorrect or improved errors from pandas

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions