-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add examples and update getting started (#40)
* docs: Add examples and update getting started
- Loading branch information
1 parent
eca4461
commit 1d76480
Showing
4 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import random | ||
from datetime import datetime | ||
|
||
from nisystemlink.clients.dataframe import DataFrameClient | ||
from nisystemlink.clients.dataframe.models import ( | ||
AppendTableDataRequest, | ||
Column, | ||
ColumnType, | ||
CreateTableRequest, | ||
DataFrame, | ||
DataType, | ||
) | ||
|
||
client = DataFrameClient() | ||
|
||
# Create table | ||
table_id = client.create_table( | ||
CreateTableRequest( | ||
name="Example Table", | ||
columns=[ | ||
Column(name="index", dataType=DataType.Int32, columnType=ColumnType.Index), | ||
Column(name="Float_Column", dataType=DataType.Float32), | ||
Column(name="Timestamp_Column", dataType=DataType.Timestamp), | ||
], | ||
) | ||
) | ||
|
||
# Generate example data | ||
frame = DataFrame( | ||
data=[[i, random.random(), datetime.now().isoformat()] for i in range(100)] | ||
) | ||
|
||
# Write example data to table | ||
client.append_table_data( | ||
table_id, data=AppendTableDataRequest(frame=frame, endOfData=True) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from nisystemlink.clients.dataframe import DataFrameClient | ||
from nisystemlink.clients.dataframe.models import ( | ||
DecimationMethod, | ||
DecimationOptions, | ||
QueryDecimatedDataRequest, | ||
) | ||
|
||
client = DataFrameClient() | ||
|
||
# List a table | ||
response = client.list_tables(take=1) | ||
table = response.tables[0] | ||
|
||
# Get table metadata by table id | ||
client.get_table_metadata(table.id) | ||
|
||
# Query decimated table data | ||
request = QueryDecimatedDataRequest( | ||
decimation=DecimationOptions( | ||
x_column="index", | ||
y_columns=["col1"], | ||
intervals=1, | ||
method=DecimationMethod.MaxMin, | ||
) | ||
) | ||
client.query_decimated_data(table.id, request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters