Official Sage data client.
Project description
Sage Data API Client
This is the official Sage Python data API client. Its main goal is to make writing queries and working with the results easy. It does this by:
- Providing a simple query function which talks to the data API.
- Providing the results in an easy to use Pandas data frame.
Installation
pip install sage-data-client
Usage Examples
Query API
import sage_data_client
# query and load data into pandas data frame
df = sage_data_client.query(
start="-1h",
filter={
"name": "env.temperature",
}
)
# print results in data frame
print(df)
# meta columns are expanded into meta.fieldname. for example, here we print the unique nodes
print(df["meta.node"].unique())
# print stats of the temperature data grouped by node + sensor.
print(df.groupby(["meta.node", "meta.sensor"]).value.agg(["size", "min", "max", "mean"]))
import sage_data_client
# query and load data into pandas data frame
df = sage_data_client.query(
start="-1h",
filter={
"name": "env.raingauge.*",
}
)
# print number of results of each name
print(df.groupby(["meta.node", "name"]).size())
Load results from file
If we have saved the results of a query to a file data.json
, we can also load using the load
function as follows:
import sage_data_client
# load results from local file
df = sage_data_client.load("data.json")
# print number of results of each name
print(df.groupby(["meta.node", "name"]).size())
Reference
The query
function accepts the following arguments:
start
. Absolute or relative start timestamp. (required)end
. Absolute or relative end timestamp.tail
. Limit results totail
most recent values per series.filter
. Key-value patterns to filter data on.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for sage-data-client-0.3.0.post3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2485c5eb56f31c87c3e41e34016f3c91dbf172da39f39a3b0c33b7b3a7cf009a |
|
MD5 | c2aae42f63086224f7e2e33fb91f5bbb |
|
BLAKE2b-256 | 8af5d930a45567fc0817b3e0f71043b24fde1e68ce78a14b0372374d6ddbf8a1 |
Close
Hashes for sage_data_client-0.3.0.post3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16b4706c3b8cc3650693bec5e12d4808f1efd422cc926c83bb825fb31d1d87be |
|
MD5 | 56dac55d4d6e5e90a0a4faef6e5a992e |
|
BLAKE2b-256 | 2cb188df03ad2d8a87d50c2f70c09da0c2a7f2ed4b610635a7433f236605b60a |