Skip to content

Commit b60f0c4

Browse files
committed
TST: unit test to assert behavior described in #2525
1 parent 88fa5b0 commit b60f0c4

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

RELEASE.rst

+3
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ pandas 0.10.0
231231
- DataFrame.sort_index raises more helpful exception if sorting by column
232232
with duplicates (GH2488_)
233233
- DataFrame.to_string formatters can be list, too (GH2520_)
234+
- DataFrame.combine_first will always result in the union of the index and
235+
columns, even if one DataFrame is length-zero (GH2525_)
234236

235237
.. _GH407: https://github.com/pydata/pandas/issues/407
236238
.. _GH821: https://github.com/pydata/pandas/issues/821
@@ -345,6 +347,7 @@ pandas 0.10.0
345347
.. _GH2307: https://github.com/pydata/pandas/issues/2307
346348
.. _GH2488: https://github.com/pydata/pandas/issues/2488
347349
.. _GH2520: https://github.com/pydata/pandas/issues/2520
350+
.. _GH2525: https://github.com/pydata/pandas/issues/2525
348351

349352

350353
pandas 0.9.1

pandas/core/frame.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3690,7 +3690,8 @@ def combine(self, other, func, fill_value=None):
36903690
def combine_first(self, other):
36913691
"""
36923692
Combine two DataFrame objects and default to non-null values in frame
3693-
calling the method. Result index will be the union of the two indexes
3693+
calling the method. Result index columns will be the union of the
3694+
respective indexes and columns
36943695
36953696
Parameters
36963697
----------

pandas/tests/test_frame.py

+6
Original file line numberDiff line numberDiff line change
@@ -6188,6 +6188,12 @@ def test_combine_first(self):
61886188
comb = self.frame.combine_first(DataFrame(index=["faz","boo"]))
61896189
self.assertTrue("faz" in comb.index)
61906190

6191+
# #2525
6192+
df = DataFrame({'a': [1]}, index=[datetime(2012,1,1)])
6193+
df2 = DataFrame({}, columns=['b'])
6194+
result = df.combine_first(df2)
6195+
self.assertTrue('b' in result)
6196+
61916197
def test_combine_first_mixed_bug(self):
61926198
idx = Index(['a','b','c','e'])
61936199
ser1 = Series([5.0,-9.0,4.0,100.],index=idx)

0 commit comments

Comments
 (0)