Skip to content

Commit dc6c678

Browse files
committed
TST: validation tests for concat of same timezones
closes #12217 xref #12306 which I think fixed Author: Jeff Reback <[email protected]> Closes #12316 from jreback/concat and squashes the following commits: 563b23b [Jeff Reback] TST: validation tests for concat of same timezones
1 parent cf8b7f8 commit dc6c678

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

doc/source/whatsnew/v0.18.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ Bug Fixes
919919
- Bug in not treating ``NaT`` as a missing value in datetimelikes when factorizing & with ``Categoricals`` (:issue:`12077`)
920920
- Bug in getitem when the values of a ``Series`` were tz-aware (:issue:`12089`)
921921
- Bug in ``Series.str.get_dummies`` when one of the variables was 'name' (:issue:`12180`)
922-
- Bug in ``pd.concat`` while concatenating tz-aware NaT series. (:issue:`11693`, :issue:`11755`)
922+
- Bug in ``pd.concat`` while concatenating tz-aware NaT series. (:issue:`11693`, :issue:`11755`, :issue:`12217`)
923923
- Bug in ``pd.read_stata`` with version <= 108 files (:issue:`12232`)
924924
- Bug in ``Series.resample`` using a frequency of ``Nano`` when the index is a ``DatetimeIndex`` and contains non-zero nanosecond parts (:issue:`12037`)
925925

pandas/tools/tests/test_merge.py

+43
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,49 @@ def test_concat_tz_series(self):
10881088
result = concat([x, y], ignore_index=True)
10891089
tm.assert_series_equal(result, expected)
10901090

1091+
# 12217
1092+
# 12306 fixed I think
1093+
1094+
# Concat'ing two UTC times
1095+
first = pd.DataFrame([[datetime(2016, 1, 1)]])
1096+
first[0] = first[0].dt.tz_localize('UTC')
1097+
1098+
second = pd.DataFrame([[datetime(2016, 1, 2)]])
1099+
second[0] = second[0].dt.tz_localize('UTC')
1100+
1101+
result = pd.concat([first, second])
1102+
self.assertEqual(result[0].dtype, 'datetime64[ns, UTC]')
1103+
1104+
# Concat'ing two London times
1105+
first = pd.DataFrame([[datetime(2016, 1, 1)]])
1106+
first[0] = first[0].dt.tz_localize('Europe/London')
1107+
1108+
second = pd.DataFrame([[datetime(2016, 1, 2)]])
1109+
second[0] = second[0].dt.tz_localize('Europe/London')
1110+
1111+
result = pd.concat([first, second])
1112+
self.assertEqual(result[0].dtype, 'datetime64[ns, Europe/London]')
1113+
1114+
# Concat'ing 2+1 London times
1115+
first = pd.DataFrame([[datetime(2016, 1, 1)], [datetime(2016, 1, 2)]])
1116+
first[0] = first[0].dt.tz_localize('Europe/London')
1117+
1118+
second = pd.DataFrame([[datetime(2016, 1, 3)]])
1119+
second[0] = second[0].dt.tz_localize('Europe/London')
1120+
1121+
result = pd.concat([first, second])
1122+
self.assertEqual(result[0].dtype, 'datetime64[ns, Europe/London]')
1123+
1124+
# Concat'ing 1+2 London times
1125+
first = pd.DataFrame([[datetime(2016, 1, 1)]])
1126+
first[0] = first[0].dt.tz_localize('Europe/London')
1127+
1128+
second = pd.DataFrame([[datetime(2016, 1, 2)], [datetime(2016, 1, 3)]])
1129+
second[0] = second[0].dt.tz_localize('Europe/London')
1130+
1131+
result = pd.concat([first, second])
1132+
self.assertEqual(result[0].dtype, 'datetime64[ns, Europe/London]')
1133+
10911134
def test_indicator(self):
10921135
# PR #10054. xref #7412 and closes #8790.
10931136
df1 = DataFrame({'col1': [0, 1], 'col_left': [

0 commit comments

Comments
 (0)