user27594
0
Q:

combining 2 dataframes pandas

df_col = pd.concat([df1,df2], axis=1)

df_col
11
df_3 = pd.concat([df_1, df_2])
2
# Joins with another DataFrame

df.join(df2, df.name == df2.name, 'outer').select(
  df.name, df2.height).collect()
# [Row(name=None, height=80), Row(name=u'Bob', height=85), Row(
#   name=u'Alice', height=None)]

df.join(df2, 'name', 'outer').select('name', 'height').collect()
# [Row(name=u'Tom', height=80), Row(name=u'Bob', height=85), Row(
#   name=u'Alice', height=None)]

cond = [df.name == df3.name, df.age == df3.age]
df.join(df3, cond, 'outer').select(df.name, df3.age).collect()
# [Row(name=u'Alice', age=2), Row(name=u'Bob', age=5)]

df.join(df2, 'name').select(df.name, df2.height).collect()
# Row(name=u'Bob', height=85)]

df.join(df4, ['name', 'age']).select(df.name, df.age).collect()
# [Row(name=u'Bob', age=5)]
2
# Pandas for Python

df['col1 & col2'] = df['col1']+df['col2']

#Output
#col1	col2	col1 & col2
#A1		A2		A1A2
#B1		B2		B1B2
4

New to Communities?

Join the community