@@ -7,13 +7,13 @@ Time Series Data
77.. contents:: On this page
88 :local:
99 :backlinks: none
10- :depth: 1
10+ :depth: 2
1111 :class: singlecol
1212
1313Overview
1414--------
1515
16- In this guide, you can learn how to use the {+driver-short+} to store
16+ In this guide, you can learn how to use {+driver-short+} to store
1717and interact with **time series data**.
1818
1919Time series data is composed of the following components:
@@ -57,31 +57,34 @@ Create a Time Series Collection
5757 connected to a deployment running {+mdb-server+} 5.0 or later.
5858
5959You can create a time series collection to store time series data. To create
60- a time series collection, pass the following parameters to the ``create_collection()``
60+ a time series collection, pass the following arguments to the ``create_collection()``
6161method:
6262
6363- Name of the new collection to create
6464- ``timeseries`` argument
6565
6666The ``timeseries`` argument is of type ``dict``. It contains the following fields:
6767
68- - ``timeField``
69- - ``metaField``
70- - ``granularity``
71- - ``bucketMaxSpanSeconds``
72- - ``bucketRoundingSeconds``
68+ - ``timeField``: Specifies the field that stores a timestamp in each time series
69+ document.
70+ - ``metaField``: Specifies the field that stores metadata in each time series
71+ document.
72+ - ``granularity``: Specifies the approximate time between consecutive timestamps.
73+ The possible values are ``'seconds'``, ``'minutes'``, and ``'hours'``.
74+ - ``bucketMaxSpanSeconds``: Sets the maximum time between timestamps in the
75+ same bucket.
76+ - ``bucketRoundingSeconds``: Sets the number of seconds to round down by when
77+ MongoDB sets the minimum timestamp for a new bucket. Must be equal to
78+ ``bucketMaxSpanSeconds``.
7379
7480See :manual:`Command Fields </reference/command/create/#command-fields>`
7581to learn more about these fields.
7682
77- The following example shows how to create a time series collection using the
78- {+driver-short+}.
79-
8083Example
8184~~~~~~~
8285
83- This example creates a time series collection named ``october2024`` with the
84- ``timeField`` option set to ``"timestamp"``.
86+ The following example creates a time series collection named ``october2024`` with the
87+ ``timeField`` option set to ``"timestamp"``:
8588
8689.. code-block:: python
8790
@@ -109,6 +112,7 @@ all collections in the database:
109112
110113 .. output::
111114 :language: json
115+ :visible: false
112116
113117 {
114118 "name": "october2024",
@@ -163,8 +167,8 @@ document contains the following fields:
163167
164168.. tip:: Formatting Dates and Times
165169
166- See :ref:`pymongo-dates-times` to learn more about using ``datetime``
167- objects in {+driver-short+} .
170+ To learn more about using ``datetime`` objects in {+driver-short+}, see
171+ :ref:`pymongo-dates-times` .
168172
169173.. _pymongo-time-series-read:
170174
0 commit comments