R&#x27的Package ::功能的Python等效是什么?

发布于 2025-02-09 04:06:56 字数 432 浏览 0 评论 0原文

在RI中可以通过两种不同的方式使用函数。首先是加载库,然后使用该功能。

library(dplyr)
df2 <- select(df, column)

或者,当我在不先加载软件包的情况下调用该函数时,我将其命名(虽然应该安装)。当我只使用一个来自某个软件包的一个函数时,这可以节省脚本中的空间。它还有助于阅读代码。

df2 <- dplyr::select(df, column)

在Python中,我这样做:

import pandas as pd
df = pd.DataFrame(df)

有没有办法写作:

df = pandas.DataFrame(df)

没有导入语句?

In R I can use a function in two different ways. First is to load the library and then use the function.

library(dplyr)
df2 <- select(df, column)

Or I name the package when I call the function without loading the package first (it should be installed though). This saves space in the script when I use only one function from a certain package. It also helps with reading the code.

df2 <- dplyr::select(df, column)

In python I do this:

import pandas as pd
df = pd.DataFrame(df)

Is there a way to only write:

df = pandas.DataFrame(df)

without the import statement?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文