Skip to content

Commit 6133ed1

Browse files
techbelleblink1073
andauthored
Update README.md (#81)
Co-authored-by: Steven Silvester <[email protected]>
1 parent 3007c02 commit 6133ed1

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,42 @@
11
# mongo-arrow
22
Tools for using Apache Arrow with MongoDB
3+
4+
## Apache Arrow
5+
We utilize Apache Arrow to offer fast and easy conversion of MongoDB query result sets to multiple numerical data formats popular among developers including NumPy ndarrays, Pandas DataFrames, parquet files, csv, and more.
6+
7+
We chose Arrow for this because of its unique set of characteristics:
8+
- language-independent
9+
- columnar memory format for flat and hierarchical data,
10+
- organized for efficient analytic operations on modern hardware like CPUs and GPUs
11+
- zero-copy reads for lightning-fast data access without serialization overhead
12+
- it was simple and fast, and from our perspective Apache Arrow is ideal for processing and transport of large datasets in high-performance applications.
13+
14+
As reference points for our implementation, we also took a look at BigQuery’s Pandas integration, pandas methods to handle JSON/semi-structured data, the Snowflake Python connector, and Dask.DataFrame.
15+
16+
17+
## How it Works
18+
Our implementation relies upon a user-specified data schema to marshall query result sets into tabular form.
19+
Example
20+
```
21+
from pymongoarrow.api import Schema
22+
schema = Schema({'_id': int, 'amount': float, 'last_updated': datetime})
23+
```
24+
25+
You can install PyMongoArrow on your local machine using Pip:
26+
`$ python -m pip install pymongoarrow`
27+
28+
You can export data from MongoDB to a pandas dataframe easily using something like:
29+
```
30+
df = production.invoices.find_pandas_all({'amount': {'$gt': 100.00}}, schema=invoices)
31+
```
32+
33+
Since PyMongoArrow can automatically infer the schema from the first batch of data, this can be
34+
further simplifed to:
35+
36+
```
37+
df = production.invoices.find_pandas_all({'amount': {'$gt': 100.00}})
38+
```
39+
40+
## Final Thoughts
41+
This library is in the early stages of development, and so it's possible the API may change in the future -
42+
we definitely want to continue expanding it. We welcome your feedback as we continue to explore and build this tool.

0 commit comments

Comments
 (0)