diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index 0ca5b9cdf1d57..cfcee79281eec 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -248,6 +248,8 @@ Timezones - Bug in :meth:`Series.truncate` with a tz-aware :class:`DatetimeIndex` which would cause a core dump (:issue:`9243`) - Bug in :class:`Series` constructor which would coerce tz-aware and tz-naive :class:`Timestamp`s to tz-aware (:issue:`13051`) - Bug in :class:`Index` with ``datetime64[ns, tz]`` dtype that did not localize integer data correctly (:issue:`20964`) +- Bug in :class:`DatetimeIndex` where constructing with an integer and tz would not localize correctly (:issue:`12619`) +- Bug in :func:`DataFrame.fillna` where a ``ValueError`` would raise when one column contained a ``datetime64[ns, tz]`` dtype (:issue:`15522`) Offsets ^^^^^^^ @@ -326,7 +328,7 @@ Sparse Reshaping ^^^^^^^^^ -- +- Bug in :func:`pandas.concat` when joining resampled DataFrames with timezone aware index (:issue:`13783`) - - diff --git a/pandas/tests/frame/test_missing.py b/pandas/tests/frame/test_missing.py index f1113fd6debf2..9567c08781856 100644 --- a/pandas/tests/frame/test_missing.py +++ b/pandas/tests/frame/test_missing.py @@ -300,6 +300,17 @@ def test_fillna(self): pd.Timestamp('2012-11-11 00:00:00+01:00')]}) assert_frame_equal(df.fillna(method='bfill'), exp) + # with timezone in another column + # GH 15522 + df = pd.DataFrame({'A': pd.date_range('20130101', periods=4, + tz='US/Eastern'), + 'B': [1, 2, np.nan, np.nan]}) + result = df.fillna(method='pad') + expected = pd.DataFrame({'A': pd.date_range('20130101', periods=4, + tz='US/Eastern'), + 'B': [1., 2., 2., 2.]}) + assert_frame_equal(result, expected) + def test_na_actions_categorical(self): cat = Categorical([1, 2, 3, np.nan], categories=[1, 2, 3]) diff --git a/pandas/tests/indexes/datetimes/test_construction.py b/pandas/tests/indexes/datetimes/test_construction.py index ae98510951845..5653943c37e37 100644 --- a/pandas/tests/indexes/datetimes/test_construction.py +++ b/pandas/tests/indexes/datetimes/test_construction.py @@ -496,6 +496,13 @@ def test_constructor_with_int_tz(self, klass, box, tz, dtype): expected = klass([ts]) assert result == expected + def test_construction_int_rountrip(self, tz_naive_fixture): + # GH 12619 + tz = tz_naive_fixture + result = 1293858000000000000 + expected = DatetimeIndex([1293858000000000000], tz=tz).asi8[0] + assert result == expected + class TestTimeSeries(object): diff --git a/pandas/tests/reshape/test_concat.py b/pandas/tests/reshape/test_concat.py index 8d819f9926abb..d05fd689ed754 100644 --- a/pandas/tests/reshape/test_concat.py +++ b/pandas/tests/reshape/test_concat.py @@ -2351,6 +2351,15 @@ def test_concat_datetime_timezone(self): tm.assert_frame_equal(result, expected) + # GH 13783: Concat after resample + with catch_warnings(record=True): + result = pd.concat([df1.resample('H').mean(), + df2.resample('H').mean()]) + expected = pd.DataFrame({'a': [1, 2, 3] + [np.nan] * 3, + 'b': [np.nan] * 3 + [1, 2, 3]}, + index=idx1.append(idx1)) + tm.assert_frame_equal(result, expected) + @pytest.mark.parametrize('pdt', [pd.Series, pd.DataFrame, pd.Panel]) @pytest.mark.parametrize('dt', np.sctypes['float'])