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



##########
File path: python/pyarrow/tests/test_array.py
##########
@@ -2162,6 +2163,101 @@ def test_array_from_numpy_ascii():
     assert arrow_arr.equals(expected)
 
 
[email protected]
+def test_interval_array_from_timedelta():
+    data = [
+        None,
+        datetime.timedelta(days=1, seconds=1, microseconds=1,
+                           milliseconds=1, minutes=1, hours=1, weeks=1)]
+
+    # From timedelta (explicit type required)
+    arr = pa.array(data, pa.month_day_nano_interval())
+    assert isinstance(arr, pa.MonthDayNanoIntervalArray)
+    assert arr.type == pa.month_day_nano_interval()
+    expected_list = [
+        None,
+        pa.MonthDayNanoTuple([0, 8,
+                              (datetime.timedelta(seconds=1, microseconds=1,
+                                                  milliseconds=1, minutes=1,
+                                                  hours=1) //
+                               datetime.timedelta(microseconds=1)) * 1000])]
+    expected = pa.array(expected_list)
+    assert arr.equals(expected)
+    assert arr.to_pylist() == expected_list
+
+# dateutil is dependency of pandas
+
+
[email protected]
+def test_interval_array_from_relativedelta():
+    from dateutil.relativedelta import relativedelta
+    from pandas.tseries.offsets import DateOffset
+    data = [
+        None,
+        relativedelta(years=1, months=1,
+                      days=1, seconds=1, microseconds=1,
+                      minutes=1, hours=1, weeks=1, leapdays=1)]
+    # Note leapdays are ignored.

Review comment:
       added to pa.array(...) doc string.




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