Skip to content

Fixturize tests/frame/test_combine_concat.py #25634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions pandas/tests/frame/test_combine_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@

import pandas as pd
from pandas import DataFrame, Index, Series, Timestamp, date_range
from pandas.tests.frame.common import TestData
import pandas.util.testing as tm
from pandas.util.testing import assert_frame_equal, assert_series_equal


class TestDataFrameConcatCommon(TestData):
class TestDataFrameConcatCommon():

def test_concat_multiple_frames_dtypes(self):

Expand Down Expand Up @@ -515,7 +514,7 @@ def test_concat_astype_dup_col(self):
tm.assert_frame_equal(result, expected)


class TestDataFrameCombineFirst(TestData):
class TestDataFrameCombineFirst():

def test_combine_first_mixed(self):
a = Series(['a', 'b'], index=lrange(2))
Expand All @@ -531,22 +530,22 @@ def test_combine_first_mixed(self):
combined = f.combine_first(g)
tm.assert_frame_equal(combined, exp)

def test_combine_first(self):
def test_combine_first(self, float_frame):
# disjoint
head, tail = self.frame[:5], self.frame[5:]
head, tail = float_frame[:5], float_frame[5:]

combined = head.combine_first(tail)
reordered_frame = self.frame.reindex(combined.index)
reordered_frame = float_frame.reindex(combined.index)
assert_frame_equal(combined, reordered_frame)
assert tm.equalContents(combined.columns, self.frame.columns)
assert tm.equalContents(combined.columns, float_frame.columns)
assert_series_equal(combined['A'], reordered_frame['A'])

# same index
fcopy = self.frame.copy()
fcopy = float_frame.copy()
fcopy['A'] = 1
del fcopy['C']

fcopy2 = self.frame.copy()
fcopy2 = float_frame.copy()
fcopy2['B'] = 0
del fcopy2['D']

Expand All @@ -570,20 +569,20 @@ def test_combine_first(self):
assert (combined['A'][:10] == 0).all()

# no overlap
f = self.frame[:10]
g = self.frame[10:]
f = float_frame[:10]
g = float_frame[10:]
combined = f.combine_first(g)
assert_series_equal(combined['A'].reindex(f.index), f['A'])
assert_series_equal(combined['A'].reindex(g.index), g['A'])

# corner cases
comb = self.frame.combine_first(self.empty)
assert_frame_equal(comb, self.frame)
comb = float_frame.combine_first(DataFrame({}))
assert_frame_equal(comb, float_frame)

comb = self.empty.combine_first(self.frame)
assert_frame_equal(comb, self.frame)
comb = DataFrame({}).combine_first(float_frame)
assert_frame_equal(comb, float_frame)

comb = self.frame.combine_first(DataFrame(index=["faz", "boo"]))
comb = float_frame.combine_first(DataFrame(index=["faz", "boo"]))
assert "faz" in comb.index

# #2525
Expand Down Expand Up @@ -850,7 +849,7 @@ def test_concat_datetime_datetime64_frame(self):
pd.concat([df1, df2_obj])


class TestDataFrameUpdate(TestData):
class TestDataFrameUpdate():

def test_update_nan(self):
# #15593 #15617
Expand Down