我想检查哪个 Vin 在模块列中有绝对值

发布于 2025-01-15 16:38:33 字数 130 浏览 0 评论 0原文

在此处输入图像描述

我想检查哪个 Vin 在模块列中具有绝对值。如果结果列中有,则无论 Vin 列中出现该数字,我都希望选择“是”。

enter image description here

I want to check which Vin has abs value in column Module. If it has then in the Result column I want Yes wherever that number is present in the column Vin.

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

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

发布评论

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

评论(1

北笙凉宸 2025-01-22 16:38:33

您可以先检查 Module == "abs" 的所有行,然后将结果按 Vin 分组,并使用 transform('any')True,则将每个组转换为 True 行,否则将转换为 False 行:

df['Result'] = df['Module'].eq('abs').groupby(df['Vin']).transform('any').map({True: 'Yes', False: 'No'})

You can first check all the rows where Module == "abs", and then group the result by Vin, and use transform('any') to convert each group to rows of True if the group contains a single True, rows of False otherwise:

df['Result'] = df['Module'].eq('abs').groupby(df['Vin']).transform('any').map({True: 'Yes', False: 'No'})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文