PANDAS pergi bergabung
df.merge(df2, left_on = "doc_id", right_on = "doc_num", how = "left")
Comfortable Cockroach
df.merge(df2, left_on = "doc_id", right_on = "doc_num", how = "left")
# df1 as main df and use the feild from df2 and map it into df1
df1.merge(df2,on='columnName',how='left')
pd.merge(product,customer,left_on='Product_name',right_on='Purchased_Product')
df = DataFrame({'var_1':['a','b','c'], 'var_2':[1, 2, 3], 'var_3':['apple', 'banana', 'pear']})
cols = ['var_1', 'var_2'] # Set columns to combine
df['combined'] = df[cols].apply(lambda row: ', '.join(row.values.astype(str)), axis=1)
# Define which column is index
df_i = df.set_index('combined')
# Set the index to None
df_i.index.names = [None]