Skip to content

Commit 17f8233

Browse files
committed
tests for pandas-dev#16402
1 parent 5623234 commit 17f8233

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

pandas/tests/series/test_missing.py

+34
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,40 @@ def test_datetime64_tz_fillna(self):
273273
pd.Timestamp('2012-11-11 00:00:00+01:00')])
274274
assert_series_equal(df.fillna(method='bfill'), exp)
275275

276+
def test_fillna_consistency(self):
277+
# GH 16402
278+
# fillna with a tz aware to a tz-naive, should result in object
279+
280+
s = Series([Timestamp('20130101'), pd.NaT])
281+
282+
result = s.fillna(Timestamp('20130101', tz='US/Eastern'))
283+
expected = Series([Timestamp('20130101'),
284+
Timestamp('2013-01-01', tz='US/Eastern')],
285+
dtype='object')
286+
assert_series_equal(result, expected)
287+
288+
# where (we ignore the raise_on_error)
289+
result = s.where([True, False],
290+
Timestamp('20130101', tz='US/Eastern'),
291+
raise_on_error=False)
292+
assert_series_equal(result, expected)
293+
294+
result = s.where([True, False],
295+
Timestamp('20130101', tz='US/Eastern'),
296+
raise_on_error=True)
297+
assert_series_equal(result, expected)
298+
299+
# with a non-datetime
300+
result = s.fillna('foo')
301+
expected = Series([Timestamp('20130101'),
302+
'foo'])
303+
assert_series_equal(result, expected)
304+
305+
# assignment
306+
s2 = s.copy()
307+
s2[1] = 'foo'
308+
assert_series_equal(s2, expected)
309+
276310
def test_datetime64tz_fillna_round_issue(self):
277311
# GH 14872
278312

0 commit comments

Comments
 (0)