Skip to content

Instantly share code, notes, and snippets.

@MrMaksimize
MrMaksimize / useful_pandas_snippets.py
Last active December 6, 2016 18:01 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a

1. Load data

  • Setup postgres or your database or choice.
  • Download the onebusaway gtfs loader.
  • Find the appropriate database jar (postgresql, 9.4-1201 JDBC 41 is what I used)
java -classpath path/to/onebusaway-gtfs-hibernate-cli-1.3.4.jar:path/to/postgresql-9.4-1201.jdbc41.jar \
  org.onebusaway.gtfs.GtfsDatabaseLoaderMain \
  --driverClass=org.postgresql.Driver \
@joshuapowell
joshuapowell / gist:e209a4dac5c8187ea8ce
Last active March 11, 2023 18:37
Setup Postgres.app to use PostGIS on OS X

Download and Install Postgres.app

Before we can setup PostGIS we need to have a local version of Postgresql installed and running. The most effecient way to do this is to download and install Postgres.app.

Spatially Enable your Postgres Database

Once Postgres.app is installed in your computers /Applications directory. Open the Terminal and enter the following two commands

psql -d DATABASE_NAME -f /Applications/Postgres.app/Contents/Versions/9.3/share/postgresql/contrib/postgis-2.1/postgis.sql
@rubenvarela
rubenvarela / gist:11332904
Created April 26, 2014 22:31
JS to remove accents in spanish including "diéresis"
accentsTidy = function(s){
var r=s.toLowerCase();
r = r.replace(new RegExp(/\s/g),"");
r = r.replace(new RegExp(/[á]/g),"a");
r = r.replace(new RegExp(/[é]/g),"e");
r = r.replace(new RegExp(/[í]/g),"i");
r = r.replace(new RegExp(/ñ/g),"n");
r = r.replace(new RegExp(/[ó]/g),"o");
r = r.replace(new RegExp(/[úü]/g),"u");
return r;
@daguar
daguar / a-moral-inquiry.md
Last active August 29, 2015 13:58
"A moral inquiry" (George Saunders, excerpt from Tent City USA)

A Moral Inquiry

Retreating down G Street, the PR considered the white girl with red hair. Was she being held against her will? Likely she was a junkie, in some sort of long-term relationship with the tall man, who served as her pimp. Who had she been before she was the white girl with red hair? The PR reminded himself that the white girl with red hair had been a whore in that tent long before he arrived and would be a whore in that tent long after he left. All of these people had been living thus before he arrived and would continue living thus long after he went home. Anything he could do for them would only comprise a small push in a positive direction before the tremendous momentum of their negative tendencies reasserted itself. The PR was put in mind of a single shot from a gun being fired into a massive orbiting planet.

Still, what would happen if he decided to abandon the Study and commit all of his resources to the sole purpose of extracting the white girl with red hair from that tent and getting

@bensheldon
bensheldon / advice_for_cfa_fellows.md
Last active August 2, 2023 16:50
A summary of conversations I've had with current, former and future Code for America fellows.
  • Who's your customer? The department or the citizen. What’s your product? The negotiated-design process or the actual outcome itself. These things are interrelated, but ensure the entire team is aligned and in agreement on what it is you’re doing and what the outcome is you want. What do you want to say you built at the end-of-year summit? The earlier you can figure this out, the better your year will go. Project uncertainty is the mind-killer.

  • Don't negotiate with yourselves. My team would have achieved so much more if we had come to an agreement internally on how to proceed in our city design negotiations, and let CfA staff tell us if we were unreasonable. Instead, we watered down what we wanted, caved on major issues, and negotiated individually with our city partners rather than as a team.

  • Invest your time in one thing for the entire year. Your understanding of the civic problem-space may change and evolve, but creating a commitment (individually, as a team, and in your city-

@MrMaksimize
MrMaksimize / vptest.info
Last active December 24, 2015 12:49 — forked from voxpelli/vptest.info
name = VoxPelli OAuth Test
core = 7.x
dependencies[] = oauth_common
dependencies[] = http_client
channels = (
{ name = "#allplayers"; chatnet = "freenode"; autojoin = "yes"; },
{ name = "#api-craft"; chatnet = "freenode"; autojoin = "yes"; },
{ name = "#Node.js"; chatnet = "freenode"; autojoin = "yes"; },
{ name = "#drupal"; chatnet = "freenode"; autojoin = "yes"; },
{ name = "#drupal-chicago"; chatnet = "freenode"; autojoin = "yes"; },
{ name = "#cadug"; chatnet = "freenode"; autojoin = "yes"; },
{ name = "#drupal-wscci"; chatnet = "freenode"; autojoin = "yes"; },
{ name = "#drupal-services"; chatnet = "freenode"; autojoin = "yes"; },
{ name = "#drupal-contribute"; chatnet = "freenode"; autojoin = "yes"; },