from geopandas import GeoDataFrame
from shapely.geometry import Point
def to_gdf(df, lon, lat, crs={'init': 'epsg:4326'}):
'''Converts a pandas dataframe with coordinate columns to a geopandas dataframe.
Inputs:
df: pandas dataframe
lon: str; name of longitude column
lat: str; name of Latitude column
crs: dict; projection type
Returns:
gdf: Geopandas dataframe
'''
geometry = [Point(xy) for xy in zip(df[f'{lon}'], df[f'{lat}'])]
df = df.drop([f'{lon}', f'{lat}'], axis=1)
crs = {'init': 'epsg:4326'}
gdf = GeoDataFrame(df, crs=crs, geometry=geometry)
return gdf