首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cudf.DataFrame.sort_values --“`ValueError:无法将NotImplementedType类型的值转换为cudf标量”

cudf.DataFrame.sort_values --“`ValueError:无法将NotImplementedType类型的值转换为cudf标量”
EN

Stack Overflow用户
提问于 2022-09-19 09:47:13
回答 2查看 78关注 0票数 0

在cudf sort_values上使用DataFrame (版本: 22.2.0)时出错:

代码语言:javascript
复制
>>> import cudf
>>> df = cudf.DataFrame()
>>> df['a'] = [0, 1, 2]
>>> df['b'] = [-3, 2, 0]
>>> df.sort_values('b')
ValueError: Cannot convert value of type NotImplementedType to cudf scalar

你知道我为什么会犯这样的错误吗?(PS:上面的例子来自于文档)

要了解信息,以下是Traceback的最后电话:

代码语言:javascript
复制
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~/miniconda3/envs/devs/lib/python3.9/site-packages/cudf/core/indexed_frame.py:554, in IndexedFrame._gather(self, gather_map, keep_index, nullify, check_bounds)
    551 if not is_integer_dtype(gather_map.dtype):
    552     gather_map = gather_map.astype("int32")
--> 554 if not libcudf.copying._gather_map_is_valid(
    555     gather_map, len(self), check_bounds, nullify
    556 ):
    557     raise IndexError("Gather map index is out of bounds.")
    559 return self._from_columns_like_self(
    560     libcudf.copying.gather(
    561         list(self._index._columns + self._columns)
   (...)
    568     self._index.names if keep_index else None,
    569 )

File cudf/_lib/copying.pyx:65, in cudf._lib.copying._gather_map_is_valid()

File ~/miniconda3/envs/devs/lib/python3.9/site-packages/cudf/core/scalar.py:264, in Scalar.__ge__(self, other)
    263 def __ge__(self, other):
--> 264     return self._scalar_binop(other, "__ge__")

File ~/miniconda3/envs/devs/lib/python3.9/site-packages/cudf/core/scalar.py:346, in Scalar._scalar_binop(self, other, op)
    344 else:
    345     result = self._dispatch_scalar_binop(other, op)
--> 346     return Scalar(result, dtype=out_dtype)

File ~/miniconda3/envs/devs/lib/python3.9/site-packages/cudf/core/scalar.py:75, in Scalar.__init__(self, value, dtype)
     73     self._device_value = value
     74 else:
---> 75     self._host_value, self._host_dtype = self._preprocess_host_value(
     76         value, dtype
     77     )

File ~/miniconda3/envs/devs/lib/python3.9/site-packages/cudf/core/scalar.py:156, in Scalar._preprocess_host_value(self, value, dtype)
    153 if isinstance(value, decimal.Decimal) and dtype is None:
    154     dtype = cudf.Decimal128Dtype._from_decimal(value)
--> 156 value = to_cudf_compatible_scalar(value, dtype=dtype)
    158 if dtype is None:
    159     if not valid:

File ~/miniconda3/envs/devs/lib/python3.9/site-packages/cudf/utils/dtypes.py:246, in to_cudf_compatible_scalar(val, dtype)
    243     return val
    245 if not cudf.api.types._is_scalar_or_zero_d_array(val):
--> 246     raise ValueError(
    247         f"Cannot convert value of type {type(val).__name__} "
    248         "to cudf scalar"
    249     )
    251 if isinstance(val, Decimal):
    252     return val

ValueError: Cannot convert value of type NotImplementedType to cudf scalar

非常感谢你的帮助

EN

回答 2

Stack Overflow用户

发布于 2022-09-19 14:24:17

此问题在cuDF的当前版本(22.08)中不存在,在一些较早的版本中也可能不存在。与正在查看的文档相比,您可能使用的是过时的版本(或者这是一个简短的错误)。

代码语言:javascript
复制
import cudf
df = cudf.DataFrame()
df['a'] = [0, 1, 2]
df['b'] = [-3, 2, 0]
df.sort_values('b')
    a   b
0   0   -3
2   2   0
1   1   2
票数 1
EN

Stack Overflow用户

发布于 2022-10-03 14:06:15

我认为问题归结于NumPy 1.23中的标量处理。如果您安装了NumPy 1.22,这应该可以工作。xref https://github.com/rapidsai/integration/pull/539

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73771513

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档