doan - Simple library for analytics
Examples
Prepare files for analysis.
import numpy as np
norm = np.random.normal(0, 0.5, 1000)
np.savetxt('/tmp/doan-normal', norm)
rand = np.random.randint(0, 100, 1000)
np.savetxt('/tmp/doan-rand', rand)
There is a file with numbers, let’s try to calculate its mean.
from doan import r_num, mean
print(mean(r_num('/tmp/doan-normal')))
If we want to get more information about list then call stat. For normal distributed data.
from doan import r_num, stat
print(stat(r_num('/tmp/doan-normal')))
And for random sample.
from doan import r_num, stat
print(stat(r_num('/tmp/doan-rand')))
To visualize numeric data there is a hist function. For normal distributed data.
from doan import r_num, hist
return hist(r_num('/tmp/doan-normal'))
And for random sample.
from doan import r_num, hist
return hist(r_num('/tmp/doan-rand'))
Can work with ssh and shell.
from doan import cmd, r_num, percentiles
print(percentiles(r_num(cmd("awk '{print $1 - 1}' /tmp/example-file")), [0.95]))
from doan import ssh, r_num, percentiles
print(percentiles(r_num(ssh('log')('echo "1\n2\n3\n" > /tmp/example-file')), [0.95]))