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



##########
File path: cpp/src/arrow/python/helpers.cc
##########
@@ -321,6 +323,14 @@ void InitPandasStaticData() {
     pandas_NA = ref.obj();
   }
 
+  // Import DateOffset type
+  OwnedRef offsets;
+  if (internal::ImportModule("pandas.tseries.offsets", &offsets).ok()) {

Review comment:
       It seems that DateOffset if available in the top-level pandas namespace, 
in which case I would import it from there 

##########
File path: cpp/src/arrow/python/datetime.h
##########
@@ -178,6 +182,17 @@ Result<PyObject*> StringToTzinfo(const std::string& tz);
 ARROW_PYTHON_EXPORT
 Result<std::string> TzinfoToString(PyObject* pytzinfo);
 
+/// Converts MonthDayNano to a python dictionary.
+///
+/// Returns a named tuple (pyarrow.MonthDayNanoTuple) containing attributes

Review comment:
       ```suggestion
   /// Returns a named tuple (pyarrow.MonthDayNano) containing attributes
   ```

##########
File path: python/pyarrow/array.pxi
##########
@@ -163,6 +163,12 @@ def array(object obj, type=None, mask=None, size=None, 
from_pandas=None,
     representation). Timezone-naive data will be implicitly interpreted as
     UTC.
 
+    Pandas's DateOffsets and dateutil.relativedelta.relativedelta are by
+    default converted as MonthDayNanoIntervalArray. relativedelta leapday's
+    are ignored as are all absolute fields on both objects. datetime.timedelta
+    can also be converted to MonthDayNanoIntervalArray but require passing
+    MonthDayIntervalType explicitly.

Review comment:
       ```suggestion
       MonthDayNanoIntervalType explicitly.
   ```

##########
File path: cpp/src/arrow/python/datetime.h
##########
@@ -178,6 +182,17 @@ Result<PyObject*> StringToTzinfo(const std::string& tz);
 ARROW_PYTHON_EXPORT
 Result<std::string> TzinfoToString(PyObject* pytzinfo);
 
+/// Converts MonthDayNano to a python dictionary.

Review comment:
       ```suggestion
   /// Converts MonthDayNano to a python namedtuple.
   ```
   
   

##########
File path: python/pyarrow/tests/test_pandas.py
##########
@@ -1495,6 +1495,19 @@ def test_timedeltas_nulls(self):
             expected_schema=schema,
         )
 
+    def test_month_day_nano_interval(self):
+        from pandas.tseries.offsets import DateOffset
+        df = pd.DataFrame({
+            'date_offset': [None,
+                            DateOffset(days=3600, months=3600, microseconds=3,
+                                       nanoseconds=600)]
+        })
+        field = pa.field('date_offset', pa.month_day_nano_interval())
+        schema = pa.schema([field])

Review comment:
       ```suggestion
           schema = pa.schema([('date_offset', pa.month_day_nano_interval()])
   ```

##########
File path: cpp/src/arrow/python/arrow_to_python_internal.h
##########
@@ -0,0 +1,52 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// Functions for converting between pandas's NumPy-based data representation
+// and Arrow data structures

Review comment:
       I think this comment is a left-over from copying another file?




-- 
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