Skip to main content

"Tools for using NumPy, Pandas and PyArrow with MongoDB"

Project description

Info:

A companion library to PyMongo that makes it easy to move data between MongoDB and Apache Arrow. See GitHub for the latest source.

Documentation:

Available at mongo-arrow.readthedocs.io.

Author:

Prashant Mital

PyMongoArrow is a companion library to PyMongo that contains tools for loading MongoDB query result sets as Apache Arrow tables, Pandas DataFrames or NumPy arrays.

>>> from pymongoarrow.monkey import patch_all
>>> patch_all()
>>> from pymongoarrow.api import Schema
>>> schema = Schema({'_id': int, 'qty': float})
>>> from pymongo import MongoClient
>>> client = MongoClient()
>>> client.db.data.insert_many([{'_id': 1, 'qty': 25.4}, {'_id': 2, 'qty': 16.9}, {'_id': 3, 'qty': 2.3}])
>>> data_frame = client.db.test.find_pandas_all({}, schema=schema)
>>> data_frame
   _id   qty
0    1  25.4
1    2  16.9
2    3   2.3
>>> arrow_table = client.db.test.find_arrow_all({}, schema=schema)
>>> arrow_table
pyarrow.Table
_id: int64
qty: double
>>> ndarrays = client.db.test.find_numpy_all({}, schema=schema)
>>> ndarrays
{'_id': array([1, 2, 3]), 'qty': array([25.4, 16.9,  2.3])}

PyMongoArrow is the recommended way to materialize MongoDB query result sets as contiguous-in-memory, typed arrays suited for in-memory analytical processing applications.

Installing PyMongoArrow

PyMongoArrow is available on PyPI:

$ python -m pip install pymongoarrow

To use PyMongoArrow with MongoDB Atlas’ mongodb+srv:// URIs, you will need to also install PyMongo with the srv extra:

$ python -m pip install 'pymongo[srv]' pymongoarrow

To use PyMongoArrow APIs that return query result sets as pandas DataFrame instances, you will also need to have the pandas package installed:

$ python -m pip install pandas

Development Install

See the instructions on Read the Docs.

Documentation

Full documentation is available on Read the Docs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymongoarrow-0.4.0.tar.gz (30.3 kB view hashes)

Uploaded Source

Built Distributions

pymongoarrow-0.4.0-cp310-cp310-win_amd64.whl (7.6 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

pymongoarrow-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.9 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pymongoarrow-0.4.0-cp310-cp310-macosx_10_15_x86_64.whl (10.7 MB view hashes)

Uploaded CPython 3.10 macOS 10.15+ x86-64

pymongoarrow-0.4.0-cp310-cp310-macosx_10_13_universal2.whl (10.9 MB view hashes)

Uploaded CPython 3.10 macOS 10.13+ universal2 (ARM64, x86-64)

pymongoarrow-0.4.0-cp39-cp39-win_amd64.whl (7.6 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

pymongoarrow-0.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.9 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pymongoarrow-0.4.0-cp39-cp39-macosx_10_15_x86_64.whl (10.7 MB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

pymongoarrow-0.4.0-cp39-cp39-macosx_10_13_universal2.whl (10.9 MB view hashes)

Uploaded CPython 3.9 macOS 10.13+ universal2 (ARM64, x86-64)

pymongoarrow-0.4.0-cp38-cp38-win_amd64.whl (7.6 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

pymongoarrow-0.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.9 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pymongoarrow-0.4.0-cp38-cp38-macosx_10_15_x86_64.whl (10.7 MB view hashes)

Uploaded CPython 3.8 macOS 10.15+ x86-64

pymongoarrow-0.4.0-cp37-cp37m-win_amd64.whl (7.6 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

pymongoarrow-0.4.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.8 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

pymongoarrow-0.4.0-cp37-cp37m-macosx_10_15_x86_64.whl (10.7 MB view hashes)

Uploaded CPython 3.7m macOS 10.15+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page