-
Notifications
You must be signed in to change notification settings - Fork 2k
/
pyunit_apply.py
43 lines (33 loc) · 1.17 KB
/
pyunit_apply.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
from __future__ import division, print_function
import sys
sys.path.insert(1,"../../")
import h2o
from tests import pyunit_utils
def pyunit_apply():
fr = h2o.import_file(pyunit_utils.locate("smalldata/logreg/prostate.csv"))
fr.apply(lambda x: x["PSA"], axis=1).show()
print()
print()
fr.apply(lambda x: x['PSA'] > x['VOL'], axis=1).show()
print()
print(fr.mean())
fr.apply(lambda x: x.mean(), axis=0).show()
fr.apply(lambda x: x.mean(), axis=1).show()
fr.apply(lambda col: col.abs()).show()
fr.apply(lambda col: col.cos()).show()
fr.apply(lambda col: col.sin()).show()
fr.apply(lambda col: col.ceil()).show()
fr.apply(lambda col: col.floor()).show()
fr.apply(lambda col: col.cosh()).show()
fr.apply(lambda col: col.exp()).show()
fr.apply(lambda col: col.log()).show()
fr.apply(lambda col: col.sqrt()).show()
fr.apply(lambda col: col.tan()).show()
fr.apply(lambda col: col.tanh()).show()
fr.apply(lambda col: (col*col - col*5*col).abs() - 55/col ).show()
if __name__ == "__main__":
pyunit_utils.standalone_test(pyunit_apply)
else:
pyunit_apply()