Skip to content

Commit

Permalink
separate non-scalar tests from test_timestamps (#19385)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored and jreback committed Jan 25, 2018
1 parent 86d9af0 commit d3f7d2a
Show file tree
Hide file tree
Showing 7 changed files with 368 additions and 375 deletions.
10 changes: 10 additions & 0 deletions pandas/tests/frame/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,16 @@ def test_applymap(self):
result = frame.applymap(func)
tm.assert_frame_equal(result, frame)

def test_applymap_box_timestamps(self):
# #2689, #2627
ser = pd.Series(date_range('1/1/2000', periods=10))

def func(x):
return (x.hour, x.day, x.month)

# it works!
pd.DataFrame(ser).applymap(func)

def test_applymap_box(self):
# ufunc will not be boxed. Same test cases as the test_map_box
df = pd.DataFrame({'a': [pd.Timestamp('2011-01-01'),
Expand Down
19 changes: 19 additions & 0 deletions pandas/tests/indexes/datetimes/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,25 @@ def test_numpy_minmax(self):
tm.assert_raises_regex(
ValueError, errmsg, np.argmax, dr, out=0)

def test_round_daily(self):
dti = pd.date_range('20130101 09:10:11', periods=5)
result = dti.round('D')
expected = pd.date_range('20130101', periods=5)
tm.assert_index_equal(result, expected)

dti = dti.tz_localize('UTC').tz_convert('US/Eastern')
result = dti.round('D')
expected = pd.date_range('20130101',
periods=5).tz_localize('US/Eastern')
tm.assert_index_equal(result, expected)

result = dti.round('s')
tm.assert_index_equal(result, dti)

# invalid
for freq in ['Y', 'M', 'foobar']:
pytest.raises(ValueError, lambda: dti.round(freq))

def test_round(self):
for tz in self.tz:
rng = pd.date_range(start='2016-01-01', periods=5,
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/io/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,13 @@ def test_fallback_success(self):
banklist_data = os.path.join(DATA_PATH, 'banklist.html')
self.read_html(banklist_data, '.*Water.*', flavor=['lxml', 'html5lib'])

def test_to_html_timestamp(self):
rng = date_range('2000-01-01', periods=10)
df = DataFrame(np.random.randn(10, 4), index=rng)

result = df.to_html()
assert '2000-01-01' in result

def test_parse_dates_list(self):
df = DataFrame({'date': date_range('1/1/2001', periods=10)})
expected = df.to_html()
Expand Down
Loading

0 comments on commit d3f7d2a

Please sign in to comment.