Skip to content

Instantly share code, notes, and snippets.

@cpcloud
cpcloud / gist:5695835
Last active December 18, 2015 00:19
test bs4 + lxml
from lxml.html import parse
url = 'http://www.fdic.gov/bank/individual/failed/banklist.html'
doc = parse(url)
print len(doc.xpath('.//table')) > 0
from bs4 import BeautifulSoup
from contextlib import closing
from urllib2 import urlopen
with closing(urlopen(url)) as f:
soup = BeautifulSoup(f.read(), features='lxml')
@cpcloud
cpcloud / vagrant_ubuntu_setup.sh
Last active December 18, 2015 03:19
Set up an Ubuntu vagrant box for pandas testing.
function setup_pandas_build_env()
{
local cwd=`pwd`
if [ ! -e "$1" ]; then
mkdir "$1"
else
[ ! -d "$1" ] && echo "$1 is not a directory" && return 1
fi
cd "$1"
vagrant init "$1" "$2"
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@cpcloud
cpcloud / gist:6205120
Created August 11, 2013 14:27
list of `statsmodels` failures using `statsmodels@2d4aad9` and `jreback@44f2d42`
======================================================================
ERROR: statsmodels.datasets.tests.test_utils.test_get_rdataset
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/phillip/.virtualenvs/pandas/src/nose/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/phillip/Documents/code/py/statsmodels/statsmodels/datasets/tests/test_utils.py", line 18, in test_get_rdataset
duncan = get_rdataset("Duncan", "car", cache=cur_dir)
File "/home/phillip/Documents/code/py/statsmodels/statsmodels/datasets/utils.py", line 250, in get_rdataset
title = _get_dataset_meta(dataname, package, cache)
{
"metadata": {
"name": "so_date"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@cpcloud
cpcloud / gist:6650724
Created September 21, 2013 13:35
Plotting Bar/Line Weirdness
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@cpcloud
cpcloud / gist:6745173
Created September 28, 2013 18:49
Command line tool to show raised exceptions that don't have a message. Originally created for use with the pandas data analysis library codebase.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import re
import os
import fnmatch
import ast
import argparse
for i in range(10):
print(i)
print(i * 2)