当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python cudf.Series.hash_values用法及代码示例


用法:

Series.hash_values(method='murmur3')

计算此列中值的哈希值。

参数

method{‘murmur3’, ‘md5’},默认 ‘murmur3’

要使用的散列函数: * murmur3:MurmurHash3 散列函数。 * md5:MD5 哈希函数。

返回

Series

具有哈希值的系列。

例子

Series

>>> import cudf
>>> series = cudf.Series([10, 120, 30])
>>> series
0     10
1    120
2     30
dtype: int64
>>> series.hash_values(method="murmur3")
0   -1930516747
1     422619251
2    -941520876
dtype: int32
>>> series.hash_values(method="md5")
0    7be4bbacbfdb05fb3044e36c22b41e8b
1    947ca8d2c5f0f27437f156cfbfab0969
2    d0580ef52d27c043c8e341fd5039b166
dtype: object

DataFrame

>>> import cudf
>>> df = cudf.DataFrame({"a": [10, 120, 30], "b": [0.0, 0.25, 0.50]})
>>> df
     a     b
0   10  0.00
1  120  0.25
2   30  0.50
>>> df.hash_values(method="murmur3")
0    -330519225
1    -397962448
2   -1345834934
dtype: int32
>>> df.hash_values(method="md5")
0    57ce879751b5169c525907d5c563fae1
1    948d6221a7c4963d4be411bcead7e32b
2    fe061786ea286a515b772d91b0dfcd70
dtype: object

相关用法


注:本文由纯净天空筛选整理自rapids.ai大神的英文原创作品 cudf.Series.hash_values。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。