pitrou commented on a change in pull request #11302:
URL: https://github.com/apache/arrow/pull/11302#discussion_r721539304



##########
File path: python/pyarrow/scalar.pxi
##########
@@ -514,6 +514,32 @@ cdef class DurationScalar(Scalar):
             return datetime.timedelta(microseconds=sp.value // 1000)
 
 
+cdef class MonthDayNanoIntervalScalar(Scalar):
+    """
+    Concrete class for month, day, nanosecond scalars.
+    """
+
+    @property
+    def value(self):
+        """
+        Returns this value pyarrow.MonthDayNanoTuple.
+        """
+        cdef PyObject* val
+        val = GetResultValue(ARROW_TO_PYTHON.ToPrimitive(
+            (deref(self.wrapped.get()))))
+        return PyObject_to_object(val)
+
+    def as_py(self):
+        """
+        Return this value as a Pandas DateOffset instance if Pandas is present
+        otherwise as a named tuple containing months days and nanoseconds.

Review comment:
       Hmm, it's a bit unfortunate for timestamps, but the decision there is 
understandable: returning a `datetime.datetime` loses precision. Also, 
`pandas.Timestamp` is probably API-compatible with `datetime.datetime`.
   
   You don't lose any precision by returning a `MonthDayNano`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to