DaddyNote

UK, Irish and EU money and travel rules, worked through step by step, with the date each figure was checked.

AI how-to notes · 2026-09-18 · last run 2026-09-18 · 한국어 원문

Removing duplicates in Excel — how far apart name-only and name-plus-department really land

One line summary

We ran 「중복된 항목 제거」 (Remove Duplicates) on the same 15-row roster and, depending on what we matched on, it left 7, 9 or 12 rows. Match on name alone and only the topmost row of each name survives, so a namesake with a different employee number gets deleted along with the real duplicates. Decide what a single record in this table is keyed on before you delete anything.

Who this is for

Test environment

ItemValue
OSMicrosoft Windows 11 Home 10.0.26200 (build 26200)
ShellPowerShell 7.6.6
ExcelExcel 16.0, build 20326
Cross-checkPython 3.12.10 + pandas 3.0.3 + openpyxl 3.1.5
Test fileA dummy roster we built ourselves — 3 columns (사번 employee no., 이름 name, 부서 department) × 15 rows

The roster we tested with

We deliberately mixed three things in: rows that are identical down to the employee number, namesakes with the same name in different departments, and namesakes with the same name and department but different employee numbers.

Excel row사번이름부서What kind of row
2K2101홍길동영업1팀
3K2102김철수인사팀
4K2103이영희개발팀
5K2104홍길동생산팀Same name as row 2, different person
6K2101홍길동영업1팀Identical to row 2
7K2105박민수영업2팀
8K2102김철수인사팀Identical to row 3
9K2106이영희개발팀Same name and department as row 4, only the number differs
10K2107최지우총무팀
11K2108박민수생산팀Same name as row 7, different person
12K2103이영희개발팀Identical to row 4
13K2109강한별영업1팀
14K2110홍길동영업1팀Same name and department as row 2, only the number differs
15K2111최지우총무팀Same name and department as row 10, only the number differs
16K2112정다은개발팀

Every name, employee number and department is invented. (The names are stock Korean placeholder names; the departments read Sales 1, HR, Dev, Production, Sales 2, General Affairs.)

The 15-row dummy roster used in the test
The 15-row dummy roster used in the test

Three criteria, run separately

On screen you click once inside the table, then 데이터 (Data) tab → 데이터 도구 (Data Tools) group → 중복된 항목 제거 (Remove Duplicates), and tick only the columns you want matched in the dialog that opens. The numbers in this note, though, did not come from that dialog. They came from passing the key columns to RemoveDuplicates over COM, and we were not able to compare them row by row against the on-screen operation.

$ws = $wb.Worksheets.Item(1)

# 기준 A — 이름(2번째 열)만. Header:=xlYes 는 두 번째 인수 1
$ws.Range("A1:C16").RemoveDuplicates(2, 1)

# 기준 B — 이름+부서(2·3번째 열)
$cols = New-Object object[] 2; $cols[0] = 2; $cols[1] = 3
$ws.Range("A1:C16").RemoveDuplicates($cols, 1)

# 기준 C — 사번+이름+부서 세 열 전부
$cols3 = New-Object object[] 3; $cols3[0] = 1; $cols3[1] = 2; $cols3[2] = 3
$ws.Range("A1:C16").RemoveDuplicates($cols3, 1)

Each criterion ran against a fresh copy of the original file. Run them one after another on a single file and the second pass is computed on rows the first pass already deleted, so the results blend together.

We counted the surviving rows this way — walk up from the bottom of column A (-4162 = xlUp) to the last cell holding a value. This roster runs unbroken below the header, so subtracting 1 from the last row number gives the data row count.

$last = $ws.Cells.Item($ws.Rows.Count, 1).End(-4162).Row
"남은 데이터 행 수 = " + ($last - 1)

Results — 15 rows split into 7, 9 and 12

CriterionColumns tickedRows leftRows deleted
A이름 (name)7 rows8 rows
B이름 + 부서 (name + department)9 rows6 rows
C사번 + 이름 + 부서 (number + name + department)12 rows3 rows

The 7 rows left by criterion A were 홍길동(K2101)·김철수(K2102)·이영희(K2103)·박민수(K2105)·최지우(K2107)·강한별(K2109)·정다은(K2112). 홍길동 of 생산팀 (K2104) and 박민수 of 생산팀 (K2108) are gone. Two people in a different department dropped off the roster purely because their names collided.

Name only — 7 rows left. The two Production staff, 홍길동 and 박민수, are gone
Name only — 7 rows left. The two Production staff, 홍길동 and 박민수, are gone

The 9 rows left by criterion B brought back 홍길동(K2104) and 박민수(K2108) of 생산팀. In exchange, 이영희(K2106) of 개발팀, 홍길동(K2110) of 영업1팀 and 최지우(K2111) of 총무팀 dropped out. Namesakes who share a department still cannot be told apart.

Name + department — 9 rows left
Name + department — 9 rows left

Criterion C deleted only 3 rows — row 6 (K2101 홍길동), row 8 (K2102 김철수) and row 12 (K2103 이영희). Those are the rows where all three columns match, the literal duplicates.

Under all three criteria, the row that survived was the topmost of each matching group. Under criterion A, K2101 from row 2 held the 홍길동 slot while row 5's K2104 and row 14's K2110 were deleted — that is the same rule at work. So if there is a specific row you want kept, sort it to the top before deleting. We did not go as far as sorting by a date column and testing whether the most recent row survives.

The same job in Python

Give drop_duplicates in pandas a keep="first" and it keeps the first row, the way Excel does.

import pandas as pd
df = pd.read_excel("E1_명단.xlsx")
df.drop_duplicates(subset=["이름"], keep="first")                  # 7행
df.drop_duplicates(subset=["이름", "부서"], keep="first")           # 9행
df.drop_duplicates(subset=["사번", "이름", "부서"], keep="first")    # 12행

We compared the rows Excel kept against the rows pandas kept, one by one. All three criteria matched on both count and content.

CriterionExcelpandasContents match
Name only7 rows7 rowsTrue
Name + department9 rows9 rowsTrue
Number + name + department12 rows12 rowsTrue

We spelled the column names out in subset for all three criteria.

Which criterion to pick

In this roster the column that identifies one person is the employee number, so the answer is "delete with the employee number included." Here is how to reason it out.

  1. What does that number count one of — a number like an employee number, one per person, belongs in the key. An order number does not: one order can run to several line items, so the same number does not mean the same row. Establish what unit the number counts first.
  2. If there is no unique number, what has to match for it to be the same person — name alone will not do. Look for a combination unlikely to collide, such as name + phone number or name + date of birth.
  3. Count before you delete — write down the row count before and after, and ask whether the drop is plausible. 15 rows becoming 7 means more than half, 8 rows, were deleted. That is a stop signal.
  4. Keep the original aside — Remove Duplicates really does delete rows. We copied the original file fresh for each criterion. Running all three criteria over one file blends the results.

What failed

What we did not test

Related notes