def test_fail3(self): with pytest.raises(AssertionError): stata_merge(self.df1, self.df1_part, on='a', how='left', assertval=3)
def test_assert3(self): result = stata_merge(self.df1, self.df1_match, on='a', how='left', assertval=3) expected = pd.DataFrame( np.array([[0, 1, 2], [1, 1, 1], [11, 11, 11]]).T, columns=['a', 'b', 'c'], dtype=np.float64) assert_frame_equal(result, expected)
def test_part_left(self): result = stata_merge(self.df1, self.df1_part, on='a', how='left') expected = pd.DataFrame( np.array([[0, 1, 2], [1, 1, 1], [9, 10, np.nan], [3, 3, 1]]).T, columns=['a', 'b', 'c', '_m'], dtype=np.float64) print(result) print(expected) assert_frame_equal(result, expected)
def test_part_left(self): result = stata_merge(self.df1, self.df1_part, on='a', how='left') expected = pd.DataFrame(np.array([[0, 1, 2], [1, 1, 1], [9, 10, np.nan], [3, 3, 1]]).T, columns=['a', 'b', 'c', '_m'], dtype=np.float64) print(result) print(expected) assert_frame_equal(result, expected)
def test_autonaming(self): left = self.df1.rename(columns={'a': 'tmpa'}) right = self.df1_match.rename(columns={'a': 'tmpb'}) result = stata_merge(left, right, left_on='tmpa', right_on='tmpb', how='left', assertval=3) expected = pd.DataFrame( np.array([[0, 1, 2], [1, 1, 1], [0, 1, 2], [11, 11, 11]]).T, columns=['tmpa', 'b', 'tmpb', 'c'], dtype=np.float64) assert_frame_equal(result, expected)
def test_assert3(self): result = stata_merge(self.df1, self.df1_match, on='a', how='left', assertval=3) expected = pd.DataFrame(np.array([[0, 1, 2], [1, 1, 1], [11, 11, 11]]).T, columns=['a', 'b', 'c'], dtype=np.float64) assert_frame_equal(result, expected)
def test_autonaming(self): left = self.df1.rename(columns={'a': 'tmpa'}) right = self.df1_match.rename(columns={'a': 'tmpb'}) result = stata_merge(left, right, left_on='tmpa', right_on='tmpb', how='left', assertval=3) expected = pd.DataFrame(np.array([[0, 1, 2], [1, 1, 1], [0, 1, 2], [11, 11, 11]]).T, columns=['tmpa', 'b', 'tmpb', 'c'], dtype=np.float64) assert_frame_equal(result, expected)
def test_fail3(self): stata_merge(self.df1, self.df1_part, on='a', how='left', assertval=3)