I have two pandas DataFrames with Address
, Lat
and Long
as columns. I'd like to find rows that are duplicates between the 2 dataframes based on the intersection of their coordinates. I'll define the logic for intersection as two points that within 50ft of each other.
import pandas as pd
df1 = pd.DataFrame({'addr': ['NBC Tower, 455 N Cityfront Plaza Dr #2700, Chicago, IL 60611, United States','340 E North Water St, Chicago, IL 60611, United States'],
'Lat': [41.890100, 41.889680],
'Lon': [-87.621150, -87.618790]
})
df1 = pd.DataFrame({'addr': ['455 N Cityfront Plaza Dr #2900, Chicago, IL 60611, United States','255 E Grand Ave, Chicago, IL 60611, United States'],
'Lat': [41.890100, 41.891392],
'Lon': [-87.621150, -87.621323]
})
If the intersection between the coordinates is less than 50ft
, then insert match
, otherwise insert No match found
.
Would prefer to have a function that find the intersection and use .apply
. Something like below:
def find_geomatch(args...):
if match:
txt = 'match'
else:
txt = 'No match found'
return txt
df1['geomatch'] = df1.apply(lambda x: geomatch(x), axis=1)
df2 = ...
for'455 N Cityfront Plaza Dr #2900, Chicago, IL 60611, United States','255 E Grand Ave, Chicago, IL 60611, United States'
?