Improve list_geobr catalog and lookup_muni fuzzy matching#421
Open
JoaoCarabetta wants to merge 4 commits into
Open
Improve list_geobr catalog and lookup_muni fuzzy matching#421JoaoCarabetta wants to merge 4 commits into
JoaoCarabetta wants to merge 4 commits into
Conversation
Introduce cached parquet downloads, filtering, multi-format output (sf/arrow/duckdb relation), and shared read_geobr_v2/hybrid helpers to align Python with the R v2.0.0 data path. Co-authored-by: Cursor <cursoragent@cursor.com>
Join live v2 metadata in list_geobr and add year-aware fuzzy municipality lookup using rapidfuzz. Co-authored-by: Cursor <cursoragent@cursor.com>
Cherry-pick CI workflow upgrade from python-v2-pipeline; keep PR4 list_geobr tests unchanged. Co-authored-by: Cursor <cursoragent@cursor.com>
AppVeyor is not required for Python (GitHub Actions Python-CMD-check covers all platforms). Path filters skip builds when only python-package or .github change. Co-authored-by: Cursor <cursoragent@cursor.com>
camilagb
reviewed
May 28, 2026
Comment on lines
+42
to
+51
| "alias": [ | ||
| "country", "regions", "states", "mesoregions", "microregions", | ||
| "intermediateregions", "immediateregions", "municipalities", | ||
| "municipalseats", "weightingareas", "censustracts", "statsgrid", | ||
| "metroarea", "urbanareas", "amazonialegal", "biomes", | ||
| "conservationunits", "disasterriskareas", "indigenousland", | ||
| "semiarid", "healthfacilities", "healthregions", "neighborhoods", | ||
| "schools", "amc", "urbanconcentrations", "poparrengements", | ||
| "favelas", "pollingplaces", "quilombolalands", | ||
| ], |
Collaborator
There was a problem hiding this comment.
Following the R package
Suggested change
| "alias": [ | |
| "country", "regions", "states", "mesoregions", "microregions", | |
| "intermediateregions", "immediateregions", "municipalities", | |
| "municipalseats", "weightingareas", "censustracts", "statsgrid", | |
| "metroarea", "urbanareas", "amazonialegal", "biomes", | |
| "conservationunits", "disasterriskareas", "indigenousland", | |
| "semiarid", "healthfacilities", "healthregions", "neighborhoods", | |
| "schools", "amc", "urbanconcentrations", "poparrengements", | |
| "favelas", "pollingplaces", "quilombolalands", | |
| ], | |
| "alias": [ | |
| "country", "regions", "states", "mesoregions", "microregions", | |
| "intermediateregions", "immediateregions", "municipalities", | |
| "municipalseats", "weightingareas", "censustracts", "statsgrid", | |
| "metroarea", "urbanareas", "amazonialegal", "biomes", | |
| "conservationunits", "disasterriskareas", "indigenouslands", | |
| "semiarid", "healthfacilities", "healthregions", "neighborhoods", | |
| "schools", "amc", "poparrangements", "poparrangements", | |
| "favelas", "pollingplaces", "quilombolalands", | |
| ], |
Comment on lines
+87
to
+101
| rows = [] | ||
| for _, row in out.iterrows(): | ||
| raw = row.get("years_available") | ||
| if raw is None or (isinstance(raw, float) and pd.isna(raw)): | ||
| years = [] | ||
| else: | ||
| years = str(raw).split(", ") | ||
| if not years or years == [""]: | ||
| rows.append(row.to_dict()) | ||
| else: | ||
| for y in years: | ||
| r = row.to_dict() | ||
| r["year"] = y.strip() | ||
| rows.append(r) | ||
| return pd.DataFrame(rows) |
Collaborator
There was a problem hiding this comment.
Suggested change
| rows = [] | |
| for _, row in out.iterrows(): | |
| raw = row.get("years_available") | |
| if raw is None or (isinstance(raw, float) and pd.isna(raw)): | |
| years = [] | |
| else: | |
| years = str(raw).split(", ") | |
| if not years or years == [""]: | |
| rows.append(row.to_dict()) | |
| else: | |
| for y in years: | |
| r = row.to_dict() | |
| r["year"] = y.strip() | |
| rows.append(r) | |
| return pd.DataFrame(rows) | |
| out["year"] = out["years_available"].fillna("").str.split(", ") | |
| out_expandido = out.explode("year") | |
| out_expandido["year"] = out_expandido["year"].str.strip() | |
| out_expandido = out_expandido.drop(columns=["years_available"]) | |
| return out_expandido |
| immediate regions. You should not select both code_muni and name_muni | ||
|
|
||
| def lookup_muni( | ||
| year: int = 2010, |
Collaborator
There was a problem hiding this comment.
Suggested change
| year: int = 2010, | |
| year: int, |
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.
Summary
list_geobr()returns a DataFrame joined with live v2 metadata yearslookup_muni()adds year parameter and rapidfuzz-based fuzzy name matchingTest plan
test_list_geobr,test_lookup_muni,test_lookup_muni_v2Depends on #418
Made with Cursor