Merge a dataframe and column of others based on indexes

Merge one dataframe and columns of 10 other dataframes based on index value. I have a 10 dataframe with index column being the key identifier and last column being a Unique number for that dataframe. I want to merge the first data frame with that last column of 9 other dataframes based on the index value.If new index arises in 9 other dataframes,merge should ignore that.

Ex: Dataframe1:

Uniq Attr1 Attr2 Rating1
1 a b 9
2 d c 7
3 y x 4

Dataframe2:

Uniq Attr1 Attr2 Rating2
1 a b 6
4 x r 8
3 y x 9
2 d c 5

Merged frame should be:

Uniq Attr1 Attr2 Rating1 Rating2
1 a b 9 6
2 d c 7 5
3 y x 4 9

Upvotes: 1

Views: 32

Answers (1)

Rabinzel
Rabinzel

Reputation: 7903

You could try this:

df_merged = df1.merge(df2, how='inner')

Upvotes: 1

Related Questions