Skip to content

Commit d3f7d2a

Browse files
jbrockmendeljreback
authored andcommitted
separate non-scalar tests from test_timestamps (#19385)
1 parent 86d9af0 commit d3f7d2a

File tree

7 files changed

+368
-375
lines changed

7 files changed

+368
-375
lines changed

pandas/tests/frame/test_apply.py

+10
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,16 @@ def test_applymap(self):
428428
result = frame.applymap(func)
429429
tm.assert_frame_equal(result, frame)
430430

431+
def test_applymap_box_timestamps(self):
432+
# #2689, #2627
433+
ser = pd.Series(date_range('1/1/2000', periods=10))
434+
435+
def func(x):
436+
return (x.hour, x.day, x.month)
437+
438+
# it works!
439+
pd.DataFrame(ser).applymap(func)
440+
431441
def test_applymap_box(self):
432442
# ufunc will not be boxed. Same test cases as the test_map_box
433443
df = pd.DataFrame({'a': [pd.Timestamp('2011-01-01'),

pandas/tests/indexes/datetimes/test_ops.py

+19
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,25 @@ def test_numpy_minmax(self):
144144
tm.assert_raises_regex(
145145
ValueError, errmsg, np.argmax, dr, out=0)
146146

147+
def test_round_daily(self):
148+
dti = pd.date_range('20130101 09:10:11', periods=5)
149+
result = dti.round('D')
150+
expected = pd.date_range('20130101', periods=5)
151+
tm.assert_index_equal(result, expected)
152+
153+
dti = dti.tz_localize('UTC').tz_convert('US/Eastern')
154+
result = dti.round('D')
155+
expected = pd.date_range('20130101',
156+
periods=5).tz_localize('US/Eastern')
157+
tm.assert_index_equal(result, expected)
158+
159+
result = dti.round('s')
160+
tm.assert_index_equal(result, dti)
161+
162+
# invalid
163+
for freq in ['Y', 'M', 'foobar']:
164+
pytest.raises(ValueError, lambda: dti.round(freq))
165+
147166
def test_round(self):
148167
for tz in self.tz:
149168
rng = pd.date_range(start='2016-01-01', periods=5,

pandas/tests/io/test_html.py

+7
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,13 @@ def test_fallback_success(self):
868868
banklist_data = os.path.join(DATA_PATH, 'banklist.html')
869869
self.read_html(banklist_data, '.*Water.*', flavor=['lxml', 'html5lib'])
870870

871+
def test_to_html_timestamp(self):
872+
rng = date_range('2000-01-01', periods=10)
873+
df = DataFrame(np.random.randn(10, 4), index=rng)
874+
875+
result = df.to_html()
876+
assert '2000-01-01' in result
877+
871878
def test_parse_dates_list(self):
872879
df = DataFrame({'date': date_range('1/1/2001', periods=10)})
873880
expected = df.to_html()

0 commit comments

Comments
 (0)