In Workshop, I need to have a variable that contains the “first timestamp” of a timeseries’s data point. Same for the last timestamp.
How can I get this first/last timestamp of a timeseries ? I can get the value, but not the timestamp itself, directly in variables in Workshop.
You need to write a function. Below is an example of the python code to do such data point extraction:
from functions.api import function, Timestamp
from ontology_sdk.ontology.objects import MyObject
@function
def get_start_ts_point(
myobject: MyObject
) -> Timestamp:
first_point = myobject.longitude_ts_seriesid.first_point()
return first_point.time
@function
def get_last_ts_point(
myobject: MyObject
) -> Timestamp:
last_point = myobject.longitude_ts_seriesid.last_point()
return last_point.time
1 Like