Menu

Joining datasets that never shared a key: validate CIN, LEI and Wikidata IDs, then resolve them in Python
📰

Joining datasets that never shared a key: validate CIN, LEI and Wikidata IDs, then resolve them in Python

DEV Community: datascience·Data Galactica·3 days ago
#WKudbz7p
#devtodatascience#science#devto#dev#return
Reading 0:00
15s threshold

Sunny Mittal works on marketing at Data Galactica. Corrections welcome in the comments.

You have three spreadsheets about the same companies. Finance keyed them by Indian CIN, the treasury team by LEI, and the research team pulled theirs from Wikidata, so every row has a Q-id. None of them shares a column you can join on. This post shows a small Python pipeline that (1) validates each identifier locally, so you don't pay to look up typos, and (2) resolves the survivors to one permanent key.

Step 1: know what a valid identifier looks like

Most bad joins start with bad IDs: a trailing space, a lowercase letter, an O where a 0 should be. Each scheme has a structure you can check for free.

Indian CIN (21 characters). Take L85110KA1981PLC013115 :

Part Value Meaning

1 char L Listed ( U = unlisted)

5 digits 85110 Industry code

2 letters KA State of registration

4 digits 1981 Year of incorporation

3 letters PLC Ownership type (e.g.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.