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)
#------------------------------------------------------------------------------ | |
# Make things VirtualEnv aware (Windows version). | |
# More info: http://www.swegler.com/becky/blog/2011/08/28/python-django-mysql-on-windows-7-part-3-ipython-virtual-environments/ | |
# add this to the end of ipython_config | |
# (or course, for virtualenvs created via --no-site-packages, it would | |
# be much easier just to install iPython) | |
#------------------------------------------------------------------------------ | |
import sys | |
import site | |
from os import environ |
import django | |
django.VERSION |
#Alternate to the django-admin.py startproject command. | |
#In windows, using 'django-admin.py startproject' is problematic...the .py extension | |
#is associated with the main install of Python, not the install on the current virtualenv, which fouls things up (e.g., import errors). Code below: | |
#1. forces module mode, which will check the path for django-admin (interpreter searches the path for modules but not for scripts) | |
#2. no more .py extension | |
#see http://stackoverflow.com/questions/2542674/no-matter-what-i-do-django-admin-py-is-not-found-even-though-its-in-my-path | |
-m django-admin startproject tutorial |
#create the database | |
CREATE DATABASE [dbname] CHARACTER SET utf8; | |
#create user | |
CREATE USER 'django_user'@'localhost' IDENTIFIED BY 'thepassword'; | |
#give user permissions to db (probably not a great idea to GRANT ALL unless you really have to) | |
# (replace django.* with [mydatabasename].*) | |
GRANT ALL ON django.* TO 'django_user'@'localhost'; |
<script type="text/javascript" src="/media/uploads/publications/presidents_budget_fy2013/swfobject.js"></script> | |
<script type="text/javascript"> | |
// For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. | |
var swfVersionStr = "11.1.0"; | |
// To use express install, set to playerProductInstall.swf, otherwise the empty string. | |
var xiSwfUrlStr = "/media/uploads/publications/presidents_budget_fy2013/playerProductInstall.swf"; | |
var flashvars = {datafile: "/media/uploads/publications/presidents_budget_fy2013/info/budget-category.txt"} | |
var params = {}; | |
params.quality = "high"; | |
params.bgcolor = "#ffffff"; |
# adopted from https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git#SetupSSHforGit-installpublickey, which was adopted from a GitHub script | |
if [ -r ~/.profile ]; then . ~/.profile; fi | |
case "$-" in *i*) if [ -r ~/.bashrc ]; then . ~/.bashrc; fi;; esac | |
echo | |
echo "Yo" | |
echo | |
SSH_ENV="$HOME/.ssh/environment" |
Vagrant::Config.run do |config| | |
config.vm.define :pythondata do |pythondata_config| | |
# Every Vagrant virtual environment requires a box to build off of. | |
pythondata_config.vm.box = "precise64" | |
# The url from where the 'config.vm.box' box will be fetched if it | |
# doesn't already exist on the user's system. | |
pythondata_config.vm.box_url = "http://files.vagrantup.com/precise64.box" | |
# Forward a port from the guest to the host, which allows for outside |
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)
#tabedata.txt is a file that contains the piped markdown table rows | |
with open ('markdownrows.txt') as f: | |
content = f.readlines() | |
rows = [] | |
for c in content: | |
cells = c.split('|') | |
cells = ['<td>{}</td>'.format(cell.strip()) for cell in cells] | |
rows.append(cells) |