You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
:py:meth:`Client.get_samples_aggregate` returns a :py:class:`pandas.Series`. The :py:mod:`start`, :py:mod:`end`, :py:mod:`aggregation_period` and :py:mod:`aggregation_function` parameters are required.
Copy file name to clipboardExpand all lines: docs/user_guide/advanced_config.rst
+81-1Lines changed: 81 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -151,4 +151,84 @@ Using the :py:mod:`max_page_size` parameter in :py:mod:`get_samples_aggregate` m
151
151
152
152
The :py:meth:`Client.get_samples_aggregate` method uses an endpoint that has support for paging of responses. This means that instead of making one big request, it might make a series of smaller requests traversing links to next pages returned in each partial response.
153
153
154
-
Normally this is something you don't have to think about. In case you do want to change the maximum number of results returned in one page, you can use the parameter called ``max_page_size`` to alter this number.
154
+
Normally this is something you don't have to think about. In case you do want to change the maximum number of results returned in one page, you can use the parameter called ``max_page_size`` to alter this number.
155
+
156
+
Using the :py:mod:`include_empty_aggregations` parameter in :py:mod:`get_samples_aggregate` method
The :py:meth:`Client.get_samples_aggregate` method aggregates data into fixed intervals based on the ``aggregation_period`` parameter. By default, the method only returns aggregations that contain data.
160
+
161
+
The ``include_empty_aggregations`` parameter controls whether to include aggregation intervals that have no data points. This is useful when you need a complete time series with regular intervals, even for periods where no measurements were recorded.
When ``include_empty_aggregations`` is ``False`` (default), only aggregations with data are returned. This results in a sparse series that may have gaps.
166
+
167
+
.. code-block:: python
168
+
169
+
import datareservoirio as drio
170
+
171
+
auth = drio.Authenticator()
172
+
client = drio.Client(auth)
173
+
174
+
# Returns only aggregations with data
175
+
timeseries = client.get_samples_aggregate(
176
+
'your-series-id',
177
+
start='2026-02-23',
178
+
end='2026-02-24',
179
+
aggregation_period='1m',
180
+
aggregation_function='mean',
181
+
include_empty_aggregations=False# Default
182
+
)
183
+
184
+
print(timeseries)
185
+
186
+
# Result will only include time intervals that have data.
When ``include_empty_aggregations`` is ``True``, all aggregation intervals within the specified time range are returned, with ``NaN`` (Not a Number) values for intervals that contain no data.
193
+
194
+
.. code-block:: python
195
+
196
+
import datareservoirio as drio
197
+
198
+
auth = drio.Authenticator()
199
+
client = drio.Client(auth)
200
+
201
+
# Returns all aggregations, including those with no data
202
+
timeseries = client.get_samples_aggregate(
203
+
'your-series-id',
204
+
start='2026-02-23',
205
+
end='2026-02-24',
206
+
aggregation_period='1m',
207
+
aggregation_function='mean',
208
+
include_empty_aggregations=True
209
+
)
210
+
211
+
print(timeseries)
212
+
213
+
# Result has a complete time series with NaN values where data is missing
214
+
# 2026-02-23 00:00:00+00:00 NaN
215
+
# 2026-02-23 00:01:00+00:00 NaN
216
+
# 2026-02-23 00:02:00+00:00 NaN
217
+
# 2026-02-23 00:03:00+00:00 2.2
218
+
# 2026-02-23 00:04:00+00:00 NaN
219
+
# ..
220
+
# 2026-02-23 23:55:00+00:00 NaN
221
+
# 2026-02-23 23:56:00+00:00 1.0
222
+
# 2026-02-23 23:57:00+00:00 NaN
223
+
# 2026-02-23 23:58:00+00:00 NaN
224
+
# 2026-02-23 23:59:00+00:00 NaN
225
+
226
+
**Use Cases:**
227
+
228
+
* **Analysis requiring regular intervals:** Set ``include_empty_aggregations=True`` when your analysis requires evenly-spaced data points (e.g., time-series forecasting models that expect regular intervals).
229
+
230
+
* **Detecting data gaps:** Set ``include_empty_aggregations=True`` if you need to identify periods with missing measurements.
231
+
232
+
* **Visualization:** Set ``include_empty_aggregations=True`` when creating time-series plots that should display the full time range uniformly.
233
+
234
+
* **Memory efficiency:** Use ``include_empty_aggregations=False`` (default) if storage or memory is a concern and you only need data-bearing intervals.
0 commit comments