Home > Mobile >  Compare two dataframe in pyspark and change column value
Compare two dataframe in pyspark and change column value

Time:02-17

I have two pyspark dataframes like this: df1:

|language|users_count|
 -------- ----------- 
|    Java|      20000|
|  Python|     100000|
|   Scala|       3000|
 -------- ----------- 

df2:

 ------------ --- 
|src_language|abb|
 ------------ --- 
|        Java|  J|
|      Python|  P|
|       Scala|  S|
 ------------ --- 

I want to compare these two dataframes and replace the column value in df1 with abb in df2. So the output will be:

|language|users_count|
 -------- ----------- 
|    J   |      20000|
|    P   |     100000|
|    S   |       3000|
 -------- ----------- 

How can I achieve this?

CodePudding user response:

You can easily do this with join - enter image description here

  • Related