liveBook · Manning

Hash function

As explained in Effective Data Analysis

A hash algorithm is a computational procedure that deterministically maps data to a fixed-size hash code.

A hash function deterministically transforms data into a fixed-size hash code. Repeated inputs produce the same code, while small input changes produce very different codes, making the result useful as a pseudonymous identifier. section 8.3.2

Hashing supports pseudonymization when sensitive fields must remain joinable in a warehouse but should stay hidden from analysts and stakeholders. Store the original value separately with restricted access, and retain only the hash in the analytical table. section 8.3.2

Use hashing with these cautions:

  • Treat hash similarity as meaningless: similar hashes do not indicate similar original data. section 8.3.2
  • Do not assume irreversible protection forever; reassess current information-security practices. section 8.3.2

Hashing email addresses

Python’s hashlib library can apply SHA-256 to each email, create an email_hash column, copy the email and hash into a separate table, and remove the original email from transactions. section 8.3.2

Table 8.1 Examples of anonymized and pseudonymized data
Example
Anonymized
Pseudonymized
Medical research
Patients have names, birthdays, and contact information removed from the data warehouse.
Patients have names replaced with pseudonyms and a unique identifier that can be tied to their contact information.
Human resources management
Employees have names, social security numbers, and birthdays masked from view.
Employees have all identifying information stored in a separate table with restricted access.
Customer surveys
Respondents have no identifying information collected.
Respondents can share their emails for future studies, which are only accessible by survey tool admins.

Compare anonymization, which removes identifying information, with pseudonymization, which preserves a restricted link to it. section 8.3.2

How Effective Data Analysis covers it

How deep it goes
Explains deterministic behavior, fixed-size output, practical hashing, and security caveats without detailing algorithm internals.
Examples
Demonstrates SHA-256 email hashing in pandas and compares anonymized and pseudonymized records across domains.
What you can do after
Apply it via Python hashlib and pandas to create pseudonymous identifiers and separate original values from analysis tables.
How it connects
Connects hashing with pseudonymization, anonymization, primary keys, data warehouses, and sensitive-data handling.

Also explained in

Compare how 16 books explain hash function →

Related concepts

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