You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Alteryx工作流中筛选出重复数据行

筛选多列完全重复行的解决方案

Got it, let's break this down for different tools you might be using to get exactly what you need—keeping only rows where the number, ID, Brand, and Partner columns are identical across at least two rows.

Excel 操作步骤

If you're working in Excel, here's a straightforward way:

  • Add a helper column (say, column E) next to your data.
  • In cell E2, enter this formula (adjust column letters if your target columns aren't A-D):
    =COUNTIFS($A:$A,A2,$B:$B,B2,$C:$C,C2,$D:$D,D2)
  • Drag the formula down to apply it to all rows. This counts how many times the combination of values in the four columns appears in the dataset.
  • Filter the helper column to show only values greater than 1. These are your duplicate rows—copy them to a new sheet to get your final result.

Python Pandas 代码实现

For Python users, Pandas makes this super simple:

import pandas as pd

# Load your dataset (replace with your actual file path/reading method)
df = pd.read_csv("your_large_dataset.csv")

# Filter rows where the four columns have duplicate values (keep all duplicates)
duplicate_rows = df[df.duplicated(subset=['number', 'ID', 'Brand', 'Partner'], keep=False)]

# Save the filtered result to a new file
duplicate_rows.to_csv("filtered_duplicate_rows.csv", index=False)
  • The subset parameter specifies which columns to check for duplicates.
  • keep=False ensures that all duplicate rows are retained (not just the first or last occurrence), which matches your requirement perfectly.

SQL 查询方案

If your data is stored in a SQL database, use this query to fetch the duplicate rows:

SELECT t.*
FROM your_table_name t
INNER JOIN (
    -- First, find all column combinations that appear more than once
    SELECT number, ID, Brand, Partner
    FROM your_table_name
    GROUP BY number, ID, Brand, Partner
    HAVING COUNT(*) > 1
) duplicate_groups 
    ON t.number = duplicate_groups.number
    AND t.ID = duplicate_groups.ID
    AND t.Brand = duplicate_groups.Brand
    AND t.Partner = duplicate_groups.Partner;
  • The subquery identifies all combinations of the four columns that have duplicates.
  • The main query joins back to the original table to pull all rows that belong to these duplicate combinations.

内容的提问来源于stack exchange,提问作者Morty2456

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 23:37:47