Repository navigation
Python: lookup_muni accepts 6-digit municipality codes (#444) - #460
Open
ArthurFachel wants to merge 1 commit into
Open
ArthurFachel wants to merge 1 commit into
ArthurFachel wants to merge 1 commit into
Conversation
Author
|
Oi @rafapereirabr, passando só pra lembrar deste PR também (junto com o #459). Se quiserem que eu mude algo no tratamento dos códigos de 6 dígitos, é só avisar. |
Contributor
|
oi @ArthurFachel , obrigado pelo PR. Vou avaliar o PR com calma nas próximas semanas. Estamos com outras demandas mais urgentes mas vejo isso assim que der. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #444 for the Python package. I don't have R set up, so the R side is untouched.
lookup_muni(code_muni=...)now accepts the 6-digit code without the IBGE check digit, which is what DATASUS systems (SIM, SIH, SINASC) store. With the 2010 municipal seats, all 5,565 codes have 7 digits and no 6-digit prefix repeats, so a 6-digit code maps to exactly one municipality.Historical years are different. Their codes are synthetic (e.g. 1599902, 1599903 in 1872) and have no check digit, so prefixes repeat: 41 collisions in 1872 and 4 in 1940. When a 6-digit code matches more than one row, the function raises an error asking for the 7-digit code instead of returning several municipalities.
Other details:
3304557.0still work, as they did withint(code_muni).int()ValueError.Tests: 11 new cases in
tests/test_lookup_muni.py(20 pass). Full suite with-m "not network": 330 passed. Also checked against the real data:431490returns Porto Alegre for 2010 and 1991, and159990in 1872 raises the ambiguity error (4 matches).