You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+83-4Lines changed: 83 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,13 +9,92 @@
9
9
10
10
Welcome to uszipcode Documentation
11
11
==================================
12
-
``uszipcode`` is the most powerful and easy to use zipcode information searchengine in Python. Besides geometry data (also boundary info), several useful census data points are also served: `population`, `population density`, `total wage`, `average annual wage`, `house of units`, `land area`, `water area`. The geometry and geocoding data I am using is from google map API on Oct 2015. To know more about the data, `click here <http://pythonhosted.org/uszipcode/uszipcode/data/__init__.html#module-uszipcode.data>`_. `Another pupolar zipcode Python extension <https://pypi.python.org/pypi/zipcode>`_ has lat, lng accuracy issue, which doesn't give me reliable results of searching by coordinate and radius.
12
+
``uszipcode`` is the **most powerful and easy to use programmable zipcode database, and also a searchengine** in Python. Besides geometry data (also boundary info), several useful census data points are also served: `population`, `population density`, `total wage`, `average annual wage`, `house of units`, `land area`, `water area`. The geometry and geocoding data I am using is from google map API on Mar 2016. `To know more about the data, click here <http://pythonhosted.org/uszipcode/uszipcode/data/__init__.html#module-uszipcode.data>`_. Another `popular zipcode Python extension <https://pypi.python.org/pypi/zipcode>`_ has lat, lng accuracy issue, which doesn't give me reliable results of searching by coordinate and radius.
13
13
14
14
**Highlight**:
15
15
16
-
1. `Rich methods <http://pythonhosted.org/uszipcode/index.html#list-of-the-way-you-can-search>`_ are provided for getting zipcode anyway you want.
17
-
2. `Fuzzy city name and state name <http://pythonhosted.org/uszipcode/index.html#search-by-city-and-state>`_ allows you to search **WITHOUT using exactly accurate input**. **This is very helpful if you need to build a web app with it**.
18
-
3. You can easily `sort your results <http://pythonhosted.org/uszipcode/index.html#sortby-descending-and-returns-keyword>`_ by `population`, `area`, `wealthy` and etc...
16
+
- `Rich information <http://pythonhosted.org/uszipcode/uszipcode/searchengine.html#uszipcode.searchengine.Zipcode>`_ of zipcode is available.
17
+
18
+
.. code-block:: python
19
+
20
+
>>>from uszipcode import ZipcodeSearchEngine
21
+
>>> search = ZipcodeSearchEngine()
22
+
>>> zipcode = search.by_zipcode("10001")
23
+
>>>print(zipcode)
24
+
{
25
+
"City": "New York",
26
+
"Density": 34035.48387096774,
27
+
"HouseOfUnits": 12476,
28
+
"LandArea": 0.62,
29
+
"Latitude": 40.75368539999999,
30
+
"Longitude": -73.9991637,
31
+
"NEBoundLatitude": 40.8282129,
32
+
"NEBoundLongitude": -73.9321059,
33
+
"Population": 21102,
34
+
"SWBoundLatitude": 40.743451,
35
+
"SWBoungLongitude": -74.00794499999998,
36
+
"State": "NY",
37
+
"TotalWages": 1031960117.0,
38
+
"WaterArea": 0.0,
39
+
"Wealthy": 48903.42702113544,
40
+
"Zipcode": "10001",
41
+
"ZipcodeType": "Standard"
42
+
}
43
+
44
+
- `Rich search methods <http://pythonhosted.org/uszipcode/index.html#list-of-the-way-you-can-search>`_ are provided for getting zipcode in the way you want.
45
+
46
+
.. code-block:: python
47
+
48
+
# Search zipcode within 30 miles, ordered from closest to farthest
49
+
>>> res = search.by_coordinate(39.122229, -77.133578, radius=30, returns=5)
50
+
>>>len(res) # by default 5 results returned
51
+
5
52
+
>>>for zipcode in res:
53
+
...# do whatever you want...
54
+
55
+
# Find top 10 population zipcode
56
+
>>> res = search.by_population(lower=0, upper=999999999,
>>> res = search.find(city="newyork", wealthy_lower=100000,
65
+
...sort_by="Wealthy", returns=10) # at least $100,000 annual income
66
+
67
+
- `Fuzzy city name and state name search <http://pythonhosted.org/uszipcode/index.html#search-by-city-and-state>`_ **enables case, space insensitive, typo tolerant input**. **You don't have to know the correct spelling of the city or state**. This is very helpful if you need to build a web app with it.
68
+
69
+
.. code-block:: python
70
+
71
+
# Looking for Chicago and IL, but entered wrong spelling.
72
+
>>> res = search.by_city_and_state("cicago", "il")
73
+
>>>len(res) # 56 zipcodes in Chicago
74
+
56
75
+
>>> zipcode = res[0]
76
+
>>> zipcode.City
77
+
'Chicago'
78
+
>>> zipcode.State
79
+
'IL'
80
+
81
+
- You can easily `sort your results <http://pythonhosted.org/uszipcode/index.html#sortby-descending-and-returns-keyword>`_ by `population`, `area`, `wealthy` and etc...
82
+
83
+
.. code-block:: python
84
+
85
+
# Find top 10 population zipcode
86
+
>>> res = search.by_population(lower=0, upper=999999999,
``by_city_and_state``, ``by_city``, ``by_state``, ``by_prefix``, ``by_population``, ``by_density``, ``by_totalwages``, ``by_wealthy``, ``by_house`` methods all support ``sort_by``, ``ascending`` keyword.
296
348
297
-
Here's an example to find the top 100 richest zipcode, sorted by average annual wage:
349
+
- ``sort_by``: attribute name(s), case insensitive. Accepts an attribute name or a list for a nested sort. By default ordered by ``Zipcode``. All valid attribute name is :class:`listed here <uszipcode.searchengine.Zipcode>`
350
+
- ``ascending``: boolean or list, default ``True``, sort ascending vs. descending. Specify list for multiple sort orders
298
351
299
352
.. code-block:: python
300
353
301
-
>>> res = search.by_wealthy(lower=100000, sortby="Wealthy", descending=True, returns=100)
354
+
# Search zipcode that average annual income per person greater than $100,000
355
+
>>> res = search.by_wealthy(lower=100000, sort_by="Wealthy", ascending=True)
302
356
>>>for zipcode in res:
303
-
...# do whatever you want...
357
+
...print(zipcode.Wealthy) # should be in ascending order
0 commit comments