user19778438
user19778438

Reputation: 15

Partial compare two columns from different dataframe of different sizes and use data from a different column

I have two different dataframes of different sizes. Like below

    df1 = pd.DataFrame(
    {
        "System": ["SYS1", "SYS2", "SYS3"],
        "User": ["USER1_COMP1", "USER1_COMP2", "USER2_COMP3"],
    }
    )



    df2 = pd.DataFrame(
    {
         "UC": [
            "USER1_COMP1 Info",
            "USER2_COMP2 LLC",
            "USER3_COMP3 INC",
            "USER1_COMP2 Ltd",
            "USER2_COM Ltd ",
        ],
        "Amount": ["150", "175", "160", "180", "100"],
    }
   )

I want to do a partial match between User from DF1 with UC in DF2.Then i want to use info. from User in Df1 and append that column to Df2. So end result should be

    df3= pd.DataFrame(
    {
        "UC": [
             "USER1_COMP1 Info",
            "USER1_COMP2 Ltd",
            "USER2_COM Ltd ",
        ],
        "Amount": ["150", "180", "100" ],
         "System": ["SYS1", "SYS2", "SYS3"]
    }
    )

I am using fuzzywuzzy to do partial compare but not sure how to append the system table to the end result.

Upvotes: 1

Views: 30

Answers (0)

Related Questions