python Pandas 有 C/C++ API 吗? [英] Is there a C/C++ API for python pandas?

查看:39
本文介绍了python Pandas 有 C/C++ API 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 C/C++ 从旧后端系统中提取大量数据,并使用 distutils 将其移动到 Python.在Python中获取数据后,我将其放入pandas DataFrame对象中进行数据分析.现在我想走得更快,想避免第二步.

I'm extracting mass data from a legacy backend system using C/C++ and move it to Python using distutils. After obtaining the data in Python, I put it into a pandas DataFrame object for data analysis. Now I want to go faster and would like to avoid the second step.

是否有用于 Pandas 的 C/C++ API 来在 C/C++ 中创建 DataFrame,添加我的 C/C++ 数据并将其传递给 Python?我正在考虑类似于 numpy C API 的东西.

Is there a C/C++ API for pandas to create a DataFrame in C/C++, add my C/C++ data and pass it to Python? I'm thinking of something that is similar to numpy C API.

我已经想在 C 中创建 numpy 数组对象作为一种解决方法,但我大量使用时间序列数据,并且也希望拥有 TimeSeries 和 date_range 对象.

I already thougth of creating numpy array objects in C as a workaround but i'm heavily using timeseries data and would love to have the TimeSeries and date_range objects as well.

推荐答案

所有 Pandas 类(TimeSeries、DataFrame、DatetimeIndex 等)都有纯 Python 定义,因此没有 C API.您最好将 numpy ndarrays 从 C 传递给您的 Python 代码,并让您的 Python 代码从它们构建 pandas 对象.

All the pandas classes (TimeSeries, DataFrame, DatetimeIndex etc.) have pure-Python definitions so there isn't a C API. You might be best off passing numpy ndarrays from C to your Python code and letting your Python code construct pandas objects from them.

如有必要,您可以使用 PyObject_CallFunction 等来调用 pandas 构造函数,但您必须注意从模块导入中访问名称并检查错误.

If necessary you could use PyObject_CallFunction etc. to call the pandas constructors, but you'd have to take care of accessing the names from module imports and checking for errors.

这篇关于python Pandas 有 C/C++ API 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆