This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| from geopandas import GeoDataFrame | |
| from shapely.geometry import Point | |
| import fiona | |
| df = pd.read_csv('data.csv') | |
| geometry = [Point(xy) for xy in zip(df.x, df.y)] | |
| crs = {'init': 'epsg:2263'} #http://www.spatialreference.org/ref/epsg/2263/ | |
| geo_df = GeoDataFrame(df, crs=crs, geometry=geometry) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from time import sleep | |
| from io import StringIO | |
| import psycopg2 | |
| def upsert_df_into_postgres(df, target_table, primary_keys, conn_string, | |
| n_trials=5, quoting=None, null_repr=None): | |
| """ | |
| Uploads data from `df` to `target_table` |