numpy - yszheda/wiki GitHub Wiki

isinstance(y, (np.ndarray, np.generic) )
convertfunc = lambda x: float(x.strip(b"%"))/100
b = np.genfromtxt(io.BytesIO(data.encode()), names = names, delimiter = ",", converters = {1:convertfunc})

numpy.vectorize

correlation

print numpy array

import sys
import numpy
numpy.set_printoptions(threshold=sys.maxsize)
import numpy as np
np.set_printoptions(formatter={'int':hex})
import numpy as np
np.set_printoptions(edgeitems=3)

save / load

np.save(fname, x)
np.load(fname + '.npy')

round

numpy.round is round half to even (IEEE 754)

import numpy as np

def round_half_up(x):
    round_lambda = lambda z: (int(z > 0) - int(z < 0)) * int(abs(z) + 0.5)
    if isinstance(x, (np.ndarray, np.generic)):
        return np.vectorize(round_lambda)(x)
    else:
        return round_lambda(x)

argwhere

float16