forked from dbis-ilm/grizzly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
39 lines (25 loc) · 994 Bytes
/
example.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
import grizzly
import sqlite3
from grizzly.relationaldbexecutor import RelationalExecutor
con = sqlite3.connect("grizzly.db")
grizzly.use(RelationalExecutor(con))
df = grizzly.read_table("events")
df = df[df["globaleventid"] == 470747760] # filter
df = df[["actor1name","actor2name"]]
df.show(pretty=True)
print("----------------------------------------")
df1 = grizzly.read_table("t1")
df2 = grizzly.read_table("t2")
j = df1.join(df2, on = (df1.actor1name == df2.actor2name) | (df1["actor1countrycode"] <= df2["actor2countrycode"]), how="left outer")
print(j.generate())
cnt = j.count()
print(f"join result contais {cnt} elments")
print("----------------------------------------")
df = grizzly.read_table("events")
print(df.count("actor2name"))
print("----------------------------------------")
from grizzly.aggregates import AggregateType
df = grizzly.read_table("events")
g = df.groupby(["year","actor1name"])
a = g.agg(col="actor2name", aggType=AggregateType.COUNT)
a.show()