pyarrow.MapScalar#

class pyarrow.MapScalar#

基类: ListScalar, Mapping

用于映射(map)标量的具体类。

__init__(*args, **kwargs)#

方法

__init__(*args, **kwargs)

as_py(self, *[, maps_as_pydicts])

根据 'maps_as_pydicts' 将此值返回为 Python 列表或字典。

cast(self[, target_type, safe, options, ...])

将标量值转换为另一种数据类型。

count(value)

equals(self, Scalar other)

get(k[,d])

index(value, [start, [stop]])

如果值不存在,则引发 ValueError。

items()

keys(self)

返回映射的键作为列表。

validate(self, *[, full])

执行验证检查。

属性

is_valid

包含一个有效(非空)值。

type

Scalar 对象的数据类型。

as_py(self, *, maps_as_pydicts=None)#

根据 ‘maps_as_pydicts’ 将此值返回为 Python 列表或字典。

参数:
maps_as_pydictsstr, 可选, 默认 None

有效值为 None、‘lossy’ 或 ‘strict’。默认行为 (None) 是将 Arrow Map 数组转换为与 Arrow Map 顺序相同的原生 Python 关联列表(元组列表),如 [(key1, value1), (key2, value2), …]。

如果为 ‘lossy’ 或 ‘strict’,则将 Arrow Map 数组转换为原生 Python 字典。

如果为 ‘lossy’,则每当检测到重复键时,都会打印警告。重复键的最后看到的值将出现在 Python 字典中。如果为 ‘strict’,则会在检测到时引发异常。

cast(self, target_type=None, safe=None, options=None, memory_pool=None)#

将标量值转换为另一种数据类型。

用法请参见 pyarrow.compute.cast()

参数:
target_typeDataType, 默认 None

要转换成的目标类型。

safebool, 默认 True

是否检查转换错误(如溢出)。

optionsCastOptions, 默认 None

通过 CastOptions 传递的额外检查

memory_poolMemoryPool, 可选

函数执行期间用于分配的内存池。

返回:
scalar给定目标数据类型的 Scalar
count(value) integer -- 返回 value 出现的次数#
equals(self, Scalar other)#
参数:
otherpyarrow.Scalar
返回:
bool
get(k[, d]) 如果 k D 中,则返回 D[k],否则返回 d。d 默认为 None。#
index(value[, start[, stop]]) integer -- 返回 value 的第一个索引。#

如果值不存在,则引发 ValueError。

支持 start 和 stop 参数是可选的,但建议使用。

is_valid#

包含一个有效(非空)值。

items() 一个提供 D 项视图的类似集合的对象#
keys(self)#

返回映射的键作为列表。

type#

Scalar 对象的数据类型。

validate(self, *, full=False)#

执行验证检查。如果验证失败,则会引发异常。

默认情况下,仅运行低成本的验证检查。传递 full=True 进行彻底的验证检查(可能为 O(n))。

参数:
fullbool, 默认 False

如果为 True,则运行昂贵的检查,否则仅运行低成本检查。

引发:
ArrowInvalid
values#