On a narrow build:
>>> ghost = u'👻'
>>> repr(ghost)
"u'\\U0001f47b'"
>>> print u'\U0001f47b'
👻
>>> g = 0x0001f47b
>>> unichr(g)
Traceback (most recent call last):
On a narrow build:
>>> ghost = u'👻'
>>> repr(ghost)
"u'\\U0001f47b'"
>>> print u'\U0001f47b'
👻
>>> g = 0x0001f47b
>>> unichr(g)
Traceback (most recent call last):
> a = data.frame(foo=c(1,2,3), bar=c(-1,2,-3)) | |
> a | |
foo bar | |
1 1 -1 | |
2 2 2 | |
3 3 -3 | |
> ifelse(a$bar < 0, -a$bar, a$bar) | |
[1] 1 2 3 | |
> |
>>> s = pd.Series([0,1,1]) | |
>>> t = pd.Series(['foo', 'bar', 'baz']) | |
>>> map = pd.Series({0: 'foo', 1: 'bar', 2: 'baz'}) | |
>>> map[s] | |
0 foo | |
1 bar | |
1 bar | |
dtype: object | |
>>> map[s].value_counts() - t.value_counts() | |
bar 1 |
>>> s = pd.Series(["foo", "bar", "bar"]) | |
>>> t = pd.Series(["foo", "bar", "baz"]) | |
>>> s.value_counts() - t.value_counts() | |
bar 1 | |
baz NaN | |
foo 0 |
import cairo | |
import numpy as np | |
from PIL import Image | |
# imdata is a 2D numpy array of dtype np.uint8 containing grayscale pixel intensities on [0, 255] | |
# repeat for each of R, G, B, and add a deck of 255s for alpha | |
cairo_imdata = np.dstack([imdata, imdata, imdata, np.ones_like(imdata)*255]) | |
surface = cairo.ImageSurface.create_for_data(cairo_imdata, cairo.FORMAT_ARGB32, *(reversed(imdata.shape))) | |
# create a context and do some doodling |
library(plyr) | |
library(dplyr) | |
donors = read.csv("donors.csv", header=TRUE, stringsAsFactors=FALSE, | |
na.strings=c("", " ")) | |
names(donors) = tolower(names(donors)) | |
library(lubridate) | |
donors$donation_time = parse_date_time(donors$donation_time, | |
orders=c("ymdhms", "mdyImsp"), | |
tz="America/Chicago") | |
donors[which.min(donors$donation_time), "donation_time"] = as.POSIXct("2014/05/01 00:00", tz="America/Chicago") |
df = data.frame(id=rep(c("A","B","C","D"), each=5),n=1:20) | |
flags = numeric(20) | |
flags[c(4,5,7)] = 1 | |
df$flag = flags | |
reduce_me = function(df, flagname) | |
{ | |
to_copy = integer(NROW(df)*2) * NA | |
ptr = 1 | |
for (i in seq_along(df[,1])) { |
df = data.frame(id=1:20) | |
flags = numeric(20) | |
flags[c(5,7)] = 1 | |
df$flag = flags | |
to_copy = numeric(20) * NA | |
ptr = 1 | |
for (i in seq_along(df$id)) { | |
if(!df[i, "flag"]) next | |
candidates = c((i-5):(i-1), (i+1):(i+5)) |
require "formula" | |
class UniversalPython < Requirement | |
satisfy(:build_env => false) { archs_for_command("python").universal? } | |
def message; <<-EOS.undent | |
A universal build was requested, but Python is not a universal build | |
Boost compiles against the Python it finds in the path; if this Python | |
is not a universal build then linking will likely fail. |
require "formula" | |
class UniversalPython < Requirement | |
satisfy(:build_env => false) { archs_for_command("python").universal? } | |
def message; <<-EOS.undent | |
A universal build was requested, but Python is not a universal build | |
Boost compiles against the Python it finds in the path; if this Python | |
is not a universal build then linking will likely fail. |