&res created ARROW-18257:
----------------------------

             Summary: [Python] array of time64 type changes from Time64Type to 
DataType
                 Key: ARROW-18257
                 URL: https://issues.apache.org/jira/browse/ARROW-18257
             Project: Apache Arrow
          Issue Type: Bug
         Environment: python 3.9
pyarrow 10.0.0
No pandas installed
            Reporter: &res


When creating an array of time64 elements, the array type information is 
changed from Time64Type to DataType. 

While it's not an issue as such, given it still looks like an array of time64, 
I can't access special attributes of the Time64Type (for example unit)

 
{code:java}
dtype = pa.time64("ns")
time_array = pa.array(
    [
        1,
        2,
        3
    ],
    dtype
)
assert pa.types.is_time64(time_array.type) is True
assert isinstance(dtype, pa.Time64Type) is True
assert isinstance(time_array.type, pa.Time64Type) is False # Wrong
assert isinstance(time_array.type, pa.DataType) is True # Wrong
assert dtype == time_array.type
assert dtype.unit == "ns"
with pytest.raises(AttributeError, match=r"'pyarrow.lib.DataType' object has no 
attribute 'unit'"):
    # Should be able to access unit:
    time_array.type.unit{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to