0

I have got two dataframes of different shapes like:

Df1:

Index State city xyz
0 AL Ala .
1 CA . .
2 AK . .
3 AR . .
. . . .
. . . .

Df2:

Index State Lat Long
0 AL 121 4456
1 AK 42 1266
2 AZ 1421 -426
3 AR 121 456
. . . .

I want to compare the State column in both the datasets and then for each state put the Lat and Long values for that state in the df1 frame. Something like this (using python, pandas and jupyter notebook):

Index State city xyz Lat Long
0 AL Ala . 121 4456
1 CA . . 198 4541
2 AK . . 42 1266
3 AR . . 121 456
. . . . ... ....

I have no Idea how to do this. Thank you for reading this question, I am still a beginner, sorry if this is a stupid question.

1 Answers1

0

Try this:

new_df = df1.merge(df2, on='State')