Skip to content

Commit d78eed3

Browse files
Move and parameterize test
1 parent 38d8574 commit d78eed3

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

pandas/tests/resample/test_datetime_index.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,12 +1489,3 @@ def test_get_timestamp_range_edges(first, last, offset,
14891489
expected = (exp_first, exp_last)
14901490
assert result == expected
14911491

1492-
1493-
def test_apply_on_series():
1494-
# GH 25959
1495-
# Calling apply on a localized time series should not cause an error
1496-
index = pd.DatetimeIndex([1478064900001000000, 1480037118776792000])\
1497-
.tz_localize('UTC')
1498-
result = pd.Series(index).apply(lambda x: pd.Series([1, 2]))
1499-
expected = pd.DataFrame([[1, 2], [1, 2]])
1500-
assert_frame_equal(result, expected)

pandas/tests/series/test_apply.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,3 +677,14 @@ def test_map_missing_mixed(self, vals, mapping, exp):
677677
result = s.map(mapping)
678678

679679
tm.assert_series_equal(result, pd.Series(exp))
680+
681+
@pytest.mark.parametrize("dti,exp", [
682+
(Series([1, 2], index=pd.DatetimeIndex([0, 31536000000])), DataFrame(np.repeat([[1, 2]], 2, axis=0))),
683+
(tm.makeTimeSeries(nper=30), DataFrame(np.repeat([[1, 2]], 30, axis=0)))
684+
])
685+
def test_apply_on_date_time_index_aware_series(self, dti, exp):
686+
# GH 25959
687+
# Calling apply on a localized time series should not cause an error
688+
index = dti.tz_localize('UTC').index
689+
result = pd.Series(index).apply(lambda x: pd.Series([1, 2]))
690+
assert_frame_equal(result, exp)

0 commit comments

Comments
 (0)