我可以用 Jython 运行 numpy 和 pandas

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19455100/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 21:15:23  来源:igfitidea点击:

Can I run numpy and pandas with Jython

pythonnumpypandasjython

提问by user2895685

We have some Java code we want to use with new code we plan to write in Python, hence our interest in using Jython. However we also want to use numpy and pandas libraries to do complex statistical analysis in this Python code.

我们有一些 Java 代码要与我们计划用 Python 编写的新代码一起使用,因此我们对使用 Jython 很感兴趣。但是,我们还想使用 numpy 和 pandas 库在此 Python 代码中进行复杂的统计分析。

Is it possible to call numpy and pandas from Jython?

是否可以从 Jython 调用 numpy 和 pandas?

回答by ankostis

Keep an eye in JyNIwhich is at alpha.2version, as of March-2014.

留意JyNI,它是alpha.2版本,截至 2014 年 3 月。

回答by sarwar

Not directly.

不直接

One option which I've used in the past is to use jsonrpclib(which works for both) to communicate between python and jython. There's even a server builtin which makes things quite simple. You'll just need to figure out whether the gains of using numpy are worth the additional overhead.

我过去使用的一种选择是使用jsonrpclib(适用于两者)在 python 和 jython 之间进行通信。甚至还有一个内置的服务器,使事情变得非常简单。您只需要弄清楚使用 numpy 的好处是否值得额外的开销。

回答by stewori

Especially if you don't want to use raw Numpy, but other Python frameworks that depend on it, JyNIwill be the way to go once it is mature. However, it is not yet capable to import Numpy.

特别是如果你不想使用原始的 Numpy,而是其他依赖它的 Python 框架,那么一旦它成熟,JyNI将是你的选择。但是,它还不能导入 Numpy。

Until then you can use Numpy from Java by embedding CPython. See the Numpy4J-project for this (I didn't test it myself though).

在此之前,您可以通过嵌入 CPython 来使用 Java 中的 Numpy。请参阅Numpy4J 项目(不过我自己没有测试过)。

回答by ndjensen

You can't use numpy from Jython at this time. But if you're willing to use CPython instead of Jython, there are some open source Java projects that work with numpy (and presumably pandas).

目前您不能使用 Jython 中的 numpy。但是,如果您愿意使用 CPython 而不是 Jython,那么有一些开源 Java 项目可以使用 numpy(可能还有 Pandas)。