A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
--create geometry columns | |
ALTER TABLE vta_wkday_od_database ADD COLUMN origin_geom geometry(Point, 4326); | |
ALTER TABLE vta_wkday_od_database ADD COLUMN first_board_geom geometry(Point, 4326); | |
--create geometry from latitude and longitude columns | |
UPDATE vta_wkday_od_database SET first_board_geom = ST_SetSRID(ST_MakePoint(first_board_lon::double precision, first_board_lat::double precision), 4326); | |
UPDATE vta_wkday_od_database SET origin_geom = ST_SetSRID(ST_MakePoint(origin_lon::double precision, origin_lat::double precision), 4326); | |
--change to 2227 so that calculations are in feet not meters. | |
ALTER TABLE vta_wkday_od_database |
import geopands as gpd | |
from shapely.geometry.polygon import Polygon | |
from shapely.geometry.multipolygon import MultiPolygon | |
def explode(indata): | |
indf = gpd.GeoDataFrame.from_file(indata) | |
outdf = gpd.GeoDataFrame(columns=indf.columns) | |
for idx, row in indf.iterrows(): | |
if type(row.geometry) == Polygon: | |
outdf = outdf.append(row,ignore_index=True) |
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
#!/bin/bash | |
# Sometimes you need to move your existing git repository | |
# to a new remote repository (/new remote origin). | |
# Here are a simple and quick steps that does exactly this. | |
# | |
# Let's assume we call "old repo" the repository you wish | |
# to move, and "new repo" the one you wish to move to. | |
# | |
### Step 1. Make sure you have a local copy of all "old repo" | |
### branches and tags. |
<html> | |
<head> | |
<link rel="stylesheet" type="text/css" href="http://wcfcourier.com/app/special/data_tables/media/css/demo_page.css"> | |
<link rel="stylesheet" type="text/css" href="http://wcfcourier.com/app/special/data_tables/media/css/demo_table.css"> | |
<style> | |
table { | |
font-size: 12px; | |
font-family: Arial, Helvetica, sans-serif; | |
float: left; |