-
Notifications
You must be signed in to change notification settings - Fork 31
/
query_data.py
22 lines (16 loc) · 924 Bytes
/
query_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from terminusdb_client import Client
from terminusdb_client.woqlschema import WOQLSchema
from terminusdb_client.woqldataframe import result_to_df
# For Terminus X, use the following
# client = Client("https://cloud.terminusdb.com/<Your Team>/")
# client.connect(db="demo_workshop", team="<Your Team>", use_token=True)
client = Client("http://127.0.0.1:6363/")
client.connect(db="getting_started")
team_it_raw = client.query_document({"@type": "Employee", "team": "it"})
team_marketing_raw = client.query_document({"@type": "Employee", "team": "marketing"})
team_it = result_to_df(team_it_raw)
team_marketing = result_to_df(team_marketing_raw)
team_it_avg = team_it["name"].apply(len).sum() / len(team_it)
team_marketing_avg = team_marketing["name"].apply(len).sum() / len(team_marketing)
print(f"Average name length of IT team is {team_it_avg}")
print(f"Average name length of Marketing team is {team_marketing_avg}")