选择熊猫的条件下的特定列

发布于 2025-02-10 18:14:15 字数 461 浏览 2 评论 0原文

我有一个带有3列的数据框:

df = DataFrame(query, columns=["Processid", "Processdate", "ISofficial"])

在下面的代码中,我基于ProcessID == 204(没有列名)获得了ProcessDate:

result = df[df.Processid == 204].Processdate.to_string(index=False)

但是我会一次对两个列的结果相同,没有列名,类似于下面的代码:

result = df[df.Processid == 204].df["Processdate","ISofficial"].to_string(index=False)

我知道如何超过结果,但我不想要列名,索引和数据类型。 有人可以帮忙吗?

I have a below Dataframe with 3 columns:

df = DataFrame(query, columns=["Processid", "Processdate", "ISofficial"])

In Below code, I get Processdate based on Processid==204 (without Column Names):

result = df[df.Processid == 204].Processdate.to_string(index=False)

But I wan the same result for Two columns at once without column names, Something like below code:

result = df[df.Processid == 204].df["Processdate","ISofficial"].to_string(index=False)

I know how to get above result but I dont want Column names, Index and data type.
Can someone help?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡忘如思 2025-02-17 18:14:15

我认为您正在寻找header in to_string 参数。将其设置为false

df[df.Processid==204][['Processdate', 'ISofficial']].to_string(index=False, header=False)

I think you are looking for header argument in to_string parameters. Set it to False.

df[df.Processid==204][['Processdate', 'ISofficial']].to_string(index=False, header=False)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文