Skip to content

Commit

Permalink
TST: unit test to assert behavior described in #2525
Browse files Browse the repository at this point in the history
  • Loading branch information
wesm committed Dec 14, 2012
1 parent 88fa5b0 commit b60f0c4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ pandas 0.10.0
- DataFrame.sort_index raises more helpful exception if sorting by column
with duplicates (GH2488_)
- DataFrame.to_string formatters can be list, too (GH2520_)
- DataFrame.combine_first will always result in the union of the index and
columns, even if one DataFrame is length-zero (GH2525_)

.. _GH407: https://github.com/pydata/pandas/issues/407
.. _GH821: https://github.com/pydata/pandas/issues/821
Expand Down Expand Up @@ -345,6 +347,7 @@ pandas 0.10.0
.. _GH2307: https://github.com/pydata/pandas/issues/2307
.. _GH2488: https://github.com/pydata/pandas/issues/2488
.. _GH2520: https://github.com/pydata/pandas/issues/2520
.. _GH2525: https://github.com/pydata/pandas/issues/2525


pandas 0.9.1
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3690,7 +3690,8 @@ def combine(self, other, func, fill_value=None):
def combine_first(self, other):
"""
Combine two DataFrame objects and default to non-null values in frame
calling the method. Result index will be the union of the two indexes
calling the method. Result index columns will be the union of the
respective indexes and columns
Parameters
----------
Expand Down
6 changes: 6 additions & 0 deletions pandas/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -6188,6 +6188,12 @@ def test_combine_first(self):
comb = self.frame.combine_first(DataFrame(index=["faz","boo"]))
self.assertTrue("faz" in comb.index)

# #2525
df = DataFrame({'a': [1]}, index=[datetime(2012,1,1)])
df2 = DataFrame({}, columns=['b'])
result = df.combine_first(df2)
self.assertTrue('b' in result)

def test_combine_first_mixed_bug(self):
idx = Index(['a','b','c','e'])
ser1 = Series([5.0,-9.0,4.0,100.],index=idx)
Expand Down

0 comments on commit b60f0c4

Please sign in to comment.