[ https://issues.apache.org/jira/browse/ARROW-18264?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Joris Van den Bossche resolved ARROW-18264. ------------------------------------------- Fix Version/s: 11.0.0 Resolution: Fixed Issue resolved by pull request 14637 [https://github.com/apache/arrow/pull/14637] > [Python] Add Time64Scalar.value field > ------------------------------------- > > Key: ARROW-18264 > URL: https://issues.apache.org/jira/browse/ARROW-18264 > Project: Apache Arrow > Issue Type: Improvement > Components: Python > Affects Versions: 10.0.0 > Environment: pyarrow==10.0.0 > No pandas installed > Reporter: &res > Assignee: &res > Priority: Minor > Labels: pull-request-available > Fix For: 11.0.0 > > Time Spent: 0.5h > Remaining Estimate: 0h > > 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. > {code:java} > time_ns = pa.array([1, 2, 3],pa.time64("ns")) > scalar = time_ns[0] > scalar.as_py() {code} > Raises: > {code:java} > 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{code} > But value isn't available: > {code:java} > scalar.value {code} > Raises: > {code:java} > AttributeError: 'pyarrow.lib.Time64Scalar' object has no attribute 'value' > {code} > The workaround is to do: > {code:java} > scalar.cast(pa.int64()).as_py() {code} > It'd be good if a value field was added to Time64Scalar, just like the > TimestampScalar > {code:java} > timestamp_ns = pa.array([1, 2, 3],pa.timestamp("ns", "UTC")) > scalar = timestamp_ns[0] > scalar.value {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)