Skip to content

Commit 44d22a7

Browse files
committed
Add tz_convert test
1 parent 1c15441 commit 44d22a7

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

pandas/core/indexes/accessors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def __new__(cls, data):
322322
orig = data if is_categorical_dtype(data) else None
323323
if orig is not None:
324324
data = Series(
325-
orig.values.__array__(),
325+
np.asarray(orig.values),
326326
name=orig.name,
327327
copy=False,
328328
dtype=orig.values.categories.dtype,

pandas/tests/indexes/test_category.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,18 @@ def test_dt_tz_localize(self, tz_aware_fixture):
11371137
expected = datetimes.dt.tz_localize(tz)
11381138
tm.assert_series_equal(result, expected)
11391139

1140-
@pytest.mark.parametrize("accessor", [("year"), ("month"), ("day")])
1140+
def test_dt_tz_convert(self, tz_aware_fixture):
1141+
# GH 27952
1142+
tz = tz_aware_fixture
1143+
datetimes = pd.Series(
1144+
["2019-01-01", "2019-01-01", "2019-01-02"], dtype="datetime64[ns, MET]"
1145+
)
1146+
categorical = datetimes.astype("category")
1147+
result = categorical.dt.tz_convert(tz)
1148+
expected = datetimes.dt.tz_convert(tz)
1149+
tm.assert_series_equal(result, expected)
1150+
1151+
@pytest.mark.parametrize("accessor", ["year", "month", "day"])
11411152
def test_dt_other_accessors(self, accessor):
11421153
# GH 27952
11431154
datetimes = pd.Series(

0 commit comments

Comments
 (0)