Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
DataFrame.combine_first() breaks for DataFrame with indices but no columns #2307
Title says it all. core/frame.py, combine() method at line 3448:
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...
@pikeas , can you provide a testcase? I tried the following:
import pandas as pd a=pd.DataFrame([1,2]) a.combine_first(pd.DataFrame())
which looks like it's working here.
import pandas as pd a=pd.DataFrame([1,2]) b=pd.DataFrame(index=[1,2]) a.combine_first(b)
which also works