We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
TST: use a different geocoder than GeocodeFarm in geocoding tests
The CI is failing under geopy new version 2.2.

The error from https://github.com/geopandas/geopandas/runs/3042280515?check_suite_focus=true#step:5:2930:

`GeocodeFarm` has been removed under geopy2.2, see geopy/geopy#445.

```python
_________________________________ test_forward _________________________________
[gw0] linux -- Python 3.7.7 /usr/share/miniconda/envs/test/bin/python

locations = ['260 Broadway, New York, NY', '77 Massachusetts Ave, Cambridge, MA']
points = [<shapely.geometry.point.Point object at 0x7f0ec0b22a10>, <shapely.geometry.point.Point object at 0x7f0ec0b22510>]

    def test_forward(locations, points):
>       from geopy.geocoders import GeocodeFarm
E       ImportError: cannot import name 'GeocodeFarm' from 'geopy.geocoders' (/usr/share/miniconda/envs/test/lib/python3.7/site-packages/geopy/geocoders/__init__.py)

geopandas/tests/test_geocode.py:141: ImportError
_________________________________ test_reverse _________________________________
[gw0] linux -- Python 3.7.7 /usr/share/miniconda/envs/test/bin/python

locations = ['260 Broadway, New York, NY', '77 Massachusetts Ave, Cambridge, MA']
points = [<shapely.geometry.point.Point object at 0x7f0ec0b39250>, <shapely.geometry.point.Point object at 0x7f0ec0b39c10>]

    def test_reverse(locations, points):
>       from geopy.geocoders import GeocodeFarm
E       ImportError: cannot import name 'GeocodeFarm' from 'geopy.geocoders' (/usr/share/miniconda/envs/test/lib/python3.7/site-packages/geopy/geocoders/__init__.py)

geopandas/tests/test_geocode.py:158: ImportError
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `geopandas/tools/geocoding.py`
Content:
```
1 from collections import defaultdict
2 import time
3 
4 import pandas as pd
5 
6 from shapely.geometry import Point
7 
8 import geopandas
9 
10 
11 def _get_throttle_time(provider):
12     """
13     Amount of time to wait between requests to a geocoding API, for providers
14     that specify rate limits in their terms of service.
15     """
16     import geopy.geocoders
17 
18     # https://operations.osmfoundation.org/policies/nominatim/
19     if provider == geopy.geocoders.Nominatim:
20         return 1
21     else:
22         return 0
23 
24 
25 def geocode(strings, provider=None, **kwargs):
26     """
27     Geocode a set of strings and get a GeoDataFrame of the resulting points.
28 
29     Parameters
30     ----------
31     strings : list or Series of addresses to geocode
32     provider : str or geopy.geocoder
33         Specifies geocoding service to use. If none is provided,
34         will use 'geocodefarm' with a rate limit applied (see the geocodefarm
35         terms of service at:
36         https://geocode.farm/geocoding/free-api-documentation/ ).
37 
38         Either the string name used by geopy (as specified in
39         geopy.geocoders.SERVICE_TO_GEOCODER) or a geopy Geocoder instance
40         (e.g., geopy.geocoders.GeocodeFarm) may be used.
41 
42         Some providers require additional arguments such as access keys
43         See each geocoder's specific parameters in geopy.geocoders
44 
45     Notes
46     -----
47     Ensure proper use of the results by consulting the Terms of Service for
48     your provider.
49 
50     Geocoding requires geopy. Install it using 'pip install geopy'. See also
51     https://github.com/geopy/geopy
52 
53     Examples
54     --------
55     >>> df = geopandas.tools.geocode(  # doctest: +SKIP
56     ...         ["boston, ma", "1600 pennsylvania ave. washington, dc"]
57     ...     )
58     >>> df  # doctest: +SKIP
59                         geometry                                            address
60     0  POINT (-71.05863 42.35899)                          Boston, MA, United States
61     1  POINT (-77.03651 38.89766)  1600 Pennsylvania Ave NW, Washington, DC 20006...
62     """
63 
64     if provider is None:
65         # https://geocode.farm/geocoding/free-api-documentation/
66         provider = "geocodefarm"
67         throttle_time = 0.25
68     else:
69         throttle_time = _get_throttle_time(provider)
70 
71     return _query(strings, True, provider, throttle_time, **kwargs)
72 
73 
74 def reverse_geocode(points, provider=None, **kwargs):
75     """
76     Reverse geocode a set of points and get a GeoDataFrame of the resulting
77     addresses.
78 
79     The points
80 
81     Parameters
82     ----------
83     points : list or Series of Shapely Point objects.
84         x coordinate is longitude
85         y coordinate is latitude
86     provider : str or geopy.geocoder (opt)
87         Specifies geocoding service to use. If none is provided,
88         will use 'geocodefarm' with a rate limit applied (see the geocodefarm
89         terms of service at:
90         https://geocode.farm/geocoding/free-api-documentation/ ).
91 
92         Either the string name used by geopy (as specified in
93         geopy.geocoders.SERVICE_TO_GEOCODER) or a geopy Geocoder instance
94         (e.g., geopy.geocoders.GeocodeFarm) may be used.
95 
96         Some providers require additional arguments such as access keys
97         See each geocoder's specific parameters in geopy.geocoders
98 
99     Notes
100     -----
101     Ensure proper use of the results by consulting the Terms of Service for
102     your provider.
103 
104     Reverse geocoding requires geopy. Install it using 'pip install geopy'.
105     See also https://github.com/geopy/geopy
106 
107     Examples
108     --------
109     >>> from shapely.geometry import Point
110     >>> df = geopandas.tools.reverse_geocode(  # doctest: +SKIP
111     ...     [Point(-71.0594869, 42.3584697), Point(-77.0365305, 38.8977332)]
112     ... )
113     >>> df  # doctest: +SKIP
114                          geometry                                            address
115     0  POINT (-71.05941 42.35837)       29 Court Sq, Boston, MA 02108, United States
116     1  POINT (-77.03641 38.89766)  1600 Pennsylvania Ave NW, Washington, DC 20006...
117     """
118 
119     if provider is None:
120         # https://geocode.farm/geocoding/free-api-documentation/
121         provider = "geocodefarm"
122         throttle_time = 0.25
123     else:
124         throttle_time = _get_throttle_time(provider)
125 
126     return _query(points, False, provider, throttle_time, **kwargs)
127 
128 
129 def _query(data, forward, provider, throttle_time, **kwargs):
130     # generic wrapper for calls over lists to geopy Geocoders
131     from geopy.geocoders.base import GeocoderQueryError
132     from geopy.geocoders import get_geocoder_for_service
133 
134     if not isinstance(data, pd.Series):
135         data = pd.Series(data)
136 
137     if isinstance(provider, str):
138         provider = get_geocoder_for_service(provider)
139 
140     coder = provider(**kwargs)
141     results = {}
142     for i, s in data.items():
143         try:
144             if forward:
145                 results[i] = coder.geocode(s)
146             else:
147                 results[i] = coder.reverse((s.y, s.x), exactly_one=True)
148         except (GeocoderQueryError, ValueError):
149             results[i] = (None, None)
150         time.sleep(throttle_time)
151 
152     df = _prepare_geocode_result(results)
153     return df
154 
155 
156 def _prepare_geocode_result(results):
157     """
158     Helper function for the geocode function
159 
160     Takes a dict where keys are index entries, values are tuples containing:
161     (address, (lat, lon))
162 
163     """
164     # Prepare the data for the DataFrame as a dict of lists
165     d = defaultdict(list)
166     index = []
167 
168     for i, s in results.items():
169 
170         if s is None:
171             p = Point()
172             address = None
173 
174         else:
175             address, loc = s
176 
177             # loc is lat, lon and we want lon, lat
178             if loc is None:
179                 p = Point()
180             else:
181                 p = Point(loc[1], loc[0])
182 
183         d["geometry"].append(p)
184         d["address"].append(address)
185         index.append(i)
186 
187     df = geopandas.GeoDataFrame(d, index=index, crs="EPSG:4326")
188 
189     return df
190
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/geopandas/tools/geocoding.py b/geopandas/tools/geocoding.py
--- a/geopandas/tools/geocoding.py
+++ b/geopandas/tools/geocoding.py
@@ -31,13 +31,12 @@
     strings : list or Series of addresses to geocode
     provider : str or geopy.geocoder
         Specifies geocoding service to use. If none is provided,
-        will use 'geocodefarm' with a rate limit applied (see the geocodefarm
-        terms of service at:
-        https://geocode.farm/geocoding/free-api-documentation/ ).
+        will use 'photon' (see the Photon's terms of service at:
+        https://photon.komoot.io).
 
         Either the string name used by geopy (as specified in
         geopy.geocoders.SERVICE_TO_GEOCODER) or a geopy Geocoder instance
-        (e.g., geopy.geocoders.GeocodeFarm) may be used.
+        (e.g., geopy.geocoders.Photon) may be used.
 
         Some providers require additional arguments such as access keys
         See each geocoder's specific parameters in geopy.geocoders
@@ -62,11 +61,8 @@
     """
 
     if provider is None:
-        # https://geocode.farm/geocoding/free-api-documentation/
-        provider = "geocodefarm"
-        throttle_time = 0.25
-    else:
-        throttle_time = _get_throttle_time(provider)
+        provider = "photon"
+    throttle_time = _get_throttle_time(provider)
 
     return _query(strings, True, provider, throttle_time, **kwargs)
 
@@ -85,13 +81,12 @@
         y coordinate is latitude
     provider : str or geopy.geocoder (opt)
         Specifies geocoding service to use. If none is provided,
-        will use 'geocodefarm' with a rate limit applied (see the geocodefarm
-        terms of service at:
-        https://geocode.farm/geocoding/free-api-documentation/ ).
+        will use 'photon' (see the Photon's terms of service at:
+        https://photon.komoot.io).
 
         Either the string name used by geopy (as specified in
         geopy.geocoders.SERVICE_TO_GEOCODER) or a geopy Geocoder instance
-        (e.g., geopy.geocoders.GeocodeFarm) may be used.
+        (e.g., geopy.geocoders.Photon) may be used.
 
         Some providers require additional arguments such as access keys
         See each geocoder's specific parameters in geopy.geocoders
@@ -117,11 +112,8 @@
     """
 
     if provider is None:
-        # https://geocode.farm/geocoding/free-api-documentation/
-        provider = "geocodefarm"
-        throttle_time = 0.25
-    else:
-        throttle_time = _get_throttle_time(provider)
+        provider = "photon"
+    throttle_time = _get_throttle_time(provider)
 
     return _query(points, False, provider, throttle_time, **kwargs)

{"golden_diff": "diff --git a/geopandas/tools/geocoding.py b/geopandas/tools/geocoding.py\n--- a/geopandas/tools/geocoding.py\n+++ b/geopandas/tools/geocoding.py\n@@ -31,13 +31,12 @@\n     strings : list or Series of addresses to geocode\n     provider : str or geopy.geocoder\n         Specifies geocoding service to use. If none is provided,\n-        will use 'geocodefarm' with a rate limit applied (see the geocodefarm\n-        terms of service at:\n-        https://geocode.farm/geocoding/free-api-documentation/ ).\n+        will use 'photon' (see the Photon's terms of service at:\n+        https://photon.komoot.io).\n \n         Either the string name used by geopy (as specified in\n         geopy.geocoders.SERVICE_TO_GEOCODER) or a geopy Geocoder instance\n-        (e.g., geopy.geocoders.GeocodeFarm) may be used.\n+        (e.g., geopy.geocoders.Photon) may be used.\n \n         Some providers require additional arguments such as access keys\n         See each geocoder's specific parameters in geopy.geocoders\n@@ -62,11 +61,8 @@\n     \"\"\"\n \n     if provider is None:\n-        # https://geocode.farm/geocoding/free-api-documentation/\n-        provider = \"geocodefarm\"\n-        throttle_time = 0.25\n-    else:\n-        throttle_time = _get_throttle_time(provider)\n+        provider = \"photon\"\n+    throttle_time = _get_throttle_time(provider)\n \n     return _query(strings, True, provider, throttle_time, **kwargs)\n \n@@ -85,13 +81,12 @@\n         y coordinate is latitude\n     provider : str or geopy.geocoder (opt)\n         Specifies geocoding service to use. If none is provided,\n-        will use 'geocodefarm' with a rate limit applied (see the geocodefarm\n-        terms of service at:\n-        https://geocode.farm/geocoding/free-api-documentation/ ).\n+        will use 'photon' (see the Photon's terms of service at:\n+        https://photon.komoot.io).\n \n         Either the string name used by geopy (as specified in\n         geopy.geocoders.SERVICE_TO_GEOCODER) or a geopy Geocoder instance\n-        (e.g., geopy.geocoders.GeocodeFarm) may be used.\n+        (e.g., geopy.geocoders.Photon) may be used.\n \n         Some providers require additional arguments such as access keys\n         See each geocoder's specific parameters in geopy.geocoders\n@@ -117,11 +112,8 @@\n     \"\"\"\n \n     if provider is None:\n-        # https://geocode.farm/geocoding/free-api-documentation/\n-        provider = \"geocodefarm\"\n-        throttle_time = 0.25\n-    else:\n-        throttle_time = _get_throttle_time(provider)\n+        provider = \"photon\"\n+    throttle_time = _get_throttle_time(provider)\n \n     return _query(points, False, provider, throttle_time, **kwargs)\n", "issue": "TST: use a different geocoder than GeocodeFarm in geocoding tests\nThe CI is failing under geopy new version 2.2.\r\n\r\nThe error from https://github.com/geopandas/geopandas/runs/3042280515?check_suite_focus=true#step:5:2930:\r\n\r\n`GeocodeFarm` has been removed under geopy2.2, see geopy/geopy#445.\r\n\r\n```python\r\n_________________________________ test_forward _________________________________\r\n[gw0] linux -- Python 3.7.7 /usr/share/miniconda/envs/test/bin/python\r\n\r\nlocations = ['260 Broadway, New York, NY', '77 Massachusetts Ave, Cambridge, MA']\r\npoints = [<shapely.geometry.point.Point object at 0x7f0ec0b22a10>, <shapely.geometry.point.Point object at 0x7f0ec0b22510>]\r\n\r\n    def test_forward(locations, points):\r\n>       from geopy.geocoders import GeocodeFarm\r\nE       ImportError: cannot import name 'GeocodeFarm' from 'geopy.geocoders' (/usr/share/miniconda/envs/test/lib/python3.7/site-packages/geopy/geocoders/__init__.py)\r\n\r\ngeopandas/tests/test_geocode.py:141: ImportError\r\n_________________________________ test_reverse _________________________________\r\n[gw0] linux -- Python 3.7.7 /usr/share/miniconda/envs/test/bin/python\r\n\r\nlocations = ['260 Broadway, New York, NY', '77 Massachusetts Ave, Cambridge, MA']\r\npoints = [<shapely.geometry.point.Point object at 0x7f0ec0b39250>, <shapely.geometry.point.Point object at 0x7f0ec0b39c10>]\r\n\r\n    def test_reverse(locations, points):\r\n>       from geopy.geocoders import GeocodeFarm\r\nE       ImportError: cannot import name 'GeocodeFarm' from 'geopy.geocoders' (/usr/share/miniconda/envs/test/lib/python3.7/site-packages/geopy/geocoders/__init__.py)\r\n\r\ngeopandas/tests/test_geocode.py:158: ImportError\r\n```\n", "before_files": [{"content": "from collections import defaultdict\nimport time\n\nimport pandas as pd\n\nfrom shapely.geometry import Point\n\nimport geopandas\n\n\ndef _get_throttle_time(provider):\n    \"\"\"\n    Amount of time to wait between requests to a geocoding API, for providers\n    that specify rate limits in their terms of service.\n    \"\"\"\n    import geopy.geocoders\n\n    # https://operations.osmfoundation.org/policies/nominatim/\n    if provider == geopy.geocoders.Nominatim:\n        return 1\n    else:\n        return 0\n\n\ndef geocode(strings, provider=None, **kwargs):\n    \"\"\"\n    Geocode a set of strings and get a GeoDataFrame of the resulting points.\n\n    Parameters\n    ----------\n    strings : list or Series of addresses to geocode\n    provider : str or geopy.geocoder\n        Specifies geocoding service to use. If none is provided,\n        will use 'geocodefarm' with a rate limit applied (see the geocodefarm\n        terms of service at:\n        https://geocode.farm/geocoding/free-api-documentation/ ).\n\n        Either the string name used by geopy (as specified in\n        geopy.geocoders.SERVICE_TO_GEOCODER) or a geopy Geocoder instance\n        (e.g., geopy.geocoders.GeocodeFarm) may be used.\n\n        Some providers require additional arguments such as access keys\n        See each geocoder's specific parameters in geopy.geocoders\n\n    Notes\n    -----\n    Ensure proper use of the results by consulting the Terms of Service for\n    your provider.\n\n    Geocoding requires geopy. Install it using 'pip install geopy'. See also\n    https://github.com/geopy/geopy\n\n    Examples\n    --------\n    >>> df = geopandas.tools.geocode(  # doctest: +SKIP\n    ...         [\"boston, ma\", \"1600 pennsylvania ave. washington, dc\"]\n    ...     )\n    >>> df  # doctest: +SKIP\n                        geometry                                            address\n    0  POINT (-71.05863 42.35899)                          Boston, MA, United States\n    1  POINT (-77.03651 38.89766)  1600 Pennsylvania Ave NW, Washington, DC 20006...\n    \"\"\"\n\n    if provider is None:\n        # https://geocode.farm/geocoding/free-api-documentation/\n        provider = \"geocodefarm\"\n        throttle_time = 0.25\n    else:\n        throttle_time = _get_throttle_time(provider)\n\n    return _query(strings, True, provider, throttle_time, **kwargs)\n\n\ndef reverse_geocode(points, provider=None, **kwargs):\n    \"\"\"\n    Reverse geocode a set of points and get a GeoDataFrame of the resulting\n    addresses.\n\n    The points\n\n    Parameters\n    ----------\n    points : list or Series of Shapely Point objects.\n        x coordinate is longitude\n        y coordinate is latitude\n    provider : str or geopy.geocoder (opt)\n        Specifies geocoding service to use. If none is provided,\n        will use 'geocodefarm' with a rate limit applied (see the geocodefarm\n        terms of service at:\n        https://geocode.farm/geocoding/free-api-documentation/ ).\n\n        Either the string name used by geopy (as specified in\n        geopy.geocoders.SERVICE_TO_GEOCODER) or a geopy Geocoder instance\n        (e.g., geopy.geocoders.GeocodeFarm) may be used.\n\n        Some providers require additional arguments such as access keys\n        See each geocoder's specific parameters in geopy.geocoders\n\n    Notes\n    -----\n    Ensure proper use of the results by consulting the Terms of Service for\n    your provider.\n\n    Reverse geocoding requires geopy. Install it using 'pip install geopy'.\n    See also https://github.com/geopy/geopy\n\n    Examples\n    --------\n    >>> from shapely.geometry import Point\n    >>> df = geopandas.tools.reverse_geocode(  # doctest: +SKIP\n    ...     [Point(-71.0594869, 42.3584697), Point(-77.0365305, 38.8977332)]\n    ... )\n    >>> df  # doctest: +SKIP\n                         geometry                                            address\n    0  POINT (-71.05941 42.35837)       29 Court Sq, Boston, MA 02108, United States\n    1  POINT (-77.03641 38.89766)  1600 Pennsylvania Ave NW, Washington, DC 20006...\n    \"\"\"\n\n    if provider is None:\n        # https://geocode.farm/geocoding/free-api-documentation/\n        provider = \"geocodefarm\"\n        throttle_time = 0.25\n    else:\n        throttle_time = _get_throttle_time(provider)\n\n    return _query(points, False, provider, throttle_time, **kwargs)\n\n\ndef _query(data, forward, provider, throttle_time, **kwargs):\n    # generic wrapper for calls over lists to geopy Geocoders\n    from geopy.geocoders.base import GeocoderQueryError\n    from geopy.geocoders import get_geocoder_for_service\n\n    if not isinstance(data, pd.Series):\n        data = pd.Series(data)\n\n    if isinstance(provider, str):\n        provider = get_geocoder_for_service(provider)\n\n    coder = provider(**kwargs)\n    results = {}\n    for i, s in data.items():\n        try:\n            if forward:\n                results[i] = coder.geocode(s)\n            else:\n                results[i] = coder.reverse((s.y, s.x), exactly_one=True)\n        except (GeocoderQueryError, ValueError):\n            results[i] = (None, None)\n        time.sleep(throttle_time)\n\n    df = _prepare_geocode_result(results)\n    return df\n\n\ndef _prepare_geocode_result(results):\n    \"\"\"\n    Helper function for the geocode function\n\n    Takes a dict where keys are index entries, values are tuples containing:\n    (address, (lat, lon))\n\n    \"\"\"\n    # Prepare the data for the DataFrame as a dict of lists\n    d = defaultdict(list)\n    index = []\n\n    for i, s in results.items():\n\n        if s is None:\n            p = Point()\n            address = None\n\n        else:\n            address, loc = s\n\n            # loc is lat, lon and we want lon, lat\n            if loc is None:\n                p = Point()\n            else:\n                p = Point(loc[1], loc[0])\n\n        d[\"geometry\"].append(p)\n        d[\"address\"].append(address)\n        index.append(i)\n\n    df = geopandas.GeoDataFrame(d, index=index, crs=\"EPSG:4326\")\n\n    return df\n", "path": "geopandas/tools/geocoding.py"}], "after_files": [{"content": "from collections import defaultdict\nimport time\n\nimport pandas as pd\n\nfrom shapely.geometry import Point\n\nimport geopandas\n\n\ndef _get_throttle_time(provider):\n    \"\"\"\n    Amount of time to wait between requests to a geocoding API, for providers\n    that specify rate limits in their terms of service.\n    \"\"\"\n    import geopy.geocoders\n\n    # https://operations.osmfoundation.org/policies/nominatim/\n    if provider == geopy.geocoders.Nominatim:\n        return 1\n    else:\n        return 0\n\n\ndef geocode(strings, provider=None, **kwargs):\n    \"\"\"\n    Geocode a set of strings and get a GeoDataFrame of the resulting points.\n\n    Parameters\n    ----------\n    strings : list or Series of addresses to geocode\n    provider : str or geopy.geocoder\n        Specifies geocoding service to use. If none is provided,\n        will use 'photon' (see the Photon's terms of service at:\n        https://photon.komoot.io).\n\n        Either the string name used by geopy (as specified in\n        geopy.geocoders.SERVICE_TO_GEOCODER) or a geopy Geocoder instance\n        (e.g., geopy.geocoders.Photon) may be used.\n\n        Some providers require additional arguments such as access keys\n        See each geocoder's specific parameters in geopy.geocoders\n\n    Notes\n    -----\n    Ensure proper use of the results by consulting the Terms of Service for\n    your provider.\n\n    Geocoding requires geopy. Install it using 'pip install geopy'. See also\n    https://github.com/geopy/geopy\n\n    Examples\n    --------\n    >>> df = geopandas.tools.geocode(  # doctest: +SKIP\n    ...         [\"boston, ma\", \"1600 pennsylvania ave. washington, dc\"]\n    ...     )\n    >>> df  # doctest: +SKIP\n                        geometry                                            address\n    0  POINT (-71.05863 42.35899)                          Boston, MA, United States\n    1  POINT (-77.03651 38.89766)  1600 Pennsylvania Ave NW, Washington, DC 20006...\n    \"\"\"\n\n    if provider is None:\n        provider = \"photon\"\n    throttle_time = _get_throttle_time(provider)\n\n    return _query(strings, True, provider, throttle_time, **kwargs)\n\n\ndef reverse_geocode(points, provider=None, **kwargs):\n    \"\"\"\n    Reverse geocode a set of points and get a GeoDataFrame of the resulting\n    addresses.\n\n    The points\n\n    Parameters\n    ----------\n    points : list or Series of Shapely Point objects.\n        x coordinate is longitude\n        y coordinate is latitude\n    provider : str or geopy.geocoder (opt)\n        Specifies geocoding service to use. If none is provided,\n        will use 'photon' (see the Photon's terms of service at:\n        https://photon.komoot.io).\n\n        Either the string name used by geopy (as specified in\n        geopy.geocoders.SERVICE_TO_GEOCODER) or a geopy Geocoder instance\n        (e.g., geopy.geocoders.Photon) may be used.\n\n        Some providers require additional arguments such as access keys\n        See each geocoder's specific parameters in geopy.geocoders\n\n    Notes\n    -----\n    Ensure proper use of the results by consulting the Terms of Service for\n    your provider.\n\n    Reverse geocoding requires geopy. Install it using 'pip install geopy'.\n    See also https://github.com/geopy/geopy\n\n    Examples\n    --------\n    >>> from shapely.geometry import Point\n    >>> df = geopandas.tools.reverse_geocode(  # doctest: +SKIP\n    ...     [Point(-71.0594869, 42.3584697), Point(-77.0365305, 38.8977332)]\n    ... )\n    >>> df  # doctest: +SKIP\n                         geometry                                            address\n    0  POINT (-71.05941 42.35837)       29 Court Sq, Boston, MA 02108, United States\n    1  POINT (-77.03641 38.89766)  1600 Pennsylvania Ave NW, Washington, DC 20006...\n    \"\"\"\n\n    if provider is None:\n        provider = \"photon\"\n    throttle_time = _get_throttle_time(provider)\n\n    return _query(points, False, provider, throttle_time, **kwargs)\n\n\ndef _query(data, forward, provider, throttle_time, **kwargs):\n    # generic wrapper for calls over lists to geopy Geocoders\n    from geopy.geocoders.base import GeocoderQueryError\n    from geopy.geocoders import get_geocoder_for_service\n\n    if not isinstance(data, pd.Series):\n        data = pd.Series(data)\n\n    if isinstance(provider, str):\n        provider = get_geocoder_for_service(provider)\n\n    coder = provider(**kwargs)\n    results = {}\n    for i, s in data.items():\n        try:\n            if forward:\n                results[i] = coder.geocode(s)\n            else:\n                results[i] = coder.reverse((s.y, s.x), exactly_one=True)\n        except (GeocoderQueryError, ValueError):\n            results[i] = (None, None)\n        time.sleep(throttle_time)\n\n    df = _prepare_geocode_result(results)\n    return df\n\n\ndef _prepare_geocode_result(results):\n    \"\"\"\n    Helper function for the geocode function\n\n    Takes a dict where keys are index entries, values are tuples containing:\n    (address, (lat, lon))\n\n    \"\"\"\n    # Prepare the data for the DataFrame as a dict of lists\n    d = defaultdict(list)\n    index = []\n\n    for i, s in results.items():\n\n        if s is None:\n            p = Point()\n            address = None\n\n        else:\n            address, loc = s\n\n            # loc is lat, lon and we want lon, lat\n            if loc is None:\n                p = Point()\n            else:\n                p = Point(loc[1], loc[0])\n\n        d[\"geometry\"].append(p)\n        d[\"address\"].append(address)\n        index.append(i)\n\n    df = geopandas.GeoDataFrame(d, index=index, crs=\"EPSG:4326\")\n\n    return df\n", "path": "geopandas/tools/geocoding.py"}]}