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)
/* Scale a value from one range to another | |
* Example of use: | |
* | |
* // Convert 33 from a 0-100 range to a 0-65535 range | |
* var n = scaleValue(33, [0,100], [0,65535]); | |
* | |
* // Ranges don't have to be positive | |
* var n = scaleValue(0, [-50,+50], [0,65535]); | |
* | |
* Ranges are defined as arrays of two values, inclusive |
# Some good references are: | |
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x | |
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/ | |
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392 | |
#1. Install PostgreSQL postgis and postgres | |
brew install postgis | |
initdb /usr/local/var/postgres | |
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start |
# http://docs.neo4j.org/chunked/snapshot/rest-api-traverse.html#rest-api-traversal-returning-nodes-below-a-certain-depth | |
try: | |
import simplejson as json | |
except ImportError: | |
import json | |
from neo4jrestclient import client | |
from neo4jrestclient.request import Request | |
from neo4jrestclient.request import NotFoundError |
import os | |
# Automatically set the __all__ variable with all | |
# the available plugins. | |
plugin_dir = "plugins" | |
__all__ = [] | |
for filename in os.listdir(plugin_dir): | |
filename = plugin_dir + "/" + filename |
from decimal import Decimal | |
try: | |
import simplejson as json | |
except ImportError: | |
import json | |
from django.utils.functional import Promise | |
class CustomJSONEncoder(json.JSONEncoder): |
#!/bin/bash | |
STARTPAGE=2 | |
ENDPAGE=75 | |
SOURCE=book.pdf | |
OUTPUT=book.txt | |
RESOLUTION=600 | |
LAYOUT="1" | |
[[ -e out.txt ]] && rm out.txt | |
for i in `seq $STARTPAGE $ENDPAGE`; do |
""" | |
Implementation of the shifted beta geometric (sBG) model from "How to Project Customer Retention" (Fader and Hardie 2006) | |
http://www.brucehardie.com/papers/021/sbg_2006-05-30.pdf | |
Apache 2 License | |
""" | |
from math import log |
""" | |
Implementation of the beta-geometric/NBD (BG/NBD) model from '"Counting Your Customers" the Easy Way: An Alternative to | |
the Pareto/NBD Model' (Fader, Hardie and Lee 2005) http://brucehardie.com/papers/018/fader_et_al_mksc_05.pdf and | |
accompanying technical note http://www.brucehardie.com/notes/004/ | |
Apache 2 License | |
""" | |
from math import log, exp | |
import numpy as np |
#!/bin/bash | |
# Author: Maxwel Leite | |
# Website: http://needforbits.wordpress.com/ | |
# Description: Script to install Microsoft Vista TrueType Fonts (TTF) aka Microsoft’s ClearType fonts on Ubuntu distros | |
# Microsoft added a group of new "ClearType Fonts" to Windows with Windows Vista and Office 2007. | |
# These fonts are named Constantia, Corbel, Calibri, Cambria (and Cambria Math), Candara, and Consolas. | |
# Calibri became the default font on Microsoft Word 2007, and it’s still the default font on Word 2016 today. | |
# Dependencies: wget, fontforge and cabextract | |
# Note: Microsoft no longer provides the PowerPoint Viewer 2007 (v12.0.4518.1014) or any version anymore for download | |
# Tested: Ubuntu Saucy/Trusty/Xenial/Bionic |
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)