Skip to content

DataFrame.combine_first() breaks for DataFrame with indices but no columns #2307

@pikeas

Description

@pikeas

Title says it all. core/frame.py, combine() method at line 3448:

    if other.empty:
        return self.copy()

If other is a DataFrame which has indices but no columns, a combine_first() should add the indices with every column set to NaN.

Sorry for not submitting a patch myself - I'm very new to the pandas codebase, so I'm not sure whether this should be resolved in combine() for all combination attempts, or only in combine_first().

...Maybe empty should check whether the DataFrame has indices? Though that could silently break a lot of old code...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions