Skip to content

ENH: Add ignore_empty and ignore_all_na arguments to pd.concat #61210

Open
@sergei3000

Description

@sergei3000

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

I'd like this warning of pd.concat() be solved with an argument

FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.
    return pd.concat(orders_for_plotting)

Feature Description

I mean instead of changing my code to something like

result = pd.concat([df for df in [df1, df2] if not df.empty])

I think it'd be cool to have arguments like ignore_empty: bool = True and ignore_all_na: bool = True (which would turn into = False in the future) in pd.concat, so I'd be all good by just adding one argument in my codebase to deal with the future behavior.

Alternative Solutions

An alternative solution would be not doing this and making people change their code to keep their legacy stuff intact

Additional Context

No response

Metadata

Metadata

Assignees

Labels

EnhancementNeeds TriageIssue that has not been reviewed by a pandas team member

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions