Data ethics and privacy
Last updated
Data about customers is data about people. In the Philippines, the Data Privacy Act sets rules for collecting and using it, and good practice goes further. In this lesson you'll sort personal from sensitive personal information, see a table with the names taken out get its names back through one join, and publish counts that can't single anyone out.
By the end of this lesson you can
- Tell personal, sensitive personal and non-personal data apart under the Data Privacy Act
- Explain why removing names doesn't make data anonymous
- Publish group counts safely by coarsening and suppressing small groups
Personal and sensitive data
The Data Privacy Act of 2012 (Republic Act 10173) is the Philippine law on personal data. The National Privacy Commission (NPC) enforces it. It covers anyone who collects or uses personal data, including a small business with a loyalty card.
It sorts data into kinds:
- Personal information: information from which a person's identity is apparent, or can reasonably and directly be worked out, alone or put together with other information.
- Sensitive personal information: a stricter class, including race and ethnic origin, marital status, age, religious and political affiliations, health, education, and government-issued identifiers such as social security numbers. It may be processed only in the cases the Act allows, such as with the person's specific consent.
Sort the Tindahan's data:
0 of 7 placed right
A card holder’s name and mobile number
A card holder’s age, in the card register
Customers who buy diabetes test strips every month, by card number
A card holder’s SSS number, copied from their ID at sign-up
Purchases by card number, without names
Takings per store per month
Card holders per barangay, every count 10 or more
The test is not "does it have a name?" but "can the person be identified?". That's why "purchases by card number" is personal: the store holds the register that links them.
Purpose, consent and proportion
The Act's general principles (section 11) come down to three questions to ask before collecting or analysing personal data:
- Transparency: do the people know what's collected, why, and who sees it? The suki card form should say so, in words customers understand.
- Legitimate purpose: is the use the one they were told about? Card data collected "to give you points" isn't automatically fine to use for, say, selling a mailing list.
- Proportionality: is it only the data needed? Points need a card number and the amount spent. They don't need a birth date, a home address or a photo of an ID.
For analysis, proportionality usually means working with the least identifying version that answers the question: store totals instead of receipts, card numbers instead of names, barangay counts instead of addresses.
Beyond the law, ask the ethical question too: would the customers be surprised, or upset, to see this analysis? If yes, don't do it without asking them.
Wrong way: the survey without names
The owners ran a short survey of 300 card holders: barangay, sex, age, and how much each owes the store on credit (utang). To share it with a student doing a project, they took out the names. "It's anonymous now." Separately, the barangay's senior citizens' association posts its officers' names, positions, ages and barangays on its public page. Run the cells.
Joining on barangay, sex and age, 6 of the 10 officers match exactly one survey row. The president, Lorna Dimaculangan, owes the store ₱290; that's now known to anyone with both files. (Everyone here is made up for the course.)
The third cell shows why it worked: 169 of 300 survey rows are the only one with their barangay, sex and age. Any list with those three columns, a voters' list, a parish directory, a Facebook group, can put names back on them.
This is re-identification, and it's the usual outcome, not a rare one. Sweeney found that ZIP code, sex and full birth date alone were enough to identify most people in the United States, and Netflix's "anonymous" movie ratings were re-identified from a few public reviews.
The check: removing names isn't anonymising. Before sharing row-level data, ask what columns someone else could join on, and how many rows are unique on them.
Safer tables
Two ways to make shared data safer. Run the cells.
- Coarsen: exact age becomes an age band with
pd.cut(4.9), and the respondent number goes. Still, 77 of 300 rows are in a group of fewer than 5 people. With barangay in, row-level data stays risky. The usual answer is not to share rows at all. - Share counts, and suppress small ones. The second cell publishes, per barangay, how many owe the store. Sabang has 10 people, and fewer than 5 of them owe, so the count is hidden: in a small barangay, "2 people in Sabang owe the Tindahan" is a guessing game everyone can win. The rule also hides counts where fewer than 5 don't owe, because that singles out the few who don't.
A threshold of 5 or 10 is common in official statistics; each agency sets its own. The PSA is required by law (the Philippine Statistical Act, Republic Act 10625) to keep each respondent's information confidential.
Suppressing one cell isn't always enough: if a row total is shown, the hidden cell can be worked out by subtraction. Check totals too.
Check what you learned
Sources
Every example on this page was run with Python 3.14, and its output and error messages are copied from it. These pages cover the same ground in more depth.
- National Privacy Commission: Data Privacy Act of 2012 (Republic Act 10173): section 3 defines personal and sensitive personal information; section 11, the general data privacy principles
- Sweeney, k-anonymity: a model for protecting privacy (International Journal of Uncertainty, Fuzziness and Knowledge-Based Systems, 2002): re-identification by joining on ordinary columns, and every record hidden among at least k
- Narayanan and Shmatikov, Robust de-anonymization of large sparse datasets (IEEE Symposium on Security and Privacy, 2008): the Netflix Prize ratings, re-identified from a few public reviews