Skip to content

Instantly share code, notes, and snippets.

@apolloclark
apolloclark / postgres cheatsheet.md
Last active March 7, 2024 13:53
postgres cheatsheet

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL

@bsweger
bsweger / useful_pandas_snippets.md
Last active April 9, 2024 10:22
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@ebrelsford
ebrelsford / nycproj2latlon.sql
Last active December 21, 2015 05:39
Convert a table with coordinates in NAD_1983_StatePlane_New_York_Long_Island_FIPS_3104_Feet (common for NYC data) to lat and lon in 4326. We first convert the coordinates from feet to meters.
UPDATE graffiti_locations
SET the_geom = ST_Transform(
ST_SetSRID(
ST_MakePoint(x * 0.3048006096012192, y * 0.3048006096012192),
32118),
4326
)