gpt4 book ai didi

vaex - 在 Vaex 中进行计算的虚拟列

转载 作者:行者123 更新时间:2023-12-05 04:38:48 24 4
gpt4 key购买 nike

我想使用 Vaex 中的另一列为计算设置一个虚拟列。我需要在此计算中使用 if 语句。一般来说,我想打电话

df['calculation_col'] = log(df['original_col']) if df['original_col'] == 0 else -4

然后我尝试在 Vaex 中运行计数函数:

hist = df.count(
binby='calculation_col',
limits=limits,
shape=binnum,
delay=True
)

当我尝试执行此代码时,出现错误 ValueError: zero-size array to reduction operation minimum which has no identity

如何在 Vaex 中为虚拟列使用条件?

最佳答案

可能最“vaex”的方法是使用where:

import vaex
df = vaex.example()
# The syntax is where(condition, if satisfied, else)
df['calculated_col'] = df.func.where(df['x'] < 10, 0, -4)

关于vaex - 在 Vaex 中进行计算的虚拟列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70513644/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com