@@ -76,6 +76,19 @@ def timestamps_in_interval_of_intervals(
76
76
77
77
Examples
78
78
--------
79
+ >>> # ignore first part, for testing purposes only...
80
+ >>> import pytest, pandas
81
+ >>> v = pandas.__version__
82
+ >>> if (
83
+ ... (v.count(".") == 1 and float(v) < 2.2)
84
+ ... or (
85
+ ... v.count(".") > 1
86
+ ... and float(v[:v.index(".", v.index(".") + 1)]) < 2.2
87
+ ... )
88
+ ... ):
89
+ ... pytest.skip("printed return only valid from pandas 2.2")
90
+ >>> #
91
+ >>> # example from here...
79
92
>>> timestamps = pd.DatetimeIndex(
80
93
... [
81
94
... pd.Timestamp('2021-03-12 14:00'),
@@ -96,6 +109,7 @@ def timestamps_in_interval_of_intervals(
96
109
>>> timestamps_in_interval_of_intervals(timestamps, intervals)
97
110
True
98
111
"""
112
+ # NOTE Can lose doctest skip when pandas support is >= 2.2
99
113
timestamps = [timestamps ] if isinstance (timestamps , pd .Timestamp ) else timestamps
100
114
ser = intervals .to_series ()
101
115
bv = ser .apply (lambda x : all ({ts in x for ts in timestamps }))
@@ -387,6 +401,19 @@ def remove_intervals_from_interval(
387
401
388
402
Examples
389
403
--------
404
+ >>> # ignore first part, for testing purposes only...
405
+ >>> import pytest, pandas
406
+ >>> v = pandas.__version__
407
+ >>> if (
408
+ ... (v.count(".") == 1 and float(v) < 2.2)
409
+ ... or (
410
+ ... v.count(".") > 1
411
+ ... and float(v[:v.index(".", v.index(".") + 1)]) < 2.2
412
+ ... )
413
+ ... ):
414
+ ... pytest.skip("printed return only valid from pandas 2.2")
415
+ >>> #
416
+ >>> # example from here...
390
417
>>> from pprint import pprint
391
418
>>> left = pd.date_range('2021-05-01 12:00', periods=5, freq='h')
392
419
>>> right = left + pd.Timedelta(30, 'min')
@@ -411,6 +438,7 @@ def remove_intervals_from_interval(
411
438
Interval(2021-05-01 15:30:00, 2021-05-01 16:00:00, closed='left'),
412
439
Interval(2021-05-01 16:30:00, 2021-05-01 17:30:00, closed='left')]
413
440
"""
441
+ # NOTE Can lose doctest skip when pandas support is >= 2.2
414
442
if not intervals .is_monotonic_increasing :
415
443
raise ValueError (
416
444
"`intervals` must be monotonically increasing although receieved"
0 commit comments