New Match Value in new column

sinoyon780

New Member
Joined
Dec 12, 2022
Messages
21
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
Hi,

Column A in primary key match with Column B And Column B And C save Valu but in C not same sequence so i want new Id list from column A to D basee on ccolumn C sequence.

thank you.
 

Attachments

  • Screenshot 2024-02-15 at 1.20.11 PM.png
    Screenshot 2024-02-15 at 1.20.11 PM.png
    106 KB · Views: 17

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Here is the Python solution i have done>

Python:
import pandas as pd

# Read the Excel file with 'Id' column as string
df = pd.read_excel("/content/SHARP_EmployeeID.xlsx", dtype={'Id': str})

# Display the DataFrame to verify the data
print(df.head())

Python:
# Drop duplicates in 'PersonalNo' column to make it unique
df_unique_personalno = df.drop_duplicates('PersonalNo')

# Create a dictionary mapping PersonalNo to Id
personalno_to_id = df_unique_personalno.set_index('PersonalNo')['Id'].to_dict()

# Use map to create Id2 based on EmployeeId sequence
df['Id2'] = df['EmployeeId'].map(personalno_to_id)
df['Id2'] = df['Id2'].astype(str)
# Print or save the DataFrame with the new column

print(df)

Python:
#Save to new excel file
df.to_excel("output_file.xlsx", index=False)
 
Upvote 0
Solution

Forum statistics

Threads
1,215,071
Messages
6,122,964
Members
449,094
Latest member
Anshu121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top