0

This may be a really easy question but I am having a hard time to figure out.

I have two python data frames that I am trying to join, here is a snip of the information on each

enter image description here

enter image description here

What I am trying to accomplish is to add the name showing in the first dataframe to each row in the second, however when I try to do a pandas.merge its only doing one row

  • Does this answer your question? [Pandas Merging 101](https://stackoverflow.com/questions/53645882/pandas-merging-101) – BeRT2me Jun 17 '22 at 18:21

1 Answers1

0

Let's suppose that df_1 is that in which you have columns named name and networkId, and df_2 is the dataframe to which you want to attach the name information via the key id.

Then,

merged = df_2.merge(df_1[["networkId","name"]], left_on="id", right_on="networkId", how="left")
print(merged.head())

If this is not in line with your example, please provide some initial data.

BloomShell
  • 833
  • 1
  • 5
  • 20