Every line of 'pandas concat two columns' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
29 def _concat(df, type): 30 if df is None: 31 df = pd.DataFrame(_object_blocks[type]) 32 else: 33 _df = pd.DataFrame(_object_blocks[type]) 34 df = pd.concat([df, _df], sort=True) 35 return df
813 def merge(old_cols, new_cols): 814 return old_cols + new_cols
142 def append_data(df1, df2): 143 ''' 144 Append df2 to df1 145 ''' 146 df = pd.concat((df1, df2)) 147 return df.groupby(df.index).first()
56 def _concat_df(data, temp): 57 58 oh = onehot(data) 59 temp = pd.concat([temp, oh], axis=1) 60 61 return temp
33 def concat(self, l): 34 if not len(l): 35 return "NA" 36 return ";".join([str(i) for i in l])
39 @pytest.mark.functions 40 def test_deconcatenate_column_string_no_sep(dataframe): 41 with pytest.raises(ValueError): 42 df_orig = dataframe.concatenate_columns( 43 column_names=["a", "decorated-elephant"], 44 sep="-", 45 new_column_name="index", 46 ) 47 df = df_orig.deconcatenate_column( 48 column_name="index", new_column_names=["A", "B"] 49 )
44 def test_concat_rows_transform_1(): 45 d1 = data_algebra.default_data_model.pd.DataFrame({"k": ["a", "b"], "x": [1, 2],}) 46 d2 = data_algebra.default_data_model.pd.DataFrame({"k": ["b", "c"], "x": [3, 4],}) 47 ops = describe_table(d1, table_name="d1").concat_rows( 48 b=describe_table(d2, table_name="d2") 49 ) 50 data = {"d1": d1, "d2": d2} 51 expect = data_algebra.default_data_model.pd.DataFrame( 52 { 53 "k": ["a", "b", "b", "c"], 54 "x": [1, 2, 3, 4], 55 "source_name": ["a", "a", "b", "b"], 56 } 57 ) 58 data_algebra.test_util.check_transform(ops, data, expect)