• Docs >
  • torcharrow.functional
Shortcuts

torcharrow.functional

Velox 核心功能

Velox核心函数包含在torcharrow.functional中。

以下是Velox字符串函数lpad的示例用法:

>>> import torcharrow as ta
>>> from torcharrow import functional
>>> col = ta.column(["abc", "x", "yz"])
# Velox's lpad function: https://facebookincubator.github.io/velox/functions/string.html#lpad
>>> functional.lpad(col, 5, "123")
0  '12abc'
1  '1231x'
2  '123yz'
dtype: String(nullable=True), length: 3, null_count: 0, device: cpu

这是Velox数组函数array_except的另一个使用示例:

>>> col1 = ta.column([[1, 2, 3], [1, 2, 3], [1, 2, 2], [1, 2, 2]])
>>> col2 = ta.column([[4, 5, 6], [1, 2], [1, 1, 2], [1, 3, 4]])
# Velox's array_except function: https://facebookincubator.github.io/velox/functions/array.html#array_except
>>> functional.array_except(col1, col2)
0  [1, 2, 3]
1  [3]
2  []
3  [2]
dtype: List(Int64(nullable=True), nullable=True), length: 4, null_count: 0

文本操作

add_tokens

将一系列标记/索引附加或前置到列中。

推荐操作

bucketize

对输入特征应用分桶处理。

sigrid_hash

对索引或索引列表应用哈希。

firstx

返回输入列前x个值

has_id_overlap

如果两个输入列重叠,则返回1.0,否则返回0.0

id_overlap_count

返回两个ID列表之间的重叠次数

get_max_count

如果input_ids和matching_ids之间存在重叠项,则将重叠id的最大实例数贡献给最大计数。

get_jaccard_similarity

返回input_ids和matching_ids之间的jaccard_similarity。

get_cosine_similarity

返回由input_ids加权定义的向量与由matching_ids加权定义的向量之间的余弦值

get_score_sum

返回在matching_id_scores中所有分数的总和,这些分数对应的id在matching_ids中,并且也在input_ids中。

get_score_min

返回在matching_id_scores中所有分数的最小值,这些分数对应的id在matching_ids中,并且也在input_ids中。

get_score_max

返回在matching_id_scores中所有分数的最小值,这些分数对应的id在matching_ids中,并且也在input_ids中。

高级操作

scale_to_0_1

返回缩放到范围 [0,1] 的列数据。