Giter Club home page Giter Club logo

uszipcode-project's Introduction

image

image

Documentation Status

image

image

image

image

image


image

image

image

image

image

image

image

image

Welcome to uszipcode Documentation

If you are on www.pypi.org or www.github.com, this is not the complete document. Here is the Complete Document.

If you are looking for technical support, click the badge below to join this gitter chat room and ask question to the author.

image

uszipcode is the most powerful and easy to use programmable zipcode database in Python. It comes with a rich feature and easy-to-use zipcode search engine. And it is easy to customize the search behavior as you wish.

About the Data

Disclaimer

I started from a academic research project for personal use. I don't promise for data accuracy, please use with your own risk.

Where the data comes from?

The data is crawled from data.census.gov. There's data tool allows you to explore 1300+ data points of a zipcode. You can play it yourself with this link https://data.census.gov/cedsci/table?q=94103.

Is this data set Up-to-Date?

Even the data.census.gov use different source for different data fields. For example, the latest general population / income / education data by zipcode are still from Census2010. But population over time data are based from IRS until FY 2018.

In general, static statistic data are from Census 2010. Demographic statistics over time has data utill 2020.

How many Zipcode in this Database

There are 42,724 zipcodes in this database. There are four different type zipcode:

  • STANDARD: most common zipcode
  • PO Box: for post office
  • UNIQUE: special location, usually a single building
  • MILITARY: military location

Number of zipcodes for each type:

+--------------+-------+------------+
| zipcode_type | count | percentage |
+--------------+-------+------------+
|   STANDARD   | 30001 |   70.22    |
|    PO BOX    |  9397 |   21.99    |
|    UNIQUE    |  2539 |    5.94    |
|   MILITARY   |  787  |    1.84    |
+--------------+-------+------------+

I found a Great data source, how to contribute?

You can open an Issue and leave the URL of the data source, brief description about the dataset.

The Data point

Address, Postal

  • zipcode
  • zipcode_type
  • major_city
  • post_office_city
  • common_city_list
  • county
  • state
  • area_code_list

Geography

  • lat
  • lng
  • timezone
  • radius_in_miles
  • land_area_in_sqmi
  • water_area_in_sqmi
  • bounds_west
  • bounds_east
  • bounds_north
  • bounds_south
  • border polygon

Stats and Demographics

  • population
  • population_density
  • population_by_year
  • population_by_age
  • population_by_gender
  • population_by_race
  • head_of_household_by_age
  • families_vs_singles
  • households_with_kids
  • children_by_age

Real Estate and Housing

  • housing_units
  • occupied_housing_units
  • median_home_value
  • median_household_income
  • housing_type
  • year_housing_was_built
  • housing_occupancy
  • vacancy_reason
  • owner_occupied_home_values
  • rental_properties_by_number_of_rooms
  • monthly_rent_including_utilities_studio_apt
  • monthly_rent_including_utilities_1_b
  • monthly_rent_including_utilities_2_b
  • monthly_rent_including_utilities_3plus_b

Employment, Income, Earnings, and Work

  • employment_status
  • average_household_income_over_time
  • household_income
  • annual_individual_earnings
  • sources_of_household_income____percent_of_households_receiving_income
  • sources_of_household_income____average_income_per_household_by_income_source
  • household_investment_income____percent_of_households_receiving_investment_income
  • household_investment_income____average_income_per_household_by_income_source
  • household_retirement_income____percent_of_households_receiving_retirement_incom
  • household_retirement_income____average_income_per_household_by_income_source
  • source_of_earnings
  • means_of_transportation_to_work_for_workers_16_and_over
  • travel_time_to_work_in_minutes

Education

  • educational_attainment_for_population_25_and_over
  • school_enrollment_age_3_to_17

Install

uszipcode is released on PyPI, so all you need is:

$ pip install uszipcode

To upgrade to latest version:

$ pip install --upgrade uszipcode

uszipcode-project's People

Contributors

aaronsmith1234 avatar andrewfulton9 avatar apryor6 avatar davidcain avatar dovetailjohn avatar machu-gwu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uszipcode-project's Issues

Time zones returned are not pytz compatible

The pytz module is the standard for time zones. The time zones returned by uszipcode don't seem to be compatible "Eastern" is returned for most east coast cities, but 'US/Eastern' is correct:

from pytz import timezone
x = timezone('Eastern')
Traceback (most recent call last):
File "", line 1, in
File "/home/xxxx/.local/lib/python3.6/site-packages/pytz/init.py", line 181, in timezone
raise UnknownTimeZoneError(zone)
pytz.exceptions.UnknownTimeZoneError: 'Eastern'
x = timezone('US/Eastern')

No error with 'US/Eastern'.

Latitude type is checked twice in find method instead of latitude and longitude being checked

As title says:

        if isinstance(lat, (integer_types, float)) and \
                isinstance(lat, (integer_types, float)) and \
                isinstance(radius, (integer_types, float)):

should be:

        if isinstance(lat, (integer_types, float)) and \
                isinstance(lng, (integer_types, float)) and \
                isinstance(radius, (integer_types, float)):

Its a simple fix so I can just make a pull request. By the way, this library has been really useful for me. I use it all the time at work. Thanks for building it out.

Missing Lat,Lng Info for Zip Codes

Some zip codes that are in free-zipcode-database-Primary.csv, but their lat, lng info cannot be called.

For example:

from uszipcode import ZipcodeSearchEngine
search = ZipcodeSearchEngine()
o = search.by_zipcode(30724)
o.Latitude

This call returns nothing, but it is clearly a zip code for Eton Georgia that is in the csv.

Zipcodes are out of date

The zip code database you are using is from 2012. Many places (Brooklyn zip codes in the 11200-11300 range for example) have added or changed zip codes since then, making this zip code data invalid/unusable. Please update the zip code database you are using to be more up to date.

Hosted simple database link not working

Describe the bug

Thanks for the great library : ) I had some test cases that were using this library to generate real zip codes, those tests started failing today with a strange error message:

sqlalchemy.exc.DatabaseError: (sqlite3.DatabaseError) file is not a database

After some debugging, turns out the hosted simple database url, that is downloaded in this line in the code is not working. hence the queries on the simple database fails.

To Reproduce

Steps to reproduce the behavior:

  1. Run the following lines in a python shell or file:
from uszipcode import SearchEngine

search = SearchEngine(simple_zipcode=True)
zip_code = search.by_zipcode(zipcode='12345')

This will produce the following exception:

Start downloading data for simple zipcode database, total size 9MB ...
  1 MB finished ...
  Complete!
Traceback (most recent call last):
  File "/home/pivot/Desktop/pivot/Papi/env/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1278, in _execute_context
    cursor, statement, parameters, context
  File "/home/pivot/Desktop/pivot/Papi/env/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlite3.DatabaseError: file is not a database

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "repro.py", line 4, in <module>
    zip_code = search.by_zipcode(zipcode='12345')
  File "/home/pivot/Desktop/pivot/Papi/env/lib/python3.6/site-packages/uszipcode/search.py", line 575, in by_zipcode
    zipcode_type=zipcode_type,
  File "/home/pivot/Desktop/pivot/Papi/env/lib/python3.6/site-packages/uszipcode/search.py", line 549, in query
    return q.limit(returns).all()
  File "/home/pivot/Desktop/pivot/Papi/env/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 3341, in all
    return list(self)
  File "/home/pivot/Desktop/pivot/Papi/env/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 3503, in __iter__
    return self._execute_and_instances(context)
  File "/home/pivot/Desktop/pivot/Papi/env/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 3528, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/home/pivot/Desktop/pivot/Papi/env/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1014, in execute
    return meth(self, multiparams, params)
  File "/home/pivot/Desktop/pivot/Papi/env/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/pivot/Desktop/pivot/Papi/env/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1133, in _execute_clauseelement
    distilled_params,
  File "/home/pivot/Desktop/pivot/Papi/env/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1318, in _execute_context
    e, statement, parameters, cursor, context
  File "/home/pivot/Desktop/pivot/Papi/env/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1512, in _handle_dbapi_exception
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/home/pivot/Desktop/pivot/Papi/env/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/home/pivot/Desktop/pivot/Papi/env/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1278, in _execute_context
    cursor, statement, parameters, context
  File "/home/pivot/Desktop/pivot/Papi/env/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.DatabaseError: (sqlite3.DatabaseError) file is not a database
[SQL: SELECT simple_zipcode.zipcode AS simple_zipcode_zipcode, simple_zipcode.zipcode_type AS simple_zipcode_zipcode_type, simple_zipcode.major_city AS simple_zipcode_major_city, simple_zipcode.post_office_city AS simple_zipcode_post_office_city, simple_zipcode.common_city_list AS simple_zipcode_common_city_list, simple_zipcode.county AS simple_zipcode_county, simple_zipcode.state AS simple_zipcode_state, simple_zipcode.lat AS simple_zipcode_lat, simple_zipcode.lng AS simple_zipcode_lng, simple_zipcode.timezone AS simple_zipcode_timezone, simple_zipcode.radius_in_miles AS simple_zipcode_radius_in_miles, simple_zipcode.area_code_list AS simple_zipcode_area_code_list, simple_zipcode.population AS simple_zipcode_population, simple_zipcode.population_density AS simple_zipcode_population_density, simple_zipcode.land_area_in_sqmi AS simple_zipcode_land_area_in_sqmi, simple_zipcode.water_area_in_sqmi AS simple_zipcode_water_area_in_sqmi, simple_zipcode.housing_units AS simple_zipcode_housing_units, simple_zipcode.occupied_housing_units AS simple_zipcode_occupied_housing_units, simple_zipcode.median_home_value AS simple_zipcode_median_home_value, simple_zipcode.median_household_income AS simple_zipcode_median_household_income, simple_zipcode.bounds_west AS simple_zipcode_bounds_west, simple_zipcode.bounds_east AS simple_zipcode_bounds_east, simple_zipcode.bounds_north AS simple_zipcode_bounds_north, simple_zipcode.bounds_south AS simple_zipcode_bounds_south 
FROM simple_zipcode 
WHERE simple_zipcode.zipcode = ?
 LIMIT ? OFFSET ?]
[parameters: ('12345', 1, 0)]
(Background on this error at: http://sqlalche.me/e/13/4xp6)

Expected behavior

  1. The download should be validated, and if the download fails, there should be a clear error message, currently the html content of the timeout page are saved as ~/.uszipcode/simple_db.sqlite

  2. Perhaps the file should be moved to a more reliable hosting service? or maybe included in the repo? we could also update the docs to easily highlight how users can include it manually in their projects, or is there a better solution?

I can try to make time to work on a PR if needed.

zipcode still missing

Good package and very useful for locating place to an address, but a bunch of zipcode information are still missing in this package. For example, 18225, there are probably more

unable to open database file

[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import uszipcode
search = uszipcode.ZipcodeSearchEngine()
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/site-packages/uszipcode/searchengine.py", line 106, in init
self.connect = sqlite3.connect(DB_FILE)
sqlite3.OperationalError: unable to open database file

search by state does not return all zip codes in Texas

Describe the bug

I am using the following code and got only a few zip codes in Texas where as Texas has a lot of zip codes.

search = SearchEngine(simple_zipcode=False)
zipcodes = search.by_state('Texas')
for zip in zipcodes:
print(f"zip: {zip.zipcode}, {zip.county}")

output:
zip: 75001, Dallas County
zip: 75002, Collin County
zip: 75006, Dallas County
zip: 75007, Denton County
zip: 75009, Collin County

Expected behavior
Should return all zip codes in the state of Texas.

Avoid saving the database on /tmp file

Saving the database on /tmp folder have several issues. The main one is that It forces you to download it every time the /tmp folder is cleared, like on a system reboot.

As well, it is generating issues when using it on a server that may use different users to run the shell and to run the app. When the downloading the file, -rw------- this permissions are attached to it, so only the owner may read it.

Why was the database moved from ~/.uszipcode/?

Would it be possible to configure the database path, like #16 proposed?

Thank you

Cannot pip install into virtualenv with Python 2.7; AttributeError

$ pip install uszipcode
Collecting uszipcode
  Using cached uszipcode-0.0.9.zip
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-BZi9bp/uszipcode/setup.py", line 61, in <module>
        VERSION = __import__(NAME).__version__
      File "uszipcode/__init__.py", line 4, in <module>
        from .searchengine import ZipcodeSearchEngine
      File "uszipcode/searchengine.py", line 4, in <module>
        from uszipcode.data import (
      File "uszipcode/data/__init__.py", line 19, in <module>
        site.getsitepackages()[1], "uszipcode", "data", "zipcode.sqlite3")
    AttributeError: 'module' object has no attribute 'getsitepackages'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-BZi9bp/uszipcode

TypeError when searching by coordinates

I'm using pandas and uszipcode to try and find the state that contains a given set of coordinates. I don't know what the issue is or what is causing it but it definitely seems to be an issue with uszipcode. Additionally, the first set of coordinates printed ("40.7830603 -73.9712488") is from the second line of the database, not the first. (The zeroth is the column names.) Here's the code and the debugger output:

import pandas as pd
import numpy as np
import os
from uszipcode import ZipcodeSearchEngine

def convert_to_state(lati, long):
    lat, lon = float(lati), float(long)
    search = ZipcodeSearchEngine()
    try:
        res = search.by_coordinate(lat, lon, radius=20, returns=1)
    except TypeError as TE:
        print(lat, lon, type(lat), type(lon))
        raise TE
    res = res[0]
    state = res.State
    return state

def get_state(path):
    with open(path + "USA_downloads.csv", 'r+') as f:
        data = pd.read_csv(f, low_memory=False)
        print(data.dtypes)
        data["state"] = np.vectorize(convert_to_state)(data["latitude"].values, data["longitude"].values)
get_state(path)


----


date         object
city         object
coords       object
doi          object
latitude     object
longitude    object
dtype: object
40.7830603 -73.9712488 <class 'float'> <class 'float'>
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-174-cf7375ac127a> in <module>()
----> 1 get_state(path)

<ipython-input-173-86eb18a81b48> in get_state(path)
      3         data = pd.read_csv(f, low_memory=False)
      4         print(data.dtypes)
----> 5         data["state"] = np.vectorize(convert_to_state)(data["latitude"].values, data["longitude"].values)

/Users/obfus/anaconda/lib/python3.5/site-packages/numpy/lib/function_base.py in __call__(self, *args, **kwargs)
   2216             vargs.extend([kwargs[_n] for _n in names])
   2217
-> 2218         return self._vectorize_call(func=func, args=vargs)
   2219
   2220     def _get_ufunc_and_otypes(self, func, args):

/Users/obfus/anaconda/lib/python3.5/site-packages/numpy/lib/function_base.py in _vectorize_call(self, func, args)
   2285                       for _a in args]
   2286
-> 2287             outputs = ufunc(*inputs)
   2288
   2289             if ufunc.nout == 1:

<ipython-input-172-e1d3d371d0eb> in convert_to_state(lati, long)
      6     except TypeError as TE:
      7         print(lat, lon, type(lat), type(lon))
----> 8         raise TE
      9     res = res[0]
     10     state = res.State

<ipython-input-172-e1d3d371d0eb> in convert_to_state(lati, long)
      3     search = ZipcodeSearchEngine()
      4     try:
----> 5         res = search.by_coordinate(lat, lon, radius=20, returns=1)
      6     except TypeError as TE:
      7         print(lat, lon, type(lat), type(lon))

/Users/obfus/anaconda/lib/python3.5/site-packages/uszipcode/searchengine.py in by_coordinate(self, lat, lng, radius, ascending, standard_only, returns)
    498           ้™ๅฎš็š„ๅŠๅพ„็š„็›ดๆŽฅไธขๅผƒใ€‚
    499         """
--> 500         return self.find(lat=lat, lng=lng, radius=radius, standard_only=standard_only, sort_by=None, ascending=ascending, returns=returns)
   501
   502     def by_city_and_state(self, city, state,

/Users/obfus/anaconda/lib/python3.5/site-packages/uszipcode/searchengine.py in find(self, lat, lng, radius, city, state, prefix, pattern, population_lower, population_upper, density_lower, density_upper, landarea_lower, landarea_upper, waterarea_lower, waterarea_upper, totalwages_lower, totalwages_upper, wealthy_lower, wealthy_upper, house_lower, house_upper, standard_only, sort_by, ascending, returns)
   983                         (row["Latitude"], row["Longitude"]), (lat, lng))
   984                     if dist <= radius:
--> 985                         heappush(heap, (dist, row))
   986
   987                 # generate results

TypeError: unorderable types: sqlite3.Row() < sqlite3.Row()

Library fails - Unable to get simple database

Describe the bug

https://datahub.io/machu-gwu/uszipcode-0.2.0-simple_db/r/simple_db.sqlite
returns:

Error 502 Ray ID: 625b403e4b5ded73 โ€ข 2021-02-22 19:53:02 UTC
Bad gateway

Also, library returns cryptic error in such case. Looks like it downloads sqlite file (which contains HTML error), but does not notice this was an error.

sqlite3.DatabaseError: file is encrypted or is not a database

To Reproduce

See above.

Expected behavior

  1. Able to download
  2. In case of download error prints an error message that this happened

Screenshots

image

sqlite to postgres

Hello, the documentation suggests

"(RECOMMEND) Dump the sqlite database to any relational database like Postgres, MySQL, and inject the database connection info in your application server."

Could you elaborate on what needs to be done ... to use postgres?

Not sure of what code changes one needs to make etc ...

Thanks!
Evan

Some zipcode polygons are 3D lists

The polygon for 44122 (using simple_zipcode=False) returns a 3D list, unlike most zipcodes. The regular 2D list is itself the only item in an outer list. The 2D list inside also seems much too short to be a good polygon for this zipcode.

I have uszipcode==0.2.2 installed in a virtualenv.

>>> search = SearchEngine(simple_zipcode=False)
>>> search.by_zipcode('44122').polygon
[[[-81.549838, 41.478182], [-81.549829, 41.474945], [-81.549883, 41.474739], [-81.550029, 41.474493], [-81.550482, 41.475187], [-81.550473, 41.477716], [-81.549838, 41.478182]]]

The expected behavior is that it returns a 2D list with many more points than that.

Other zipcodes I've found with the same issue (not a complete list):

  • 31632
  • 49426
  • 45801
  • 60605
  • 22180
  • 08540
  • 01588
  • 55901

Zipcode 75036 returns "None" for all fields when using SearchEngine().by_zipcode()

I love this package, but encountered a missing zip code (or maybe there's some other error going on).
I am using uszipcode==0.2.4 .

Code to reproduce the issue:

from uszipcode import SearchEngine

SearchEngine(simple_zipcode=True).by_zipcode('75036')

# OUTPUT:
SimpleZipcode(zipcode=None, zipcode_type=None, major_city=None, post_office_city=None, common_city_list=None, county=None, state=None, lat=None, lng=None, timezone=None, radius_in_miles=None, area_code_list=None, population=None, population_density=None, land_area_in_sqmi=None, water_area_in_sqmi=None, housing_units=None, occupied_housing_units=None, median_home_value=None, median_household_income=None, bounds_west=None, bounds_east=None, bounds_north=None, bounds_south=None)

Expected behavior

Zipcode 75036 does in fact exist, it is located just north of Dallas, Texas.

Missing someting in manual?

from uszipcode import Zipcode
Search zipcode within 30 miles, ordered from closest to farthest
result = search.by_coordinates(39.122229, -77.133578, radius=30, returns=5)
len(res) # by default 5 results returned
5

What does search stand for?

Thanks

Manassas Park, VA is included in Prince William County

Describe the bug

When requesting the zip code for Manassas Park, it is listed as being in Prince William County, but it is an independent city in VA and not part of any county

To Reproduce

Steps to reproduce the behavior:

search = SearchEngine(simple_zipcode=True)
zipcode = zip_search_engine.by_zipcode('20111').to_dict()

Expected behavior

Manassas Park should return as a county as well since it is an independent city.

zipcodes that don't return lat and lon data when using search.by_zipcode

I went through a debugging process in an attempt to determine where the issue might lie, but was unable to find it myself. We ran several thousand zipcodes through the search.by_zipcode function and a good number of them did not return any latitude and longitude data. (2701 returned the data and 1648 did not) I googled the first few zipcodes for which the data was not returned to ensure they were valid US zip codes and they were. I have provided a csv file with the 1648 zip codes that did not work. If you can determine why some zip codes work with this function while others don't, it would be much appreciated. I've also provided a short python script showing how we are utilizing the package so you can be sure it is not a problem with the code on our end. Also provided is a csv with ALL the zipcodes we have been testing to write into the script.
uszipcode issue.zip

Thanks!

-Derek Prestwich (BYU Prism Lab)

Fuzzy match error: by_city_and_state changes the city when it is not ambiguously spelled.

Describe the bug
Searching for a zip code by city (by_city_and_state) is returning a zip code for a city who's name is close to the one provided, but unnecessarily so, since the city provided is unambiguous.

A clear and concise description of what the bug is.
Searching for city state : 'burien' , 'wa' returns a zip code for 'Burlington, WA'

To Reproduce
by_city_and_state using above test case.

Steps to reproduce the behavior:
import pandas as pd
from uszipcode import SearchEngine
searchObject = SearchEngine(simple_zipcode=True)
strCity='burien'
strState='WA'
res = searchObject.by_city_and_state(strCity, strState, returns=100)
res[0]
SimpleZipcode(zipcode='98233', zipcode_type='Standard', major_city='Burlington', post_office_city='Burlington, WA', common_city_list=['Burlington'], county='Skagit County', state='WA', lat=48.5, lng=-122.4, timezone='Pacific', radius_in_miles=10.0, area_code_list=['360'], population=14871, population_density=439.0, land_area_in_sqmi=33.85, water_area_in_sqmi=0.26, housing_units=5897, occupied_housing_units=5522, median_home_value=232700, median_household_income=52906, bounds_west=-122.444478, bounds_east=-122.285302, bounds_north=48.620048, bounds_south=48.444658)

Expected behavior
Should match on 'burien' as that is a valid city in WA.

Screenshots
see above, code snippet

Additional context

I love your work, and hope it helps to report this issue. keep it up.
I am working on a workaround to this issue, to search by state, and then try to find the match myself for the city name, which defeats some of the purpose of this awesome library. Wondering if there is a better pattern or workaround I could consider, if the above is just a side effect of fuzzy matching. Thanks so much.

Incomplete results using Search Engine

Describe the bug

The results of using the search engine with 2 different methods shown in the documentation yields incomplete results. I have used both the search.query() as well as search.by_state()

To Reproduce

Steps to reproduce the behavior:

   from uszipcode import Zipcode 
   from uszipcode import SearchEngine 

   # Create a search engine object 
   search = SearchEngine() 
   # Get all the zip codes in the desired location 
   result = search.query(city="Long Island", state="NY") 
   
   # This yields a list of length 2. That is incorrect. Long Island has more zip codes than just 2 

   # Search using .by_state() method 
   res = search.by_state("New York")
   
   # This yields just 5 zip codes. Again, the state has more than 5 zip codes. It has 2,150 zip codes

Expected behavior

I would expect the package methods to list all the zip codes based on valid search criteria. If some are excluded, providing a brief explanation in the documentation on what kind of zip codes are excluded will be very helpful.

Screenshots

  • Expected results for zip codes in long island
    image

  • Expected results for zip codes in New York
    image

  • Results from the code
    image

image

Additional context

SearchEngine.by_zipcode(zipcode) Only returns Standard Zipcode

Describe the bug

SearchEngine.by_zipcode should able to only any type of zipcode, and unlike other query methods, it doesn't have zipcode_type option.

To Reproduce

Steps to reproduce the behavior:

from uszipcode import SearchEngine

search = SearchEngine()
search.by_zipcode(48874).lat # is None, but it actually exists and has valid lat, lng

Solution

add zipcode_type=None to by_zipcode method.

Thanks for @derekep to report

Missing location for lat/long

The following lat/long (which are all in Alaska) don't map to a location. And the city names don't map to a zip code.

ATKA | AK | 52.19844444 | -174.1976389
AKUTAN | AK | 54.13411111 | -165.7736389
FALSE PASS | AK | 54.8555 | -163.4141944
KING COVE | AK | 55.05938889 | -162.3106111
COLD BAY | AK | 55.20605556 | -162.7075556
SAND POINT | AK | 55.34313889 | -160.4899444
NELSON LAGOON | AK | 56.00111111 | -161.2039722
CHIGNIK LAKE | AK | 56.25363889 | -158.7620278
ST. GEORGE | AK | 56.60436111 | -169.5516111
PORT HEIDEN | AK | 56.93811111 | -158.5992778
ST. PAUL | AK | 57.12119444 | -170.2814444
EGEGIK | AK | 58.21452778 | -157.3762778
TOGIAK | AK | 59.06088889 | -160.3774722
DILLINGHAM | AK | 59.06202778 | -158.4697222
GOODNEWS BAY | AK | 59.11819444 | -161.5892778
ALEKNAGIK | AK | 59.27897222 | -158.6188611
NEW STUYAHOK | AK | 59.45175 | -157.3107778
KOLIGANEK | AK | 59.72761111 | -157.2841389
ILIAMNA | AK | 59.75263889 | -154.8460556
KWIGILLINGOK | AK | 59.86422222 | -163.1378333
KONGIGANAK | AK | 59.95922222 | -162.8939444
NONDALTON | AK | 59.97375 | -154.8491111
EEK | AK | 60.21811111 | -162.0219722
NIGHTMUTE | AK | 60.47752778 | -164.7223056
TANUNAK | AK | 60.58252778 | -165.2611667
BETHEL | AK | 60.79175 | -161.7750833
KWETHLUK | AK | 60.81175 | -161.4356111
LIME VILLAGE | AK | 61.35541667 | -155.4383889
ANIAK | AK | 61.58122222 | -159.5671389
CROOKED CREEK | AK | 61.87038889 | -158.1040556
HOLY CROSS | AK | 62.19872222 | -159.7704167
ALAKANUK | AK | 62.68336111 | -164.6513056
MCGRATH | AK | 62.94991667 | -155.5884444
KOTLIK | AK | 63.03255556 | -163.5546667
ST. MICHAEL | AK | 63.47786111 | -162.0410556
SAVOONGA | AK | 63.69536111 | -170.4783333
GAMBELL | AK | 63.77841667 | -171.7308611
SHAKTOOLIK | AK | 64.35427778 | -161.1919722
NOME | AK | 64.50341667 | -165.4005278
ELIM | AK | 64.61677778 | -162.2581111
RUBY | AK | 64.73911111 | -155.4882778
TANANA | AK | 65.17280556 | -152.0797222
HUSLIA | AK | 65.69855556 | -156.3998056
CIRCLE | AK | 65.82686111 | -144.0685833
BUCKLAND | AK | 65.97877778 | -161.1249167
SHISHMAREF | AK | 66.25508333 | -166.0722222
BEAVER | AK | 66.35875 | -147.3975833
ALLAKAKET | AK | 66.56422222 | -152.6465278
FORT YUKON | AK | 66.56436111 | -145.2659167
CHALKYITSIK | AK | 66.64994444 | -143.7276111
KOTZEBUE | AK | 66.90102778 | -162.5901944
AMBLER | AK | 67.08719444 | -157.8527778
KIVALINA | AK | 67.72652778 | -164.5370556
ANAKTUVUK PASS | AK | 68.1415 | -151.7336111
POINT LAY | AK | 69.73605556 | -163.01625
ATQASUK | AK | 70.46897222 | -157.3977778
WAINWRIGHT | AK | 70.63141667 | -160.0200556

Historic Data

Hi, this is an awesome and great package. Thanks a lot for that. Can you please say whether it is possible to somehow access the historic data?

[PY2.7] import uszipcode raise Import Error

Describe the bug

We use uszipcode in python2.7 for historical reason

after an update we can't import uszipdecode anymore

To Reproduce
install latest version of uszipcode using pip for python2.7 (--force-reinstall if needed)

then

$ python2.7
Python 2.7.18 (default, Aug 24 2020, 19:12:23) 
[GCC 10.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import uszipcode
cannot import name ExtendedBase
>>> from uszipcode import SearchEngine
cannot import name ExtendedBase
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name SearchEngine

It seem related to the latest build which didn't upgrade the package version.
It is still in 0.2.4 on pypi

Edit 2021-04-12

After futher investigation
we use the package sqlalchemy_mate

But the path of latest build don't include this change

Incorrect/misleading zipcodes

I am looking at zip codes in the Southern California area and noticed a few lat/long coordinates that returned zip code that do not correspond to the zip code that google maps returns:

For example, when I look up 34.0352, -118.2583 via Google maps I get 90015, whereas the package returns 90079:

search.by_coordinate(lng=-118.2583, lat=34.0352, radius=50, returns=1)

[{"City": "Los Angeles", "Density": 0.0, "HouseOfUnits": 0, "LandArea": 0.01, "Latitude": 34.0405313, "Longitude": -118.25540320000002, "NEBoundLatitude": 34.041599, "NEBoundLongitude": -118.254093, "Population": 0, "SWBoundLatitude": 34.039571, "SWBoungLongitude": -118.256716, "State": "CA", "TotalWages": null, "WaterArea": 0.0, "Wealthy": null, "Zipcode": "90079", "ZipcodeType": "Standard"},
{"City": "Los Angeles", "Density": 11102.923976608188, "HouseOfUnits": 8245, "LandArea": 1.71, "Latitude": 34.0390107, "Longitude": -118.2672801, "NEBoundLatitude": 34.053104, "NEBoundLongitude": -118.2492601, "Population": 18986, "SWBoundLatitude": 34.02588, "SWBoungLongitude": -118.28284599999999, "State": "CA", "TotalWages": 196952937.0, "WaterArea": 0.0, "Wealthy": 10373.587748867589, "Zipcode": "90015", "ZipcodeType": "Standard"}]

If I expand the returns variable to >1 then I do see that the correct zip code is in the second entry.

Another example is 34.048, -118.2577, but this time it doesn't return the "correct" (according to Google maps) zip code until the 4th entry.

search.by_coordinate(lng=-118.2577, lat=34.048, radius=50, returns=4)

[{"City": "Los Angeles", "Density": 125.0, "HouseOfUnits": 0, "LandArea": 0.12, "Latitude": 34.052996, "Longitude": -118.2548551, "NEBoundLatitude": 34.056087, "NEBoundLongitude": -118.250157, "Population": 15, "SWBoundLatitude": 34.048743, "SWBoungLongitude": -118.259363, "State": "CA", "TotalWages": 75762361.0, "WaterArea": 0.0, "Wealthy": 5050824.066666666, "Zipcode": "90071", "ZipcodeType": "Standard"},
{"City": "Los Angeles", "Density": 25017.857142857138, "HouseOfUnits": 4990, "LandArea": 0.28, "Latitude": 34.0434783, "Longitude": -118.2519314, "NEBoundLatitude": 34.050176, "NEBoundLongitude": -118.24524, "Population": 7005, "SWBoundLatitude": 34.037303, "SWBoungLongitude": -118.257926, "State": "CA", "TotalWages": 91984035.0, "WaterArea": 0.0, "Wealthy": 13131.197002141329, "Zipcode": "90014", "ZipcodeType": "Standard"},
{"City": "Los Angeles", "Density": 0.0, "HouseOfUnits": 0, "LandArea": 0.01, "Latitude": 34.0405313, "Longitude": -118.25540320000002, "NEBoundLatitude": 34.041599, "NEBoundLongitude": -118.254093, "Population": 0, "SWBoundLatitude": 34.039571, "SWBoungLongitude": -118.256716, "State": "CA", "TotalWages": null, "WaterArea": 0.0, "Wealthy": null, "Zipcode": "90079", "ZipcodeType": "Standard"},
{"City": "Los Angeles", "Density": 32558.90410958904, "HouseOfUnits": 10610, "LandArea": 0.73, "Latitude": 34.054379700000005, "Longitude": -118.2672801, "NEBoundLatitude": 34.060871, "NEBoundLongitude": -118.2541801, "Population": 23768, "SWBoundLatitude": 34.043726899999996, "SWBoungLongitude": -118.27431299999999, "State": "CA", "TotalWages": 229419093.0, "WaterArea": 0.0, "Wealthy": 9652.435753954898, "Zipcode": "90017", "ZipcodeType": "Standard"}]

Partial results in common_city_list

while trying to query the common_city_list using zipcode, package gives partial results.

Ex: for zipcode 99505 --> common_city_list

search.by_zipcode("99505").to_dict()["common_city_list"]
['Jber', 'Anchorage', 'Fort Richardson', 'Ft Richardso...']

Missing Zipcodes

Hello,

First of all, I need to say that this is an awesome project. Very helpful.
Thank you so much.

While this was not a problem for me, I found the following zip codes did not return any data when queried within the uszipcode-project. I am raising this bug report as an FYI only.

The zip codes with format 008XX are for Virgin Islands and those with format 969XX are for Guam/American Samoa.

ZIPCODE_ZCTA | GEOID | ALAND | AWATER | LATITUDE | LONGITUDE
00801 | 00801 | 2875853 | 1354 | 18.3498707 | -64.9740158
00802 | 00802 | 71671243 | 8928497 | 18.3407091 | -64.9233287
00820 | 00820 | 78982024 | 3075492 | 17.7431002 | -64.6865559
00823 | 00823 | 1035362 | 0 | 17.7235479 | -64.7459318
00824 | 00824 | 57053 | 0 | 17.7445568 | -64.6829328
00830 | 00830 | 50003826 | 374670 | 18.3385589 | -64.7365301
00831 | 00831 | 119891 | 0 | 18.3272939 | -64.7867198
00840 | 00840 | 48724800 | 22578 | 17.7478722 | -64.8806949
00841 | 00841 | 6600893 | 632642 | 17.7681345 | -64.8078517
00850 | 00850 | 60060282 | 3028705 | 17.7052534 | -64.7525564
00851 | 00851 | 19685283 | 71124 | 17.7322277 | -64.7707604
96799 | 96799 | 197672934 | 1164503 | -14.3233846 | -170.7502395
96910 | 96910 | 39144820 | 137543 | 13.4505692 | 144.7507227
96913 | 96913 | 63776792 | 0 | 13.4778382 | 144.814519
96915 | 96915 | 212399590 | 16628595 | 13.3774806 | 144.7022783
96916 | 96916 | 8146159 | 0 | 13.2603723 | 144.7006789
96917 | 96917 | 46482180 | 125441 | 13.3009464 | 144.7398106
96921 | 96921 | 469596 | 0 | 13.4591223 | 144.7940327
96928 | 96928 | 1189070 | 2939 | 13.3845367 | 144.6612982
96929 | 96929 | 171450550 | 0 | 13.5650982 | 144.8762401
96932 | 96932 | 499553 | 0 | 13.4754276 | 144.7417503
96950 | 96950 | 118883306 | 185857 | 15.1868936 | 145.7543957
96951 | 96951 | 85098741 | 19201 | 14.1524934 | 145.2129037
96952 | 96952 | 101224486 | 727567 | 15.0097681 | 145.6211273

Subodh.

Import error using SQLAlchemy v1.4

uszipcode requires sqlalchemy as a dependency; but no version is specified so it will always install the latest version.

SQLAlchemy==1.4 was released yesterday. One of the changes is that

from sqlalchemy.ext.declarative.api import DeclarativeMeta

used on uszipcode-project/uszipcode/pkg/sqlalchemy_mate/pt.py raises an import error. However, on uszipcode it is being ignored by a try except call.

So, a fresh install of uszipcode will produce a ImportError: cannot import name 'SearchEngine' when trying to import the SearchEngine.

To Reproduce

Steps to reproduce the behavior:

  1. Create a fresh virtualenv
  2. Run pip install uszipcode
  3. Try to run from uszipcode import SearchEngine on the shell
  4. See error

Expected behavior

It should raise a versions error or something more telling; the try except being used on uszipcode-project/uszipcode/pkg/sqlalchemy_mate/__init__.py is reducing the obtained feedback and it may be confusing to new users.

Thank you,

Library stopped working, crash on boot

I have been using uszipcode for months and it suddenly stopped working. I did not change anything in my requirements.txt or anything else that could have caused this issue. Now when I try to restart my server I get the following:

2021-02-22T04:11:59.344048+00:00 app[web.1]: Exception ignored in: <bound method SearchEngine.__del__ of <uszipcode.search.SearchEngine object at 0x7fd84bc16a58>>
2021-02-22T04:11:59.344112+00:00 app[web.1]: Traceback (most recent call last):
2021-02-22T04:11:59.344153+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/uszipcode/search.py", line 112, in __del__
2021-02-22T04:11:59.345406+00:00 app[web.1]:     if self.ses:
2021-02-22T04:11:59.348880+00:00 app[web.1]: AttributeError: 'SearchEngine' object has no attribute 'ses'
2021-02-22T04:11:59.909128+00:00 app[web.1]: [2021-02-22 04:11:59 +0000] [34] [INFO] Booting worker with pid: 34
2021-02-22T04:11:59.955068+00:00 app[web.1]: [2021-02-22 04:11:59 +0000] [36] [INFO] Booting worker with pid: 36
2021-02-22T04:12:00.027154+00:00 app[web.1]: [2021-02-22 04:12:00 +0000] [37] [INFO] Booting worker with pid: 37
2021-02-22T04:12:00.033332+00:00 app[web.1]: [2021-02-22 04:12:00 +0000] [38] [INFO] Booting worker with pid: 38
2021-02-22T04:12:03.765888+00:00 app[web.1]: Start downloading data for simple zipcode database, total size 9MB ...
2021-02-22T04:12:04.192924+00:00 app[web.1]: Start downloading data for simple zipcode database, total size 9MB ...
2021-02-22T04:12:04.636695+00:00 app[web.1]: Start downloading data for simple zipcode database, total size 9MB ...
2021-02-22T04:12:04.956754+00:00 app[web.1]: Start downloading data for simple zipcode database, total size 9MB ...
2021-02-22T04:12:30.254613+00:00 app[web.1]: [2021-02-22 04:12:30 +0000] [4] [CRITICAL] WORKER TIMEOUT (pid:34)
2021-02-22T04:12:30.254810+00:00 app[web.1]: [2021-02-22 04:12:30 +0000] [4] [CRITICAL] WORKER TIMEOUT (pid:36)
2021-02-22T04:12:30.255022+00:00 app[web.1]: [2021-02-22 04:12:30 +0000] [4] [CRITICAL] WORKER TIMEOUT (pid:37)
2021-02-22T04:12:30.257715+00:00 app[web.1]: [2021-02-22 04:12:30 +0000] [36] [INFO] Worker exiting (pid: 36)
2021-02-22T04:12:30.262161+00:00 app[web.1]: [2021-02-22 04:12:30 +0000] [4] [CRITICAL] WORKER TIMEOUT (pid:38)
2021-02-22T04:12:30.263997+00:00 app[web.1]: Exception ignored in: <bound method SearchEngine.__del__ of <uszipcode.search.SearchEngine object at 0x7fd84bc54b38>>
2021-02-22T04:12:30.264057+00:00 app[web.1]: Traceback (most recent call last):
2021-02-22T04:12:30.264097+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/uszipcode/search.py", line 112, in __del__
2021-02-22T04:12:30.265194+00:00 app[web.1]:     if self.ses:
2021-02-22T04:12:30.265253+00:00 app[web.1]: AttributeError: 'SearchEngine' object has no attribute 'ses'
2021-02-22T04:12:30.268294+00:00 app[web.1]: [2021-02-22 04:12:30 +0000] [34] [INFO] Worker exiting (pid: 34)
2021-02-22T04:12:30.271511+00:00 app[web.1]: Exception ignored in: <bound method SearchEngine.__del__ of <uszipcode.search.SearchEngine object at 0x7fd84bc54b38>>
2021-02-22T04:12:30.271569+00:00 app[web.1]: Traceback (most recent call last):
2021-02-22T04:12:30.271607+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/uszipcode/search.py", line 112, in __del__
2021-02-22T04:12:30.271855+00:00 app[web.1]: [2021-02-22 04:12:30 +0000] [37] [INFO] Worker exiting (pid: 37)
2021-02-22T04:12:30.272425+00:00 app[web.1]:     if self.ses:
2021-02-22T04:12:30.272431+00:00 app[web.1]: AttributeError: 'SearchEngine' object has no attribute 'ses'
2021-02-22T04:12:30.273443+00:00 app[web.1]: Exception ignored in: <bound method SearchEngine.__del__ of <uszipcode.search.SearchEngine object at 0x7fd84bc54ac8>>
2021-02-22T04:12:30.273480+00:00 app[web.1]: Traceback (most recent call last):
2021-02-22T04:12:30.273512+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/uszipcode/search.py", line 112, in __del__
2021-02-22T04:12:30.274135+00:00 app[web.1]:     if self.ses:
2021-02-22T04:12:30.274169+00:00 app[web.1]: AttributeError: 'SearchEngine' object has no attribute 'ses'
2021-02-22T04:12:30.319813+00:00 app[web.1]: [2021-02-22 04:12:30 +0000] [38] [INFO] Worker exiting (pid: 38)
2021-02-22T04:12:30.328268+00:00 app[web.1]: Exception ignored in: <bound method SearchEngine.__del__ of <uszipcode.search.SearchEngine object at 0x7fd84bc54b38>>
2021-02-22T04:12:30.328276+00:00 app[web.1]: Traceback (most recent call last):
2021-02-22T04:12:30.328329+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/uszipcode/search.py", line 112, in __del__
2021-02-22T04:12:30.329134+00:00 app[web.1]:     if self.ses:
2021-02-22T04:12:30.329139+00:00 app[web.1]: AttributeError: 'SearchEngine' object has no attribute 'ses'

Population update cycle and source for the population

Hello, thanks for this awesome tool.
I had question related to the population data. Is it using Census dataset (only) for the population count? and how often the population data is getting updated? when was the last time the population was updated?
I tried to look into this by checking all the documentation and even issues but was little unclear. It would be great if you can help me on this!

documentation bug: returns & the number of zips in chicago

The documentation says that this:

# Looking for Chicago and IL, but entered wrong spelling.
>>> res = search.by_city_and_state("cicago", "il")
>>> len(res) # 56 zipcodes in Chicago
56

will print 56 at the end.

However:

  1. It actually prints 5 because it's using the default value of returns=5
  2. If I supply returns=5000, so the number of zips isn't limited, the result is not 56 but 58.

Link broken in documentation

On your documentation page, http://www.wbh-doc.com.s3.amazonaws.com/uszipcode/index.html, in the first "Basic Search" section, you have a line that reads:

For all available zipcode attributes, click here.

The link for "click here" is file:///C:/Users/shu/Documents/PythonWorkSpace/py3/py33_projects/uszipcode-project/build/html/uszipcode/searchengine.html#uszipcode.searchengine.Zipcode

Can you upload this page to your site, so I can see the full attribute list?

Possible to know sources of data

Would be great to know the data-sources, and year for the data. Particularly relevant when using this data to build/update machine learning models.

Change database location

Is there an easy way to change the database location? Unable to get this working in AWS because the db file is located in a different directory.

Suggest explicitly mentioning that the database is separate from the Python package

I've been evaluating using your package and it looks initially like this project is really useful.

However currently it is not clear from the description of the package that the underlying database is not actually part of the distributed package and instead is downloaded separately on first use. Obviously this makes the package far less appealing for a variety of use-cases. I appreciate that there is mention of dumping the sqlite database to another database server for deployment as a web service, and that the database file location can be configured, however I think it would be great if this separation and download were mentioned upfront in the readme.

Missing longitude & latitude for Toledo, OH 43660

Thanks for this good tool. Please add the longitude and latitude data for Toledo, OH.

by_zipcode(43660)

43660
SimpleZipcode(zipcode='43660', zipcode_type='Unique', major_city='Toledo', post_office_city=None, common_city_list=['Toledo'], county='Lucas County', state='OH', lat=None, lng=None, timezone=None, radius_in_miles=None, area_code_list=['419'], population=None, population_density=None, land_area_in_sqmi=None, water_area_in_sqmi=None, housing_units=None, occupied_housing_units=None, median_home_value=None, median_household_income=None, bounds_west=None, bounds_east=None, bounds_north=None, bounds_south=None)

Location / URL to find definition of each variable?

Hello,

I've been using this library and it has been quite amazing (simple to use and easy to get the data out). However, many of the detailed variables like families_vs_singles are left unexplained...I tried to look it up in the US Census main website but that has been difficult to navigate. Do you have a place to point us to if we are trying to find what these variables are/mean?

For example, does Single_Guardian under families_vs_singles mean single parent with children?

Licensing issues from direct inclusion of dependencies

I've been evaluating using your package in a project with relatively strict licensing requirements. It looks initially like this project is really useful, however I spotted that you currently vendor in some dependencies (in uszipcode/pkg) rather than declaring them at the package level.

While I can see that one of them (sqlalchemy-mate) is another of your own packages and that haversine is also licensed under MIT, the fuzzywuzzy package appears to currently be licensed under GPLv2 and is thus incompatible with being distributed as part of an MIT-licensed distribution as this package does. The fuzzywuzzy package's license does appear to have changed (seatgeek/fuzzywuzzy#131, seatgeek/fuzzywuzzy@d079d6b) from MIT to GPLv2 a few years ago, so perhaps the version you're embedding predates that?

If not, you may wish to review the licensing status of the packages to ensure that your package is compliant. At the very least please consider including in your README a mention of the packages which are being included and the licenses they're under.

Latitude Longitude in ocean for 94121

Great tool thanks!

Was testing with some local zip codes though and noticed that the latitude, longitude for 94121 is miles off in the ocean, for whatever it's worth.

uszipcode silently redownloads the database in case of corruption

Describe the bug

If the dataset is corrupted in some way, uszipcode will silently redownload it.

To Reproduce

Steps to reproduce the behavior:

  1. In a Python console, run import uszipcode; uszipcode.SearchEngine() to trigger a download
  2. Run echo > path/to/simple_db.sqlite to truncate the file
  3. Run step 1 again
  4. Notice how the file is redownloaded, with no mention of the corrupted file

Expected behavior

At the very least a warning should be logged to console. I think probably this should throw an exception though. The current behavior can be really confusing in environments where this file is vendored into a deploy artifact, but something goes wrong with the deploy. (In our case it was that Git LFS wasn't configured, so we got the "pointer" file instead of the actual database.) That's why I think it's better to just error out: it makes it much, much easier to notice the problem.

Screenshots

N/A

Additional context

N/A

Radius Calculation

Hey there has to be a bug with the by_coordinate method on certian lat,lng calculations.
Try it with Lat 42.3612999 Long -88.0899304 (which are the coordinates pulled for zipcode 60073).

I came across this while looking for a 30 mile radius search for zipcodes based on 60073.

Search by City/State returns Puerto Rico if City/State are None

Describe the bug

Using a SearchEngine method "by_city_and_state" returns an unexpected result if one accidentally passes Nones. It can be handled by not doing this, obviously, but it makes sense I think to be consistent.

To Reproduce

ZIP_SEARCH_ENGINE = SearchEngine()

ZIP_SEARCH_ENGINE.by_city_and_state(None, None)

Output :

[Zipcode(zipcode_type='Standard', major_city='Adjuntas', post_office_city=None, common_city_list=['Adjuntas'] .... ..... ..... educational_attainment_for_population_25_and_over=None, school_enrollment_age_3_to_17=None)]

Expected behavior

We should get a ZipCode object back that has None in every field, or simply None. However it appears default behavior of .by_zipcode() is to return a ZipCode object with all fields populated with Nones.

If we do this :

ZIP_SEARCH_ENGINE.by_zipcode(None)

We get something like :
Zipcode(zipcode_type=None, major_city=None, post_office_city=None ..... ..... educational_attainment_for_population_25_and_over=None, school_enrollment_age_3_to_17=None)

search.all() function is no longer available

I have been using the search.all() function in a previous version of this code to loop over all zipcodes in the database. Is it still possible to access the list of all zipcodes? If not can this feature be added back in?
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.