我正在尝试将pyarrow时间戳类型转换为time64类型。但它显示了演员错误
import pyarrow as pa
from datetime import datetime
dt = datetime.now()
table = pa.Table.from_pydict({'ts': pa.array([dt, dt])})
new_schema = table.schema.set(0, pa.field('ts', pa.time64('us')))
table.schema
# ts: timestamp[us]
new_schema
# ts: time64[us]
table.cast(new_schema)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pyarrow/table.pxi", line 1329, in pyarrow.lib.Table.cast
File "pyarrow/table.pxi", line 277, in pyarrow.lib.ChunkedArray.cast
File "/home/inspiron/.virtualenvs/par/lib/python3.7/site-packages/pyarrow/compute.py", line 243, in cast
return call_function("cast", [arr], options)
File "pyarrow/_compute.pyx", line 446, in pyarrow._compute.call_function
File "pyarrow/_compute.pyx", line 275, in pyarrow._compute.Function.call
File "pyarrow/error.pxi", line 122, in pyarrow.lib.pyarrow_internal_check_status
File "pyarrow/error.pxi", line 105, in pyarrow.lib.check_status
pyarrow.lib.ArrowNotImplementedError: Unsupported cast from timestamp[us] to time64 using function cast_time64
有什么方法可以让这个角色成为可能吗
time64[us]
是一天中的一段时间。它表示自午夜以来的微秒数。它不绑定到任何特定日期,并且不能转换为时间戳箭头文档有点稀疏,但是parquet docs解释得更好:
相关问题 更多 >
编程相关推荐