4
4
Schema Examples
5
5
===============
6
6
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
8
13
14
+ This guide shows examples of how to use PyMongoArrow schemas in common situations.
9
15
10
- Nested Data With Schema
16
+ Nested Data with Schema
11
17
-----------------------
12
18
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
14
21
names in sub-documents compared to their parent documents.
15
22
16
23
.. code-block:: python
@@ -40,9 +47,9 @@ names in sub-documents compared to their parent documents.
40
47
-- child 0 type: int32
41
48
[0,10]]
42
49
43
- For Pandas and NumPy you can do the same exact thing:
50
+ You can do the same thing when using Pandas and NumPy :
44
51
45
- .. code-block:: pycon
52
+ .. code-block:: python
46
53
47
54
>>> df = find_pandas_all(
48
55
... 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:
52
59
0 string {'start': 0}
53
60
1 string {'start': 10}
54
61
55
-
56
- Nested Data With Projections
62
+ Nested Data with Projections
57
63
----------------------------
58
64
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:
61
68
62
- .. code-block:: pycon
69
+ .. code-block:: python
63
70
64
71
>>> df = find_pandas_all(
65
72
... coll,
@@ -77,8 +84,8 @@ The following example illustrates how to do it with a very simple nested documen
77
84
0 b'c\xec2\x98R(\xc9\x1e@#\xcc\xbb' 0 foo
78
85
1 b'c\xec2\x98R(\xc9\x1e@#\xcc\xbc' 10 bar
79
86
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 :
82
89
83
90
.. code-block:: pycon
84
91
0 commit comments