Questions about Pandas Dataframe

Hello,

I have a question related to Pandas.

In df1 I have a data frame with the id of each seller and their respective names.

In df2 I have the id of the salesmen and their respective sales.

I would like to have in the df2, two new columns with the first name and last names of the salesmen.

PS. in df2 one of the sales is shared between two salesmen.

import pandas as pd

vendors = {'first_name': ['Montgomery', 'Dagmar', 'Reeba', 'Shalom', 'Broddy', 'Aurelia'],
         'last_name': ['Humes', 'Elstow', 'Wattisham', 'Alen', 'Keningham', 'Brechin'],
         'id_vendor': [127, 241, 329, 333, 212, 233]}

sales = {'id_vendor': [['127'], ['241'], ['329, 333'], ['212'], ['233']],
         'sales': [1233, 25000, 8555, 4333, 3222]}

df1 = pd.DataFrame(vendors)
df2 = pd.DataFrame(sales)

I attach the code. any suggestions?`

Thank you in advance.

This does not appear to be a question related to Anvil.

You might get better results by asking such questions on other forums (like stackoverflow.com) and keep this place reserved for questions related to Anvil.

4 Likes