1

I have 2 dataframes. One has a bunch of columns including f_uuid. The other dataframe has 2 columns, f_uuid and i_uuid.

the first dataframe may contain some f_uuids that the second dataframe doesn't and vice versa.

I want the first dataframe to have a new column i_uuid (from the second dataframe) populated with the appropriate values for the matching f_uuid in that first dataframe.

How would I achieve this?

1

2 Answers 2

1
df1 = pd.merge(df1,
               df2,
               on='f_uuid')

If you want to keep all f_uuid from df1 (e.g. those not available in df2), you may run

df1 = pd.merge(df1,
               df2,
               on='f_uuid',
               how='left')
Sign up to request clarification or add additional context in comments.

Comments

1

I think what your looking for is a merge : https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.merge.html?highlight=merge#pandas.DataFrame.merge

In your case, that would look like :

bunch_of_col_df.merge(other_df, on="f_uuid")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.