def test_merge_unicode_col(): bad_df = DDF(DATA) bad_str = u'hurac\xe1n' bad_df['name'] = np.array([bad_str]*N_EXAMPLES).astype(unicode) good_df = DDF(DATA) good_str = u'namey_mc_name' good_df['name'] = np.array([good_str]*N_EXAMPLES).astype(str) bad_df.merge(good_df, on=['group_id', 'name'], how='left')
def test_can_merge_two_ddfs(): d1 = DDF({'col1': np.arange(4), 'col2': np.arange(4)}) d2 = DDF({'col1': np.arange(2), 'col3': np.arange(2)}) d3 = d2.merge(d1, on='col1', how='outer') assert np.allclose(d3['col2'], d1['col2']) assert utils.nan_allclose(d3['col3'], np.array([0, 1, np.nan, np.nan]))
def test_merge_preservers_strings(): d1 = DDF({'a': np.arange(4), 'b': np.repeat('b', 4), 'd': np.repeat('r', 4)}) d2 = DDF({'a': np.arange(4), 'c': np.repeat('c', 4), 'd': np.repeat('2r', 4)}) merged = d1.merge(d2, on='a') assert merged['b'].dtype.type is np.str_ assert merged['c'].dtype.type is np.str_