Skip to content

Commit ce51e16

Browse files
authored
DOCSP-37420 - Schemas (#6)
1 parent 09b6194 commit ce51e16

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

source/schemas.txt

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@
44
Schema Examples
55
===============
66

7-
The following are a few examples of usage of PyMongoArrow Schemas in common situations.
7+
.. facet::
8+
:name: genre
9+
:values: reference
10+
11+
.. meta::
12+
:keywords: pandas, numpy, flatten
813

14+
This guide shows examples of how to use PyMongoArrow schemas in common situations.
915

10-
Nested Data With Schema
16+
Nested Data with Schema
1117
-----------------------
1218

13-
With aggregate or find methods, you can provide a schema for nested data using the struct object. Note that there can be conflicting
19+
When performing aggregate or find operations, you can provide a schema for nested data
20+
by using the ``struct`` object. There can be conflicting
1421
names in sub-documents compared to their parent documents.
1522

1623
.. code-block:: python
@@ -40,9 +47,9 @@ names in sub-documents compared to their parent documents.
4047
-- child 0 type: int32
4148
[0,10]]
4249

43-
For Pandas and NumPy you can do the same exact thing:
50+
You can do the same thing when using Pandas and NumPy:
4451

45-
.. code-block:: pycon
52+
.. code-block:: python
4653

4754
>>> df = find_pandas_all(
4855
... coll, {}, schema=Schema({"start": str, "prop": struct([field("start", int32())])})
@@ -52,14 +59,14 @@ For Pandas and NumPy you can do the same exact thing:
5259
0 string {'start': 0}
5360
1 string {'start': 10}
5461

55-
56-
Nested Data With Projections
62+
Nested Data with Projections
5763
----------------------------
5864

59-
One can also use projections to flatten the data prior to ingesting into PyMongoArrow.
60-
The following example illustrates how to do it with a very simple nested document structure.
65+
You can also use projections to flatten the data before passing it to {+driver-short+}.
66+
The following example illustrates how to do this by using a very simple nested document
67+
structure:
6168

62-
.. code-block:: pycon
69+
.. code-block:: python
6370

6471
>>> df = find_pandas_all(
6572
... coll,
@@ -77,8 +84,8 @@ The following example illustrates how to do it with a very simple nested documen
7784
0 b'c\xec2\x98R(\xc9\x1e@#\xcc\xbb' 0 foo
7885
1 b'c\xec2\x98R(\xc9\x1e@#\xcc\xbc' 10 bar
7986

80-
81-
For aggregate you can flatten the fields using the ``$project`` stage, like so:
87+
When performing an aggregate operation, you can flatten the fields by using the ``$project``
88+
stage, as shown in the following example:
8289

8390
.. code-block:: pycon
8491

0 commit comments

Comments
 (0)