brew install mongodb
mkdir -p /data/dbEnsure that user account running mongod has correct permissions for the directory:
| from dateutil.parser import parse | |
| import pandas as pd | |
| # monthly slaughter records since 1921 | |
| df = pd.read_csv("http://bit.ly/119792b") | |
| # parse the data (we could also use pd.to_datetime) | |
| df.date = df.date.apply(parse) | |
| # sort the data frame by date | |
| df = df.sort(['date']) | |
| # create an index |
| import pandas as pd | |
| import numpy as np | |
| from datetime import datetime | |
| # generate some fake tick data with 1 million observations | |
| n = 1000000 | |
| df = pd.DataFrame({ | |
| "timestamp": [datetime.now() for t in range(n)], | |
| "value": np.random.uniform(-1, 1, n) | |
| }) |
| # pylint: disable=W0612 | |
| import time | |
| import pandas as pd | |
| import numpy as np | |
| import iopro | |
| import gc |
| #!/usr/bin/env python | |
| from pocket import Pocket | |
| import webbrowser, sys | |
| # Get consumer key from cmd line | |
| consumer_key = sys.argv[1] | |
| request_token = Pocket.get_request_token( | |
| consumer_key=consumer_key, |
| from collections import namedtuple | |
| def convert(dictionary): | |
| return namedtuple('GenericDict', dictionary.keys())(**dictionary) | |
| """ | |
| >>> d = dictionary(a=1, b='b', c=[3]) | |
| >>> named = convert(d) | |
| >>> named.a == d.a | |
| True | |
| >>> named.b == d.b |
Oddly enough ggplot2 has no support for a stacked and grouped (position="dodge") bar plot. The seaborn python package, although excellent, also does not provide an alternative. However, I knew it was surely possible to make such a plot in regular matplotlib. Matplotlib, although sometimes clunky, gives you enough flexibility to precisely place plotting elements which is needed for a stacked and grouped bar plot.
Below is a working example of making a stacked and grouped bar plot.
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np| # Path to your oh-my-zsh configuration. | |
| export ZSH=$HOME/.oh-my-zsh | |
| # Set name of the theme to load. | |
| # Look in ~/.oh-my-zsh/themes/ | |
| # Optionally, if you set this to "random", it'll load a random theme each | |
| # time that oh-my-zsh is loaded. | |
| #export ZSH_THEME="robbyrussell" | |
| export ZSH_THEME="zanshin" |
| #!/usr/bin/env python | |
| """strip outputs from an IPython Notebook | |
| Opens a notebook, strips its output, and writes the outputless version to the original file. | |
| Useful mainly as a git filter or pre-commit hook for users who don't want to track output in VCS. | |
| This does mostly the same thing as the `Clear All Output` command in the notebook UI. | |
| LICENSE: Public Domain |
| import pandas as pd | |
| # http://blog.yhathq.com/static/misc/data/WineKMC.xlsx | |
| df_offers = pd.read_excel("./WineKMC.xlsx", sheetname=0) | |
| df_offers.columns = ["offer_id", "campaign", "varietal", "min_qty", "discount", "origin", "past_peak"] | |
| df_offers.head() | |
| df_transactions = pd.read_excel("./WineKMC.xlsx", sheetname=1) | |
| df_transactions.columns = ["customer_name", "offer_id"] | |
| df_transactions['n'] = 1 | |
| df_transactions.head() |