MCPcopy Create free account
hub / github.com/apache/arrow / test_interval_array_from_dateoffset

Function test_interval_array_from_dateoffset

python/pyarrow/tests/test_array.py:2911–2942  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2909
2910@pytest.mark.pandas
2911def test_interval_array_from_dateoffset():
2912 from pandas.tseries.offsets import DateOffset
2913 data = [
2914 None,
2915 DateOffset(years=1, months=1,
2916 days=1, seconds=1, microseconds=1,
2917 minutes=1, hours=1, weeks=1, nanoseconds=1),
2918 DateOffset()]
2919
2920 arr = pa.array(data)
2921 assert isinstance(arr, pa.MonthDayNanoIntervalArray)
2922 assert arr.type == pa.month_day_nano_interval()
2923 expected_list = [
2924 None,
2925 pa.MonthDayNano([13, 8, 3661000001001]),
2926 pa.MonthDayNano([0, 0, 0])]
2927 expected = pa.array(expected_list)
2928 assert arr.equals(expected)
2929 expected_from_pandas = [
2930 None, DateOffset(months=13, days=8,
2931 nanoseconds=(
2932 datetime.timedelta(seconds=1, microseconds=1,
2933 minutes=1, hours=1) //
2934 datetime.timedelta(microseconds=1) * 1000) + 1),
2935 DateOffset(months=0, days=0, nanoseconds=0)]
2936
2937 assert arr.to_pandas().tolist() == expected_from_pandas
2938
2939 # nested list<interval> array conversion
2940 actual_list = pa.array([data]).to_pandas().tolist()
2941 assert len(actual_list) == 1
2942 assert list(actual_list[0]) == expected_from_pandas
2943
2944
2945@pytest.mark.numpy

Callers

nothing calls this directly

Calls 4

lenFunction · 0.85
listFunction · 0.85
equalsMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected