Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pad .zip attribute with 0 and ensure proper loading from court list #841

Merged
merged 5 commits into from
Apr 25, 2024

Conversation

nonprofittechy
Copy link
Member

@nonprofittechy nonprofittechy commented Apr 25, 2024

Fix #840

Currently, when you use the court_loader class in al_courts.py, there's a chance that a column that has a zip code with leading zeros will be interpreted incorrectly.

This fixes it in 2 ways:

  1. transforms the address_zip column inside the dataframe when it is loaded to zerofill it to at least 5 digits
  2. when printing a zip code (.zip attribute) as part of an address, zerofill to 5 digits.

It also adds an API to define a transformation for arbitrary columns of the Excel spreadsheet: defining the .converters attribute of the ALCourtLoader will now automatically run the converters when the dataframe is loaded. This honors the standard Pandas syntax, where converters should be a mapping between the column name and a callable with one parameter.

Ex:

---
objects:
  - all_courts: |
      ALCourtLoader.using(file_name='courts_list.xlsx', converters={"address_zip": float})

…e circumstances in which the .zip attribute is used and the country is one with a shorter than 5 character standard postal code
@samglover
Copy link

samglover commented Apr 25, 2024

The logic of this fix makes sense and the ALKiln error doesn't seem to relate to it. (Didn't mean to close; clicked the wrong button to comment. 😬)

@samglover samglover closed this Apr 25, 2024
@samglover samglover reopened this Apr 25, 2024
@nonprofittechy nonprofittechy merged commit 2c45d80 into main Apr 25, 2024
6 checks passed
@nonprofittechy nonprofittechy deleted the court-enhancements branch April 26, 2024 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure address_zip of a court list is treated as a string with leading zeros
2 participants