我知道我可以通过铸造创建一个
pa.StructScalar
:
import pyarrow as pa
import pyarrow.compute as pac
struct_scalar = pac.cast(
{"hello": "greetings", "world": 5},
target_type=pa.struct([("hello", pa.string()), ("world", pa.int16())]),
)
print(f"{struct_scalar=}")
print(f"{struct_scalar.type=}")
但是还有其他方法可以创建结构体标量吗?
pyarrow.scalar
import pyarrow as pa
scalar = pa.scalar(
{"hello": "greetings", "world": 5},
type=pa.struct([("hello", pa.string()), ("world", pa.int16())]),
)