[ 
https://issues.apache.org/jira/browse/ARROW-18264?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

&res updated ARROW-18264:
-------------------------
    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.
{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}

  was:
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}
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}


> [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
>            Priority: Minor
>
> 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)

Reply via email to