Skip to content

Commit d466fd2

Browse files
committed
Address whatsnew and test comments
1 parent 9e9b89e commit d466fd2

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

doc/source/whatsnew/v0.21.0.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ Previously, :func:`to_datetime` did not localize datetime ``Series`` data when `
326326

327327
pd.to_datetime(s, utc=True)
328328

329-
Additionally, DataFrames with datetime columns returned by :func:`read_sql_table` and :func:`read_sql_query` with the `parse_dates` argument specified will also be localized to UTC only if the original SQL columns were timezone aware datetime columns.
329+
Additionally, DataFrames with datetime columns that were parsed by :func:`read_sql_table` and :func:`read_sql_query` will also be localized to UTC only if the original SQL columns were timezone aware datetime columns.
330330

331331
.. _whatsnew_0210.api:
332332

pandas/tests/indexes/datetimes/test_tools.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,10 @@ def test_to_datetime_tz_pytz(self):
265265
(list, DatetimeIndex, tm.assert_index_equal),
266266
(np.array, DatetimeIndex, tm.assert_index_equal),
267267
(Series, Series, tm.assert_series_equal)])
268-
def test_to_datetime_utc_true_with_constructors(self,
269-
init_constructor,
270-
end_constructor,
271-
test_method):
268+
def test_to_datetime_utc_true(self,
269+
init_constructor,
270+
end_constructor,
271+
test_method):
272272
# See gh-11934 & gh-6415
273273
data = ['20100102 121314', '20100102 121315']
274274
expected_data = [pd.Timestamp('2010-01-02 12:13:14', tz='utc'),
@@ -292,9 +292,13 @@ def test_to_datetime_utc_true_with_series_single_value(self):
292292
expected = pd.Series([pd.Timestamp(ts, tz='utc')])
293293
tm.assert_series_equal(result, expected)
294294

295-
@pytest.mark.parametrize("dtype", [None, 'datetime64[ns]'])
296-
def test_to_datetime_utc_true_with_naive_series(self, dtype):
297-
test_dates = ['2013-01-01 00:00:00-01:00'] * 10
295+
@pytest.mark.parametrize("data, dtype",
296+
[('2013-01-01 00:00:00-01:00', None),
297+
('2013-01-01 00:00:00-01:00','datetime64[ns]'),
298+
('2013-01-01 01:00:00', None),
299+
('2013-01-01 01:00:00', 'datetime64[ns]')])
300+
def test_to_datetime_utc_true_with_naive_dtype_series(self, data, dtype):
301+
test_dates = [data] * 10
298302
ser = pd.Series(test_dates, dtype=dtype)
299303
result = pd.to_datetime(ser, utc=True)
300304
expected_data = [pd.Timestamp('20130101 01:00:00', tz='utc')] * 10

pandas/tests/io/test_sql.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,6 +1312,8 @@ def check(col):
13121312
assert is_datetime64tz_dtype(col.dtype)
13131313
assert str(col.dt.tz) == 'UTC'
13141314
expected = sql.read_sql_table("types_test_data", self.conn)
1315+
col = expected.DateColWithTz
1316+
assert is_datetime64tz_dtype(col.dtype)
13151317
# Removed ".astype('datetime64[ns, UTC]')"after GH 6415 was fixed
13161318
tm.assert_series_equal(df.DateColWithTz, expected.DateColWithTz)
13171319

0 commit comments

Comments
 (0)