-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Closed
Labels
EnhancementNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further action
Description
Is your feature request related to a problem?
Yes, pd.concat([]) currently raises the exception, ValueError("No objects to concatenate").
Describe the solution you'd like
To be correct on all input sizes, it should return an empty DataFrame.
API breaking implications
Obviously, concat will no longer detect empty data. However, empty data will detect itself.
Additional context
The concatenation operation is for lists what addition is for numbers. Concatenation of an empty list should produce an empty dataframe, because the empty dataframe represents 0. Consider
sum([])
which python evaluates to 0.
This makes concatenation and sum commute, sum([1] + []) == sum([1]) + sum([]).
This already works for an empty dataframe:
pd.concat([pd.DataFrame({'A':[1]}), pd.DataFrame()])
if is very odd for concat([]) not to produce a DataFrame, since its input has the correct type.
Metadata
Metadata
Assignees
Labels
EnhancementNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further action