# MongoDf
[](https://github.com/VK/mongodf/actions/workflows/python-publish.yml)
[](https://pypi.org/project/mongodf)
[](https://vk.github.io/mongodf)
A mongoDB to pandas DataFrame converter with a pandas filter style.
## Install
```
pip install mongodf
```
## Filter Example
```python
import mongodf
import pymongo
mongo = pymongo.MongoClient("mongodb://mongo:27017")
# create a dataframe from a mongoDB collection
df = mongodf.from_mongo(mongo, "DB", "Collection")
# filter values
df = df[(df["colA"] == "Test") & (df.ColB.isin([1, 2]))]
# filter columns
df = df[["colA", "colC"]]
# compute a pandas.DataFrame
df.compute()
```
| | colA | colC |
|---| ----- | ---- |
|0 | Test | NaN |
|1 | Test | 12 |
## Cache Example
```
import plotly.express as px
df = px.data.gapminder()
cache = MongoDFCache(
host="mongodb://mongo:27017",
database="mongodfcache",
expire_after_seconds=20,
)
# put the dataframe into the mongo cache
# the name can be auto generated, array_group can be a list of cols
id = cache.cache_dataframe(df, "test_df", array_group=True)
# get a mongodf without reading all the data
cdf = cache.get_dataframe(id)
# get the metadata and the content of the dataframe
gcdf.get_meta()
gcdf.compute()
```
Raw data
{
"_id": null,
"home_page": "https://github.com/VK/mongodf",
"name": "mongodf",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "mongoDB pandas dataframe filter",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/c6/dd/ca1f41f9e15659e74ce74395b30ad5d93a9229b0a91d70e6e24b595526be/mongodf-0.1.15.tar.gz",
"platform": null,
"description": "# MongoDf\n\n[](https://github.com/VK/mongodf/actions/workflows/python-publish.yml)\n[](https://pypi.org/project/mongodf)\n[](https://vk.github.io/mongodf)\n\n\nA mongoDB to pandas DataFrame converter with a pandas filter style.\n\n## Install\n```\npip install mongodf\n```\n\n## Filter Example\n```python\nimport mongodf\nimport pymongo\n\nmongo = pymongo.MongoClient(\"mongodb://mongo:27017\")\n\n# create a dataframe from a mongoDB collection\ndf = mongodf.from_mongo(mongo, \"DB\", \"Collection\")\n\n# filter values\ndf = df[(df[\"colA\"] == \"Test\") & (df.ColB.isin([1, 2]))]\n\n# filter columns\ndf = df[[\"colA\", \"colC\"]]\n\n# compute a pandas.DataFrame\ndf.compute()\n```\n\n| | colA | colC |\n|---| ----- | ---- |\n|0 | Test | NaN |\n|1 | Test | 12 |\n\n\n\n## Cache Example\n```\nimport plotly.express as px\ndf = px.data.gapminder()\n\ncache = MongoDFCache(\n host=\"mongodb://mongo:27017\",\n database=\"mongodfcache\",\n expire_after_seconds=20,\n)\n\n# put the dataframe into the mongo cache\n# the name can be auto generated, array_group can be a list of cols\nid = cache.cache_dataframe(df, \"test_df\", array_group=True)\n\n# get a mongodf without reading all the data\ncdf = cache.get_dataframe(id)\n\n# get the metadata and the content of the dataframe\ngcdf.get_meta()\ngcdf.compute()\n\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": null,
"version": "0.1.15",
"project_urls": {
"Homepage": "https://github.com/VK/mongodf"
},
"split_keywords": [
"mongodb",
"pandas",
"dataframe",
"filter"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "de0393b0d0a0b485769b9c105641cc2cfd4a7da7f3422d92e8b981b80515dc15",
"md5": "9c0160509d9b642c6707bda10f956478",
"sha256": "ac5d3870cc6baf2afc35fa7b643d970405f84063cb7f2a3f57bd98fc7bfd4727"
},
"downloads": -1,
"filename": "mongodf-0.1.15-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9c0160509d9b642c6707bda10f956478",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 18369,
"upload_time": "2025-01-24T15:38:46",
"upload_time_iso_8601": "2025-01-24T15:38:46.350820Z",
"url": "https://files.pythonhosted.org/packages/de/03/93b0d0a0b485769b9c105641cc2cfd4a7da7f3422d92e8b981b80515dc15/mongodf-0.1.15-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "c6ddca1f41f9e15659e74ce74395b30ad5d93a9229b0a91d70e6e24b595526be",
"md5": "c7fd8c5d1c86de8831d2bcc747a0ce7d",
"sha256": "aeb0e84c96781f26843d617ff6fa1b4dd98e6966fdee527ff3324e482bae731b"
},
"downloads": -1,
"filename": "mongodf-0.1.15.tar.gz",
"has_sig": false,
"md5_digest": "c7fd8c5d1c86de8831d2bcc747a0ce7d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 14885,
"upload_time": "2025-01-24T15:38:47",
"upload_time_iso_8601": "2025-01-24T15:38:47.535562Z",
"url": "https://files.pythonhosted.org/packages/c6/dd/ca1f41f9e15659e74ce74395b30ad5d93a9229b0a91d70e6e24b595526be/mongodf-0.1.15.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-24 15:38:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "VK",
"github_project": "mongodf",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "pymongo",
"specs": []
},
{
"name": "pandas",
"specs": []
},
{
"name": "numpy",
"specs": [
[
">=",
"1.22.2"
]
]
}
],
"lcname": "mongodf"
}