liveBook · Manning

Unique identifier

As explained in The Well-Grounded Data Analyst

A unique identifier is a value intended to distinguish one entity or record from others within a data source or model.

A unique identifier is a value used to distinguish one entity or record from others in a dataset. It supports combining records, tracing their source, and checking whether repeated rows represent the same entity or merely separate records with similar details. section 3.3.1 section 3.4.3

Do not treat differing identifiers as proof that two records are different customers. When otherwise identical records have different IDs, removing one casually can discard a valid source record; retain the IDs and establish links between records that may describe the same underlying entity. section 3.3.1 section 3.4.3

Use identifiers as part of a practical data-quality workflow:

  • Inspect identifier ranges, missing values, and whether associated fields such as categories or brands stay consistent for each ID. section 3.4.3 section 4.4.1
  • Assign an identifier to records that lack one when later matching depends on linking records to an entity. section 3.4.3
  • Keep a separate relationship to other possible IDs when duplicate detection indicates that multiple records may belong to one entity. section 3.4.3
  • Validate that each product ID maps to one intended set of descriptive attributes before using those attributes in analysis. section 4.4.1

Giving guest customers identifiers

Guest checkout records without customer IDs cannot be linked to related accounts through an identifier. One workable convention assigns each unique guest combination a negative integer ID, leaving the existing positive customer-ID range untouched. The chosen convention is artificial but makes every guest record addressable for later deduplication. section 3.4.3

all_guests = all_customers[all_customers["is_guest"]].copy()
new_ids = np.arange(-1, -(len(all_guests) + 1), -1)                    #1
all_customers.loc[all_customers["is_guest"], "customer_id"] = new_ids

Generates sequential negative customer IDs and assigns them only to rows marked as guest accounts. section 3.4.3

How The Well-Grounded Data Analyst covers it

How deep it goes
Works through generated guest IDs, duplicate-ID relationships, and grouped checks for conflicting product attributes.
Examples
Uses guest checkout customers with missing IDs and product IDs assigned to multiple categories or brands.
What it assumes
Assumes tabular customer or event data and uses pandas-style grouping, merging, filtering, and duplicate detection.
What you can do after
Apply it via pandas and recordlinkage to assign IDs, link possible duplicate customers, and detect inconsistent product attributes.
How it connects
Connects unique identifiers with deduplication, entity resolution, missing data, record linkage, product categories, and brands.

Also explained in

Compare how 9 books explain unique identifier →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Well-Grounded Data Analyst. The section links point to the parts of the book it draws on.