modin

modin

轻松实现pandas并行化加速

Modin是pandas的高性能替代方案,通过并行化计算显著提升数据处理速度。只需更改一行导入代码,即可利用全部CPU核心加速pandas工作流,特别适合大型数据集。Modin支持处理超出内存的数据,兼容90%以上pandas API,并支持Ray、Dask和MPI等多种计算引擎。它简化了分布式计算,让用户轻松获得性能提升。

Modinpandas并行计算数据处理大数据Github开源项目
<p align="center"><a href="https://modin.readthedocs.io"><img width=77% alt="" src="https://github.com/modin-project/modin/raw/7c009c747caa90554607e30b9ac2bd1b190b8c7d/docs/img/MODIN_ver2_hrz.png?raw=true"></a></p> <h2 align="center">Scale your pandas workflows by changing one line of code</h2> <div align="center">
<h3>Dev Community & Support</h3><h3>Forums</h3><h3>Socials</h3><h3>Docs</h3>
SlackStack Overflow<a href="https://twitter.com/modin_project"><img alt="Twitter Follow" src="https://img.shields.io/twitter/follow/modin_project?style=social" height=28 align="center"></a><a href="https://modin.readthedocs.io/en/latest/?badge=latest"><img alt="" src="https://readthedocs.org/projects/modin/badge/?version=latest" height=28 align="center"></a>
</div> <p align="center"> <a href="https://pepy.tech/project/modin"><img src="https://static.pepy.tech/personalized-badge/modin?period=total&units=international_system&left_color=black&right_color=blue&left_text=Downloads" align="center"></a> <a href="https://codecov.io/gh/modin-project/modin"><img src="https://codecov.io/gh/modin-project/modin/branch/main/graph/badge.svg" align="center"/></a> <a href="https://github.com/modin-project/modin/actions/workflows/push-to-main.yml?query=event%3Apush"><img src="https://github.com/modin-project/modin/actions/workflows/push-to-main.yml/badge.svg?branch=main" align="center"></a> <a href="https://github.com/modin-project/modin/actions/workflows/ci.yml?query=event%3Apush"><img src="https://github.com/modin-project/modin/actions/workflows/ci.yml/badge.svg?branch=main" align="center"></a> <a href="https://pypi.org/project/modin/"><img src="https://badge.fury.io/py/modin.svg" alt="PyPI version" align="center"></a> <a href="https://modin.org/modin-bench/#/"><img src="https://img.shields.io/badge/benchmarked%20by-asv-blue.svg" align="center"></a> </p>

What is Modin?

Modin is a drop-in replacement for pandas. While pandas is single-threaded, Modin lets you instantly speed up your workflows by scaling pandas so it uses all of your cores. Modin works especially well on larger datasets, where pandas becomes painfully slow or runs out of memory. Also, Modin comes with the additional APIs to improve user experience.

By simply replacing the import statement, Modin offers users effortless speed and scale for their pandas workflows:

<img src="https://github.com/modin-project/modin/raw/main/docs/img/Import.gif" style="display: block;margin-left: auto;margin-right: auto;" width="100%"></img>

In the GIFs below, Modin (left) and pandas (right) perform the same pandas operations on a 2GB dataset. The only difference between the two notebook examples is the import statement.

<table class="tg"> <thead> <tr> <th class="tg-0lax" style="text-align: center;"><img src="https://github.com/modin-project/modin/raw/7c009c747caa90554607e30b9ac2bd1b190b8c7d/docs/img/MODIN_ver2_hrz.png?raw=True" height="35px"></th> <th class="tg-0lax" style="text-align: center;"><img src="https://pandas.pydata.org/static/img/pandas.svg" height="50px"></img></th> </tr> </thead> <tbody> <tr> <td class="tg-0lax"><img src="https://github.com/modin-project/modin/raw/7c009c747caa90554607e30b9ac2bd1b190b8c7d/docs/img/Modin.gif"></img></td> <td class="tg-0lax"><img src="https://github.com/modin-project/modin/raw/7c009c747caa90554607e30b9ac2bd1b190b8c7d/docs/img/Pandas.gif"></img></td> </tr> </tbody> </table>

The charts below show the speedup you get by replacing pandas with Modin based on the examples above. The example notebooks can be found here. To learn more about the speedups you could get with Modin and try out some examples on your own, check out our 10-minute quickstart guide to try out some examples on your own!

<img src="https://github.com/modin-project/modin/raw/7c009c747caa90554607e30b9ac2bd1b190b8c7d/docs/img/Modin_Speedup.svg" style="display: block;margin-left: auto;margin-right: auto;" width="100%"></img>

Installation

From PyPI

Modin can be installed with pip on Linux, Windows and MacOS:

pip install "modin[all]" # (Recommended) Install Modin with Ray and Dask engines.

If you want to install Modin with a specific engine, we recommend:

pip install "modin[ray]" # Install Modin dependencies and Ray. pip install "modin[dask]" # Install Modin dependencies and Dask. pip install "modin[mpi]" # Install Modin dependencies and MPI through unidist.

To get Modin on MPI through unidist (as of unidist 0.5.0) fully working it is required to have a working MPI implementation installed beforehand. Otherwise, installation of modin[mpi] may fail. Refer to Installing with pip section of the unidist documentation for more details about installation.

Note: Since Modin 0.30.0 we use a reduced set of Ray dependencies: ray instead of ray[default]. This means that the dashboard and cluster launcher are no longer installed by default. If you need those, consider installing ray[default] along with modin[ray].

Modin automatically detects which engine(s) you have installed and uses that for scheduling computation.

From conda-forge

Installing from conda forge using modin-all will install Modin and three engines: Ray, Dask and MPI through unidist.

conda install -c conda-forge modin-all

Each engine can also be installed individually (and also as a combination of several engines):

conda install -c conda-forge modin-ray # Install Modin dependencies and Ray. conda install -c conda-forge modin-dask # Install Modin dependencies and Dask. conda install -c conda-forge modin-mpi # Install Modin dependencies and MPI through unidist.

Note: Since Modin 0.30.0 we use a reduced set of Ray dependencies: ray-core instead of ray-default. This means that the dashboard and cluster launcher are no longer installed by default. If you need those, consider installing ray-default along with modin-ray.

Refer to Installing with conda section of the unidist documentation for more details on how to install a specific MPI implementation to run on.

To speed up conda installation we recommend using libmamba solver. To do this install it in a base environment:

conda install -n base conda-libmamba-solver

and then use it during istallation either like:

conda install -c conda-forge modin-ray --experimental-solver=libmamba

or starting from conda 22.11 and libmamba solver 22.12 versions:

conda install -c conda-forge modin-ray --solver=libmamba

Choosing a Compute Engine

If you want to choose a specific compute engine to run on, you can set the environment variable MODIN_ENGINE and Modin will do computation with that engine:

export MODIN_ENGINE=ray # Modin will use Ray export MODIN_ENGINE=dask # Modin will use Dask export MODIN_ENGINE=unidist # Modin will use Unidist

If you want to choose the Unidist engine, you should set the additional environment variable UNIDIST_BACKEND. Currently, Modin only supports MPI through unidist:

export UNIDIST_BACKEND=mpi # Unidist will use MPI backend

This can also be done within a notebook/interpreter before you import Modin:

import modin.config as modin_cfg import unidist.config as unidist_cfg modin_cfg.Engine.put("ray") # Modin will use Ray modin_cfg.Engine.put("dask") # Modin will use Dask modin_cfg.Engine.put('unidist') # Modin will use Unidist unidist_cfg.Backend.put('mpi') # Unidist will use MPI backend

Note: You should not change the engine after your first operation with Modin as it will result in undefined behavior.

Which engine should I use?

On Linux, MacOS, and Windows you can install and use either Ray, Dask or MPI through unidist. There is no knowledge required to use either of these engines as Modin abstracts away all of the complexity, so feel free to pick either!

Pandas API Coverage

<p align="center">
pandas ObjectModin's Ray Engine CoverageModin's Dask Engine CoverageModin's Unidist Engine Coverage
pd.DataFrame<img src=https://img.shields.io/badge/api%20coverage-90.8%25-hunter.svg><img src=https://img.shields.io/badge/api%20coverage-90.8%25-hunter.svg><img src=https://img.shields.io/badge/api%20coverage-90.8%25-hunter.svg>
pd.Series<img src=https://img.shields.io/badge/api%20coverage-88.05%25-green.svg><img src=https://img.shields.io/badge/api%20coverage-88.05%25-green.svg><img src=https://img.shields.io/badge/api%20coverage-88.05%25-green.svg>
pd.read_csv
pd.read_table
pd.read_parquet
pd.read_sql
pd.read_feather
pd.read_excel
pd.read_json✳️✳️✳️
pd.read_<other>✴️✴️✴️
</p> Some pandas APIs are easier to implement than others, so if something is missing feel free to open an issue!

More about Modin

For the complete documentation on Modin, visit our ReadTheDocs page.

Scale your pandas workflow by changing a single line of code.

Note: In local mode (without a cluster), Modin will create and manage a local (Dask or Ray) cluster for the execution.

To use Modin, you do not need to specify how to distribute the data, or even know how many cores your system has. In fact, you can continue using your previous pandas notebooks while experiencing a considerable speedup from Modin, even on a single machine. Once you've changed your import statement, you're ready to use Modin just like you would with pandas!

Faster pandas, even on your laptop

<img align="right" style="display:inline;" height="350" width="300" src="https://github.com/modin-project/modin/raw/7c009c747caa90554607e30b9ac2bd1b190b8c7d/docs/img/read_csv_benchmark.png?raw=true"></a>

The modin.pandas DataFrame is an extremely light-weight parallel DataFrame. Modin transparently distributes the data and computation so that you can continue using the same pandas API while working with more data faster. Because it is so light-weight, Modin provides speed-ups of up to 4x on a laptop with 4 physical cores.

In pandas, you are only able to use one core at a time when you are doing computation of any kind. With Modin, you are able to use all of the CPU cores on your machine. Even with a traditionally synchronous task like read_csv, we see large speedups by efficiently distributing the work across your entire machine.

import modin.pandas as pd df = pd.read_csv("my_dataset.csv")

Modin can handle the datasets that pandas can't

Often data scientists have to switch between different tools for operating on datasets of different sizes. Processing large dataframes with pandas is slow, and pandas does not support working with dataframes that are too large to fit into the available memory. As a result, pandas workflows that work well for prototyping on a few MBs of data do not scale to tens or hundreds of GBs (depending on the size of your machine). Modin supports operating on data that does not fit in memory, so that you can comfortably work with hundreds of GBs without worrying about substantial slowdown or memory errors. With cluster and out of core support, Modin is a DataFrame library with both great single-node performance and high scalability in a cluster.

Modin Architecture

We designed Modin's architecture to be modular so we can plug in different components as they develop and improve:

<img src="https://github.com/modin-project/modin/raw/7c009c747caa90554607e30b9ac2bd1b190b8c7d/docs/img/modin_architecture.png" alt="Modin's architecture" width="75%"></img>

Other Resources

Getting Started with Modin

Modin Community

Learn More about Modin

编辑推荐精选

商汤小浣熊

商汤小浣熊

最强AI数据分析助手

小浣熊家族Raccoon,您的AI智能助手,致力于通过先进的人工智能技术,为用户提供高效、便捷的智能服务。无论是日常咨询还是专业问题解答,小浣熊都能以快速、准确的响应满足您的需求,让您的生活更加智能便捷。

imini AI

imini AI

像人一样思考的AI智能体

imini 是一款超级AI智能体,能根据人类指令,自主思考、自主完成、并且交付结果的AI智能体。

Keevx

Keevx

AI数字人视频创作平台

Keevx 一款开箱即用的AI数字人视频创作平台,广泛适用于电商广告、企业培训与社媒宣传,让全球企业与个人创作者无需拍摄剪辑,就能快速生成多语言、高质量的专业视频。

即梦AI

即梦AI

一站式AI创作平台

提供 AI 驱动的图片、视频生成及数字人等功能,助力创意创作

扣子-AI办公

扣子-AI办公

AI办公助手,复杂任务高效处理

AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!

TRAE编程

TRAE编程

AI辅助编程,代码自动修复

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

AI工具TraeAI IDE协作生产力转型热门
蛙蛙写作

蛙蛙写作

AI小说写作助手,一站式润色、改写、扩写

蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。

AI辅助写作AI工具蛙蛙写作AI写作工具学术助手办公助手营销助手AI助手
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

热门AI助手AI对话AI工具聊天机器人
Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

AI办公办公工具AI工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图热门
下拉加载更多