Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Deduplicate a Customer List | Deduplication Strategies
Quizzes & Challenges
Quizzes
Challenges
/
Data Cleaning Techniques in Python

bookChallenge: Deduplicate a Customer List

Opgave

Swipe to start coding

You are given a list of customer records that contains duplicate entries. Each customer is represented as a dictionary with two fields:

  • name — the customer's full name;
  • email — the email address provided by the customer.

Your goal is to remove duplicate records using a simple matching rule.

Follow these steps:

  1. Two records are considered duplicates if their email fields match exactly.
  2. Create an empty dictionary named unique_customers, where keys are email addresses and values are customer dictionaries.
  3. Loop through the input list customers and add only the first occurrence of each email to unique_customers.
  4. Store the deduplicated list in a new variable named deduplicated_list, which should contain only the unique customer dictionaries (values of unique_customers).

Make sure both unique_customers and deduplicated_list are declared and contain the correct deduplicated data.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 3
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

Suggested prompts:

Can you explain this in simpler terms?

What are some examples related to this topic?

Where can I learn more about this?

close

bookChallenge: Deduplicate a Customer List

Stryg for at vise menuen

Opgave

Swipe to start coding

You are given a list of customer records that contains duplicate entries. Each customer is represented as a dictionary with two fields:

  • name — the customer's full name;
  • email — the email address provided by the customer.

Your goal is to remove duplicate records using a simple matching rule.

Follow these steps:

  1. Two records are considered duplicates if their email fields match exactly.
  2. Create an empty dictionary named unique_customers, where keys are email addresses and values are customer dictionaries.
  3. Loop through the input list customers and add only the first occurrence of each email to unique_customers.
  4. Store the deduplicated list in a new variable named deduplicated_list, which should contain only the unique customer dictionaries (values of unique_customers).

Make sure both unique_customers and deduplicated_list are declared and contain the correct deduplicated data.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 3
single

single

some-alt