I would need to merge using pandas two dataframes with two columns: locid and locname; then, I would need to find the rows that having same locid, they have different value for locname
Asked
Active
Viewed 40 times
-1
-
Please provide a reproducible input (text), images are not acceptable, also provide iniput for your **two** inputs, and the matching expected output. – mozway Apr 26 '23 at 16:55
-
Refrain from showing your dataframe as an image. Your question needs a minimal reproducible example consisting of sample input, expected output, actual output, and only the relevant code necessary to reproduce the problem. See [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) for best practices related to Pandas questions. – itprorh66 Apr 26 '23 at 17:39
1 Answers
0
Considering, You have 2 Pandas dataframe and each were having locid
and locname
. You want to get the resultant dataframe with column locid
, locname_table1
, locname_table2
.
Then you can try below code -
resultant_df = pd.merge(df_table1, df_table2, on='locid', suffixes=['_table1', '_table2'])

Pravash Panigrahi
- 701
- 2
- 7
- 21