Skip to content
This repository was archived by the owner on Jul 5, 2024. It is now read-only.

Commit d6c981e

Browse files
committed
Reverting query_api.py to version in master branch. Updating README and quicstart with correct aggregateList parameter, and example illustrating how aggregation list works.
1 parent 947c8e7 commit d6c981e

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ client = tsi.TSIClient(
4848
You can check the docs at <https://raalabs-tsiclient.readthedocs.io/en/latest/authentication.html> for more information on authentication, and check
4949
the old way of authentication (these will be removed in a future version).
5050

51-
You can query your timeseries data by timeseries id, timeseries name or timeseries description. The Microsoft TSI apis support aggregation, so you can specify a sampling freqency and an aggregation method. Refer to the documentation for detailed information.
51+
You can query your timeseries data by timeseries id, timeseries name or timeseries description. The Microsoft TSI apis support aggregation, so you can specify a sampling freqency and aggregation methods. Refer to the documentation for detailed information.
5252

5353
````python
5454
data = client.query.getDataById(
5555
timeseries=["timeseries_id1", "timeseries_id2"],
5656
timespan=["2019-12-12T15:35:11.68Z", "2019-12-12T17:02:05.958Z"],
5757
interval="PT5M",
58-
aggregateList=["avg", "avg"],
58+
aggregateList=["avg", "max"],
5959
useWarmStore=False
6060
)
6161
````

TSIClient/query/query_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ def _getData(
669669
if isinstance(aggregateList, list):
670670
for idx, agg in enumerate(aggregateList):
671671
currColName = colNames[i] + "/" + agg
672-
df[currColName] = response["properties"][0]["values"]
672+
df[currColName] = response["properties"][idx]["values"]
673673
else:
674674
df[colNames[i]] = response["properties"][0]["values"]
675675

@@ -735,4 +735,4 @@ def _getData(
735735
df = pd.merge_asof(df,df_temp,on=['timestamp'],direction='nearest',tolerance=pd.Timedelta(seconds=30))
736736
finally:
737737
logging.critical("Loaded data for tag: {tag}".format(tag=colNames[i]))
738-
return df
738+
return df

docs/source/quickstart.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -167,21 +167,21 @@ is convenient for further statistical analysis.
167167
... timeseries=["timeseries_id1", "timeseries_id2"],
168168
... timespan=["2020-01-25T10:00:11.68Z", "2020-01-26T13:45:11.68Z"],
169169
... interval="PT5M",
170-
... aggregateList=["avg", "avg"],
170+
... aggregateList=["avg", "max"],
171171
... useWarmStore=False
172172
... )
173173
>>> data
174-
timestamp timeseries_id1 timeseries_id2
175-
0 2020-01-25T10:00:00Z 360.272727 242.692308
176-
1 2020-01-25T10:05:00Z 362.588235 244.523810
177-
2 2020-01-25T10:10:00Z 369.280000 245.000000
178-
3 2020-01-25T10:15:00Z 365.952381 242.962963
179-
4 2020-01-25T10:20:00Z 367.962963 241.391304
180-
.. ... ... ...
181-
329 2020-01-26T13:25:00Z 315.210526 299.250000
182-
330 2020-01-26T13:30:00Z 310.060606 569.776119
183-
331 2020-01-26T13:35:00Z 300.961538 299.000000
184-
332 2020-01-26T13:40:00Z 301.645161 293.421053
185-
333 2020-01-26T13:45:00Z 300.000000 NaN
174+
timestamp timeseries_id1/avg timeseries_id1/max timeseries_id2/avg timeseries_id2/max
175+
0 2020-01-25T10:00:00Z 324.060000 325.1 0.706804 0.882239
176+
1 2020-01-25T10:05:00Z 324.840000 325.1 0.757573 0.882239
177+
2 2020-01-25T10:10:00Z 324.479310 325.1 0.716411 0.744299
178+
3 2020-01-25T10:15:00Z 323.954545 324.9 0.779331 1.156681
179+
4 2020-01-25T10:20:00Z 324.300000 325.1 0.723073 1.205535
180+
.. ... ... ... ... ...
181+
329 2020-01-26T13:25:00Z 325.468750 326.1 0.871528 0.910976
182+
330 2020-01-26T13:30:00Z 325.135294 326.1 0.858428 0.892297
183+
331 2020-01-26T13:35:00Z 323.957142 324.9 0.804100 0.842006
184+
332 2020-01-26T13:40:00Z 324.666666 325.1 0.788907 0.882239
185+
333 2020-01-26T13:45:00Z 324.969999 325.1 0.756615 0.784532
186186
187187
[334 rows x 3 columns]

0 commit comments

Comments
 (0)