title: How to get Dataframe with associated Zip codes from Lat and Long in python?
body: <p>I am trying to reverse Geocode and get the zip codes.
  I have a table / dataframe that has 400,000 lat and long and I would like to get the zip code by parsing the lat,long.</p>
  
  <p>Below is the sample dataframe</p>
  
  <pre><code>data = {'Site 1': '31.336968, -109.560959',
          'Site 2': '31.347745, -108.229963',
          'Site 3': '32.277621, -107.734724',
          'Site 4': '31.655494, -106.420484',
          'Site 5': '30.295053, -104.014528'}
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>import geopandas as gpd
  from shapely.geometry import Point
  gdf_locations = gpd.read_file('/Users/admin/Downloads/tl_2016_us_zcta510/tl_2016_us_zcta510.shp')
  </code></pre>
  
  <p>I downloaded the <code>tl_2016_us_zcta510.shp</code> file from <a href="https://catalog.data.gov/dataset/tiger-line-shapefile-2016-2010-nation-u-s-2010-census-5-digit-zip-code-tabulation-area-zcta5-na" rel="nofollow noreferrer">here.</a></p>
  
  <p>This is where I am getting stuck. One solution that I tried was to convert it to <code>NUMPY</code> array and pass the value. But that seems extremely slow.
  I would like to do it as a dataframe using <code>lambda</code> and get the results quickly.</p>
  
  <p>What I tried:</p>
  
  <pre><code>               [Longitude]    [Latitude]
  x = np.array((-73.986946106, 40.284328461))
  x_pnt = Point(x)
  filter = gdf_locations['geometry'].contains(x_pnt)
  print(gdf_locations.loc[filter, 'GEOID10'])
  </code></pre>
  
  <p>While this is giving me what I want, it is extremely slow.
  How can I make it faster and as a recursive function?
  Any help is appreciated. Thank you.</p>
  
  <p>P.S: I have seen many blog posts and read stuff on this subject, but none seems to address it for large scale real-time implementation.</p>
  
  <p><strong>Edits:</strong>
  I am specifically looking to get a dataframe with following structure:</p>
  
  <pre><code> data = {'Site 1': '31.336968, -109.560959', 94108,
              'Site 2': '31.347745, -108.229963', 60616,
              'Site 3': '32.277621, -107.734724', 78654,
              'Site 4': '31.655494, -106.420484', 78090,
              'Site 5': '30.295053, -104.014528', 78901}
  </code></pre>
  
  <p>I understand how to convert lat long to Zip, what I'm not able to do is get a dataframe. Hope this makes it more clear. </p>