如何在DASK中使用多个条件的变量创建变量?
我想应用与NP.SELECT类似的内容,但使用DASK函数或属性。
I would like to apply something similar to np.select but using dask functions or attributes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,我假设您不仅在使用dask,还使用dask-dataframes。如果您在此处查看文档: https://docs.dask.orgg/en/最新/dataframe.html 您会发现,在DASK系列上进行索引被认为很快。因此,这样的例子
应该完美地工作。考虑到基本上使用布尔指示器来选择索引,我们可以使用乘法扩展示例。 true由a表示为零,零表示
true * true * true
的乘法始终等于1,而false * true * true
,true * false
和false * false
将产生零。因此,应该为您提供所需的功能。
请注意,当您使用DASK DataFrames时,实际结果只能根据要求产生。因此,如果您想运行计算,链
.compute
在您的语句背后进行计算,所以我希望这会有所帮助
So I am assuming that you are not just using Dask, but Dask-Dataframes. If you look at the documentation here: https://docs.dask.org/en/latest/dataframe.html you will see that indexing over a Dask Series is considered to be fast. So an example like
Should work perfectly. Considering that basically uses a boolean indicator to select the index, we can extend the example by using the multiplication. True is represented by a 1 and False by a zero, which means that a multiplication of
True * True
will always equal 1, whilstFalse * True
,True * False
andFalse * False
will yield a zero.Should therefore give you the functionality that you are looking for.
Please note that when you are using Dask DataFrames, that the actual result will only be produced on request. So chain
.compute
behind your statement if you want to run the calculations like soI hope this helps