Skip to content

ENH: alleviate issues with inconsistent multi-level joining on a 0-column merge table #48084

Closed
@prhbrt

Description

@prhbrt

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

FutureWarning: merging between different levels is deprecated and will be removed in a future version. (`some number` levels on the left, 1 on the right)

When running:

multilevel_columns = pd.DataFrame({('a', 'b'): np.random.randint(0,100, 10)})
multilevel_columns.index.name = 'alpha'

relations = pd.DataFrame({
    'alpha': np.random.randint(0,10, 10),
    'beta': np.random.randint(0,10, 10)
}).set_index(['alpha', 'beta'])

multilevel_columns.join(relations)

because the 0-column merge table relations only has 1 column-level, whereas multilevel_columns has two. However, it's irrelevant because relations has 0 columns anyway, and so concatenating them should be trivial.

Feature Description

Allow merging inconsistent levels if one frame has 0 columns.

Alternative Solutions

Change this check with the added condition and len(_left.columns) > 0 and len(_right.columns) > 0

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions