Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
10.0.0
-
pyarrow==10.0.0
No pandas installed
Description
At the moment, when pandas is not installed, it is not possible to access the underlying value for a Time64Scalar of "ns" precision without casting it to int64.
time_ns = pa.array([1, 2, 3],pa.time64("ns"))
scalar = time_ns[0]
scalar.as_py()
Raises:
ValueError: Nanosecond resolution temporal type 1 is not safely convertible to microseconds to convert to datetime.datetime. Install pandas to return as Timestamp with nanosecond support or access the .value attribute
But value isn't available:
scalar.value
Raises:
AttributeError: 'pyarrow.lib.Time64Scalar' object has no attribute 'value'
The workaround is to do:
scalar.cast(pa.int64()).as_py()
It'd be good if a value field was added to Time64Scalar, just like the TimestampScalar
timestamp_ns = pa.array([1, 2, 3],pa.timestamp("ns", "UTC")) scalar = timestamp_ns[0] scalar.value