Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-18257

[Python] array of time64 type changes from Time64Type to DataType

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 10.0.0
    • 11.0.0
    • Python
    • python 3.9
      pyarrow 10.0.0
      No pandas installed

    Description

      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)

       

      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

      Attachments

        Issue Links

          Activity

            People

              0x26dres &res
              0x26dres &res
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h