-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Description
Code Sample, a copy-pastable example if possible
df = pandas.DataFrame(columns=['a']).combine_first(pandas.DataFrame(columns=['b']))
df.columns
> Index(['a'], dtype='object')Problem description
The current behaviour is a problem in that the resulting dataframe's columns are not a combination/union of the columns of each of the two dataframes. The expected output is that df.columns would return Index(['a', 'b'], dtype='object'). This expected output is desirable as it is a possible that the dataframes being combined have information value in the union of columns even in instances where there are no row indexes in either dataframe.
I am using version 0.25.3 for which the documentation states: "The row and column indexes of the resulting DataFrame will be the union of the two". (https://github.com/pandas-dev/pandas/blob/v0.25.3/pandas/core/frame.py#L5587-L5661)
I've checked the issues page but couldn't find anything on this case.
Expected Output
Index(['a', 'b'], dtype='object')