Example 1: join on column pandas
df1.merge(df2,on='columnName',how='left')
Example 2: joins in pandas
pd.merge(product,customer,left_on='Product_name',right_on='Purchased_Product')
Example 3: joins in pandas
pd.merge(product,customer,on='Product_ID')
Example 4: Joins with another DataFrame
df.join(df2, df.name == df2.name, 'outer').select(
df.name, df2.height).collect()
df.join(df2, 'name', 'outer').select('name', 'height').collect()
cond = [df.name == df3.name, df.age == df3.age]
df.join(df3, cond, 'outer').select(df.name, df3.age).collect()
df.join(df2, 'name').select(df.name, df2.height).collect()
df.join(df4, ['name', 'age']).select(df.name, df.age).collect()
Example 5: join in pandas
import pandas as pd
clients = {'Client_ID': [111,222,333,444,555],
'Client_Name': ['Jon Snow','Maria Green', 'Bill Jones','Rick Lee','Pamela Lopez']
}
df1 = pd.DataFrame(clients, columns= ['Client_ID','Client_Name'])
countries = {'Client_ID': [111,222,333,444,777],
'Client_Country': ['UK','Canada','Spain','China','Brazil']
}
df2 = pd.DataFrame(countries, columns= ['Client_ID', 'Client_Country'])
Inner_Join = pd.merge(df1, df2, how='inner', on=['Client_ID', 'Client_ID'])
print(Inner_Join)
Example 6: pandas join dataframe