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

[Python] Add Time64Scalar.value field

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 10.0.0
    • 11.0.0
    • Python
    • 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 

      Attachments

        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 40m
                1h 40m